Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1544024 > unrolled thread

Documentation/unaligned-memory-access.txt: fix incorrect comparison operator

Started byCihangir Akturk <cakturk@gmail.com>
First post2016-12-17 18:50 +0100
Last post2016-12-27 21:10 +0100
Articles 5 — 3 participants

Back to article view | Back to linux.kernel


Contents

  Documentation/unaligned-memory-access.txt: fix incorrect comparison operator Cihangir Akturk <cakturk@gmail.com> - 2016-12-17 18:50 +0100
    Re: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator Ozgur Karatas <okaratas@member.fsf.org> - 2016-12-18 00:00 +0100
      Re: Documentation/unaligned-memory-access.txt: fix incorrect  comparison operator Cihangir Akturk <cakturk@gmail.com> - 2016-12-20 01:30 +0100
        Re: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator Ozgur Karatas <okaratas@member.fsf.org> - 2016-12-20 11:00 +0100
    Re: Documentation/unaligned-memory-access.txt: fix incorrect  comparison operator Jonathan Corbet <corbet@lwn.net> - 2016-12-27 21:10 +0100

#1544024 — Documentation/unaligned-memory-access.txt: fix incorrect comparison operator

FromCihangir Akturk <cakturk@gmail.com>
Date2016-12-17 18:50 +0100
SubjectDocumentation/unaligned-memory-access.txt: fix incorrect comparison operator
Message-ID<sPrho-4eD-31@gated-at.bofh.it>
In the actual implementation ether_addr_equal function tests for equality to 0
when returning. It seems in commit 0d74c4 it is somehow overlooked to change
this operator to reflect the actual function.

Signed-off-by: Cihangir Akturk <cakturk@gmail.com>
---
 Documentation/unaligned-memory-access.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Documentation/unaligned-memory-access.txt b/Documentation/unaligned-memory-access.txt
index a445da0..3f76c0c 100644
--- a/Documentation/unaligned-memory-access.txt
+++ b/Documentation/unaligned-memory-access.txt
@@ -151,7 +151,7 @@ bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
 #else
 	const u16 *a = (const u16 *)addr1;
 	const u16 *b = (const u16 *)addr2;
-	return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
+	return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) == 0;
 #endif
 }
 
-- 
2.1.4

[toc] | [next] | [standalone]


#1544051

FromOzgur Karatas <okaratas@member.fsf.org>
Date2016-12-18 00:00 +0100
Message-ID<sPw7n-7ne-1@gated-at.bofh.it>
In reply to#1544024
17.12.2016, 19:43, "Cihangir Akturk" <cakturk@gmail.com>:
> In the actual implementation ether_addr_equal function tests for equality to 0
> when returning. It seems in commit 0d74c4 it is somehow overlooked to change
> this operator to reflect the actual function.

why this "return" function need to be ==0? I think, u16 functions read memory but "0" is should not be equalty.
This way, -for the code to work- memory should be everytime unaligned !=0.


> Signed-off-by: Cihangir Akturk <cakturk@gmail.com>
> ---
>  Documentation/unaligned-memory-access.txt | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/unaligned-memory-access.txt b/Documentation/unaligned-memory-access.txt
> index a445da0..3f76c0c 100644
> --- a/Documentation/unaligned-memory-access.txt
> +++ b/Documentation/unaligned-memory-access.txt
> @@ -151,7 +151,7 @@ bool ether_addr_equal(const u8 *addr1, const u8 *addr2)
>  #else
>          const u16 *a = (const u16 *)addr1;
>          const u16 *b = (const u16 *)addr2;
> - return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
> + return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) == 0;
>  #endif
>  }
>
> --
> 2.1.4

[toc] | [prev] | [next] | [standalone]


#1544839 — Re: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator

FromCihangir Akturk <cakturk@gmail.com>
Date2016-12-20 01:30 +0100
SubjectRe: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator
Message-ID<sQgtz-6D2-1@gated-at.bofh.it>
In reply to#1544051
On Sun, Dec 18, 2016 at 12:52:12AM +0200, Ozgur Karatas wrote:
> 17.12.2016, 19:43, "Cihangir Akturk" <cakturk@gmail.com>:
> > In the actual implementation ether_addr_equal function tests for equality to 0
> > when returning. It seems in commit 0d74c4 it is somehow overlooked to change
> > this operator to reflect the actual function.
> 
> why this "return" function need to be ==0? I think, u16 functions read memory but "0" is should not be equalty.

XOR is true only when inputs differ. That means if inputs are the
same, then it outputs false (0) or whatever you call it. Then we
perform OR operation between those outputs. So if the result is 0 then
addr1 and addr2 is equal.

> This way, -for the code to work- memory should be everytime unaligned !=0.

Sorry I didn't quite get the point.

[toc] | [prev] | [next] | [standalone]


#1545018

FromOzgur Karatas <okaratas@member.fsf.org>
Date2016-12-20 11:00 +0100
Message-ID<sQpnc-3Uc-43@gated-at.bofh.it>
In reply to#1544839
20.12.2016, 02:22, "Cihangir Akturk" <cakturk@gmail.com>:
> On Sun, Dec 18, 2016 at 12:52:12AM +0200, Ozgur Karatas wrote:
>>  17.12.2016, 19:43, "Cihangir Akturk" <cakturk@gmail.com>:
>>  > In the actual implementation ether_addr_equal function tests for equality to 0
>>  > when returning. It seems in commit 0d74c4 it is somehow overlooked to change
>>  > this operator to reflect the actual function.
>>
>>  why this "return" function need to be ==0? I think, u16 functions read memory but "0" is should not be equalty.
>
> XOR is true only when inputs differ. That means if inputs are the
> same, then it outputs false (0) or whatever you call it. Then we
> perform OR operation between those outputs. So if the result is 0 then
> addr1 and addr2 is equal.

Thanks for this explanation to your patch. In this case the patch mentioned is valid. 
I checked, turned to "!=0" errors.

un-mem.c:29:18: error: ‘!’ (first use in this function)
         return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0;
                                                                                    ^
Also, don't need to send patch it secon time :)

>>  This way, -for the code to work- memory should be everytime unaligned !=0.
>
> Sorry I didn't quite get the point.

Regards,

~Ozgur

[toc] | [prev] | [next] | [standalone]


#1547741 — Re: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator

FromJonathan Corbet <corbet@lwn.net>
Date2016-12-27 21:10 +0100
SubjectRe: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator
Message-ID<sT6em-6EK-21@gated-at.bofh.it>
In reply to#1544024
On Sat, 17 Dec 2016 19:42:17 +0200
Cihangir Akturk <cakturk@gmail.com> wrote:

> In the actual implementation ether_addr_equal function tests for equality to 0
> when returning. It seems in commit 0d74c4 it is somehow overlooked to change
> this operator to reflect the actual function.

I've applied this to the docs tree, thanks.

jon

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web