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

>> + char buf[sizeof("18446744073709551615\0")];
>
>rofl. We really ought to have a #define for "this architecture's maximum
>length of an asciified int/long/s32/s64". Generally people do
>guess-and-giggle-plus-20%, or they just get it wrong.

And this one seems wrong[*] to me too (making it a rofl²).
It is two chars (or one[*]) too long.

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)

[*] Depending on what the original author wanted.



Jan Engelhardt
--
\
 
 \ /
  Last update: 2006-03-25 20:29    [W:0.079 / U:1.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site