public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Miller <davem@davemloft.net>
To: linux-kernel@vger.kernel.org
Cc: torvalds@osdl.org, herbert@gondor.apana.org
Subject: [PATCH]: Fix ALIGN() macro
Date: Fri, 22 Sep 2006 22:31:36 -0700 (PDT)	[thread overview]
Message-ID: <20060922.223136.41635862.davem@davemloft.net> (raw)


A regression or two were added by the crypto-2.6 tree merge.

I've tracked down one of them, and it's caused by the ALIGN()
macro truncating things down to "int".  Some of Herbert's new
code is aligning pointers using ALIGN() and this thus explodes
on 64-bit since the top 32-bits get chopped off.

It is arguable that perhaps we should make a special macro
for pointer aligning, but even in that case ALIGN() as a general
purpose macro should use the largest natural integer size in
order to not cause surprises for people.

I'm still trying to track down the other regression added by
the crypto merge.  I have it git bisected down to a single
changeset, but I haven't determined what's really wrong yet.
I should be able to kill that over the weekend.  I want to fix
this before merging my networking tree so I can be absolutely
sure that IPSEC doesn't break because of something in my tree :)

[KERNEL]: Do not truncate to 'int' in ALIGN() macro.

Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 851aa1b..2b2ae4f 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -31,7 +31,7 @@ #define ULLONG_MAX	(~0ULL)
 #define STACK_MAGIC	0xdeadbeef
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
-#define ALIGN(x,a) (((x)+(a)-1)&~((a)-1))
+#define ALIGN(x,a) (((x)+(a)-1UL)&~((a)-1UL))
 #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f))
 #define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
 

             reply	other threads:[~2006-09-23  5:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-23  5:31 David Miller [this message]
2006-09-23 12:46 ` [PATCH]: Fix ALIGN() macro Herbert Xu
2006-09-23 12:54   ` Herbert Xu
2006-09-23 14:40     ` Herbert Xu
2006-09-23 20:12       ` David Miller
2006-09-23 20:36       ` Kyle Moffett
2006-09-23 20:42         ` Kyle Moffett
2006-09-23 23:30         ` Herbert Xu
2006-09-23 19:57     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060922.223136.41635862.davem@davemloft.net \
    --to=davem@davemloft.net \
    --cc=herbert@gondor.apana.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox