public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Dike <jdike@addtoit.com>
To: Jan Engelhardt <jengelh@linux01.gwdg.de>
Cc: Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org,
	user-mode-linux-devel@lists.sourceforge.net
Subject: Re: [PATCH 12/16] UML - Memory hotplug
Date: Sat, 25 Mar 2006 15:08:45 -0500	[thread overview]
Message-ID: <20060325200845.GA4143@ccure.user-mode-linux.org> (raw)
In-Reply-To: <Pine.LNX.4.61.0603252021330.29793@yvahk01.tjqt.qr>

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

      reply	other threads:[~2006-03-25 20:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-24 18:14 [PATCH 12/16] UML - Memory hotplug Jeff Dike
2006-03-24 22:45 ` Andrew Morton
2006-03-24 23:58   ` [uml-devel] " Blaisorblade
2006-03-25  1:19     ` Jeff Dike
2006-03-25  1:05   ` Jeff Dike
2006-04-05 22:02     ` Daniel Phillips
2006-04-06  1:56       ` [uml-devel] " Jeff Dike
2006-04-06  3:32         ` Andrew Morton
2006-04-06  3:33           ` Andrew Morton
2006-04-06  3:42         ` Daniel Phillips
2006-03-25 19:26   ` Jan Engelhardt
2006-03-25 20:08     ` Jeff Dike [this message]

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=20060325200845.GA4143@ccure.user-mode-linux.org \
    --to=jdike@addtoit.com \
    --cc=akpm@osdl.org \
    --cc=jengelh@linux01.gwdg.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /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