diff mbox

misplaced parenthesis?

Message ID 4A0DC131.8020606@gmail.com (mailing list archive)
State Superseded
Headers show

Commit Message

Roel Kluin May 15, 2009, 7:23 p.m. UTC
Fix misplaced parenthesis.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
I think this is what was intended? Note that this patch may affect
profiling.

--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Randolph Chung May 16, 2009, 4:14 a.m. UTC | #1
This is a bit confusingly written, but your patch does not appear to be 
correct.

== has higher precedence than &, so you are basically changing it to:
if (likely(t1 & 1))

it really should be

-	if (likely(t1 & (sizeof(unsigned int)-1)) == 0) {
+	if (likely((t1 & (sizeof(unsigned int)-1)) == 0)) {

randolph


Roel Kluin wrote:
> Fix misplaced parenthesis.
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> I think this is what was intended? Note that this patch may affect
> profiling.
>
> diff --git a/arch/parisc/lib/memcpy.c b/arch/parisc/lib/memcpy.c
> index bbda909..30207b0 100644
> --- a/arch/parisc/lib/memcpy.c
> +++ b/arch/parisc/lib/memcpy.c
> @@ -405,7 +405,7 @@ byte_copy:
>  
>  unaligned_copy:
>  	/* possibly we are aligned on a word, but not on a double... */
> -	if (likely(t1 & (sizeof(unsigned int)-1)) == 0) {
> +	if (likely(t1 & (sizeof(unsigned int)-1) == 0)) {
>  		t2 = src & (sizeof(unsigned int) - 1);
>  
>  		if (unlikely(t2 != 0)) {
> --
> To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   

--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Matt Turner May 16, 2009, 5:48 a.m. UTC | #2
Does gcc produce different code for the three variations?

Matt

On Sat, May 16, 2009 at 12:14 AM, Randolph Chung <randolph@tausq.org> wrote:
> This is a bit confusingly written, but your patch does not appear to be
> correct.
>
> == has higher precedence than &, so you are basically changing it to:
> if (likely(t1 & 1))
>
> it really should be
>
> -       if (likely(t1 & (sizeof(unsigned int)-1)) == 0) {
> +       if (likely((t1 & (sizeof(unsigned int)-1)) == 0)) {
>
> randolph
>
>
> Roel Kluin wrote:
>>
>> Fix misplaced parenthesis.
>>
>> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>> ---
>> I think this is what was intended? Note that this patch may affect
>> profiling.
>>
>> diff --git a/arch/parisc/lib/memcpy.c b/arch/parisc/lib/memcpy.c
>> index bbda909..30207b0 100644
>> --- a/arch/parisc/lib/memcpy.c
>> +++ b/arch/parisc/lib/memcpy.c
>> @@ -405,7 +405,7 @@ byte_copy:
>>   unaligned_copy:
>>        /* possibly we are aligned on a word, but not on a double... */
>> -       if (likely(t1 & (sizeof(unsigned int)-1)) == 0) {
>> +       if (likely(t1 & (sizeof(unsigned int)-1) == 0)) {
>>                t2 = src & (sizeof(unsigned int) - 1);
>>                  if (unlikely(t2 != 0)) {
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Randolph Chung May 18, 2009, 1:42 a.m. UTC | #3
The wrong version of course produces different code....

the original and the corrected one may produce different code depending 
on how the compiler schedules things.

randolph

Matt Turner wrote:
> Does gcc produce different code for the three variations?
>
> Matt
>
> On Sat, May 16, 2009 at 12:14 AM, Randolph Chung <randolph@tausq.org> wrote:
>   
>> This is a bit confusingly written, but your patch does not appear to be
>> correct.
>>
>> == has higher precedence than &, so you are basically changing it to:
>> if (likely(t1 & 1))
>>
>> it really should be
>>
>> -       if (likely(t1 & (sizeof(unsigned int)-1)) == 0) {
>> +       if (likely((t1 & (sizeof(unsigned int)-1)) == 0)) {
>>
>> randolph
>>
>>
>> Roel Kluin wrote:
>>     
>>> Fix misplaced parenthesis.
>>>
>>> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
>>> ---
>>> I think this is what was intended? Note that this patch may affect
>>> profiling.
>>>
>>> diff --git a/arch/parisc/lib/memcpy.c b/arch/parisc/lib/memcpy.c
>>> index bbda909..30207b0 100644
>>> --- a/arch/parisc/lib/memcpy.c
>>> +++ b/arch/parisc/lib/memcpy.c
>>> @@ -405,7 +405,7 @@ byte_copy:
>>>   unaligned_copy:
>>>        /* possibly we are aligned on a word, but not on a double... */
>>> -       if (likely(t1 & (sizeof(unsigned int)-1)) == 0) {
>>> +       if (likely(t1 & (sizeof(unsigned int)-1) == 0)) {
>>>                t2 = src & (sizeof(unsigned int) - 1);
>>>                  if (unlikely(t2 != 0)) {
>>> --
>>> To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
>>> the body of a message to majordomo@vger.kernel.org
>>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>>
>>>       
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>>     
> --
> To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>   

--
To unsubscribe from this list: send the line "unsubscribe linux-parisc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/parisc/lib/memcpy.c b/arch/parisc/lib/memcpy.c
index bbda909..30207b0 100644
--- a/arch/parisc/lib/memcpy.c
+++ b/arch/parisc/lib/memcpy.c
@@ -405,7 +405,7 @@  byte_copy:
 
 unaligned_copy:
 	/* possibly we are aligned on a word, but not on a double... */
-	if (likely(t1 & (sizeof(unsigned int)-1)) == 0) {
+	if (likely(t1 & (sizeof(unsigned int)-1) == 0)) {
 		t2 = src & (sizeof(unsigned int) - 1);
 
 		if (unlikely(t2 != 0)) {