Re: [PATCH 12/16] UML - Memory hotplug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux