linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Documentation/unaligned-memory-access.txt: fix incorrect comparison operator
@ 2016-12-17 17:42 Cihangir Akturk
  2016-12-17 22:52 ` Ozgur Karatas
  2016-12-27 20:09 ` Jonathan Corbet
  0 siblings, 2 replies; 5+ messages in thread
From: Cihangir Akturk @ 2016-12-17 17:42 UTC (permalink / raw)
  To: corbet; +Cc: linux-doc, linux-kernel, Cihangir Akturk

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator
  2016-12-17 17:42 Documentation/unaligned-memory-access.txt: fix incorrect comparison operator Cihangir Akturk
@ 2016-12-17 22:52 ` Ozgur Karatas
  2016-12-20  0:22   ` Cihangir Akturk
  2016-12-27 20:09 ` Jonathan Corbet
  1 sibling, 1 reply; 5+ messages in thread
From: Ozgur Karatas @ 2016-12-17 22:52 UTC (permalink / raw)
  To: Cihangir Akturk, corbet; +Cc: linux-doc, linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator
  2016-12-17 22:52 ` Ozgur Karatas
@ 2016-12-20  0:22   ` Cihangir Akturk
  2016-12-20  9:51     ` Ozgur Karatas
  0 siblings, 1 reply; 5+ messages in thread
From: Cihangir Akturk @ 2016-12-20  0:22 UTC (permalink / raw)
  To: Ozgur Karatas; +Cc: corbet, linux-doc, linux-kernel

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.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator
  2016-12-20  0:22   ` Cihangir Akturk
@ 2016-12-20  9:51     ` Ozgur Karatas
  0 siblings, 0 replies; 5+ messages in thread
From: Ozgur Karatas @ 2016-12-20  9:51 UTC (permalink / raw)
  To: Cihangir Akturk; +Cc: corbet, linux-doc, linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Documentation/unaligned-memory-access.txt: fix incorrect comparison operator
  2016-12-17 17:42 Documentation/unaligned-memory-access.txt: fix incorrect comparison operator Cihangir Akturk
  2016-12-17 22:52 ` Ozgur Karatas
@ 2016-12-27 20:09 ` Jonathan Corbet
  1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Corbet @ 2016-12-27 20:09 UTC (permalink / raw)
  To: Cihangir Akturk; +Cc: linux-doc, linux-kernel

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-12-27 20:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-17 17:42 Documentation/unaligned-memory-access.txt: fix incorrect comparison operator Cihangir Akturk
2016-12-17 22:52 ` Ozgur Karatas
2016-12-20  0:22   ` Cihangir Akturk
2016-12-20  9:51     ` Ozgur Karatas
2016-12-27 20:09 ` Jonathan Corbet

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).