lkml.org 
[lkml]   [2006]   [Mar]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 12/16] UML - Memory hotplug
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@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-03-25 21:14    [W:0.081 / U:1.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site