Re: [KERNEL]: Avoid divide in IS_ALIGN

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Herbert Xu <herbert@...>
Cc: Linus Torvalds <torvalds@...>, Andrew Morton <akpm@...>, Linux Kernel Mailing List <linux-kernel@...>
Date: Tuesday, November 20, 2007 - 5:43 pm

On Tue, 20 Nov 2007, Herbert Xu wrote:


Your macro modification is wrong.

Take 0x12345600, which is aligned on a 16-byte boundary.
Now, with your macro, we have for a 0x10 alignment:
      (0x12345600 & 0x0f) = (0x00 == 0) == TRUE (correct)
For an 0x20 alignment:
      (0x12345600 & 0x1f) = (0x00 == 0) == TRUE (incorrect)

In other words, the macro may work for some alignments, but
not all. It is therefore wrong. You need the modulus, the
remainder after division. Anything else is broken.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.22.1 on an i686 machine (5588.30 BogoMips).
My book : http://www.AbominableFirebug.com/
_


****************************************************************
The information transmitted in this message is confidential and may be privileged.  Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited.  If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to DeliveryErrors@analogic.com - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[KERNEL]: Avoid divide in IS_ALIGN, Herbert Xu, (Tue Nov 20, 9:56 am)
Re: [KERNEL]: Avoid divide in IS_ALIGN, linux-os (Dick Johnson), (Tue Nov 20, 5:43 pm)
Re: [KERNEL]: Avoid divide in IS_ALIGN, linux-os (Dick Johnson), (Wed Nov 21, 9:06 am)
Re: [KERNEL]: Avoid divide in IS_ALIGN, Andreas Schwab, (Wed Nov 21, 9:35 am)
Re: [KERNEL]: Avoid divide in IS_ALIGN, Joe Perches, (Tue Nov 20, 2:17 pm)
Re: [KERNEL]: Avoid divide in IS_ALIGN, Andrew Morton, (Tue Nov 20, 4:22 pm)