Re: [PATCH 12/16] UML - Memory hotplug
From: Jeff Dike
Date: Sat Mar 25 2006 - 15:14:40 EST
On Sat, Mar 25, 2006 at 08:26:08PM +0100, Jan Engelhardt wrote:
>
> >> + char buf[sizeof("18446744073709551615\0")];
>
> And this one seems wrong[*] to me too (making it a rofl??).
> It is two chars (or one[*]) too long.
One - it needs to be NULL-terminated.
>
> Consider this test:
>
> #include <stdio.h>
> #include <string.h>
> int main(void) {
> printf("%d\n", sizeof("18446744073709551615\0"));
> printf("%d\n", sizeof("18446744073709551615"));
> printf("%d\n", strlen("18446744073709551615"));
> }
>
> Which will print, when executed,
>
> 22
> 21
> 20 (the "pure string" length)
>
Oops, I was basing this on a hazy (too hazy, apparently) recollection
that the C standard specified sizeof("literal string") as being the
pure string length. Now that I'm actually thinking about it, the
actual behavior makes much more sense.
Thanks for checking this out in time for me to fix it in my revised
patch.
Jeff
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/