From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from sc8-sf-mx2-b.sourceforge.net ([10.3.1.92] helo=mail.sourceforge.net) by sc8-sf-list1.sourceforge.net with esmtp (Exim 4.30) id 1FNF2r-0005sq-57 for user-mode-linux-devel@lists.sourceforge.net; Sat, 25 Mar 2006 12:07:33 -0800 Received: from [198.99.130.12] (helo=saraswathi.solana.com) by mail.sourceforge.net with esmtps (TLSv1:AES256-SHA:256) (Exim 4.44) id 1FNF2p-0004jv-In for user-mode-linux-devel@lists.sourceforge.net; Sat, 25 Mar 2006 12:07:33 -0800 From: Jeff Dike Message-ID: <20060325200845.GA4143@ccure.user-mode-linux.org> References: <200603241814.k2OIExNn005555@ccure.user-mode-linux.org> <20060324144535.37b3daf7.akpm@osdl.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [uml-devel] Re: [PATCH 12/16] UML - Memory hotplug Sender: user-mode-linux-devel-admin@lists.sourceforge.net Errors-To: user-mode-linux-devel-admin@lists.sourceforge.net List-Unsubscribe: , List-Id: The user-mode Linux development list List-Post: List-Help: List-Subscribe: , List-Archive: Date: Sat, 25 Mar 2006 15:08:45 -0500 To: Jan Engelhardt Cc: Andrew Morton , linux-kernel@vger.kernel.org, user-mode-linux-devel@lists.sourceforge.net 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 > #include > 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 ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ User-mode-linux-devel mailing list User-mode-linux-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751068AbWCYUHt (ORCPT ); Sat, 25 Mar 2006 15:07:49 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751380AbWCYUHt (ORCPT ); Sat, 25 Mar 2006 15:07:49 -0500 Received: from saraswathi.solana.com ([198.99.130.12]:33953 "EHLO saraswathi.solana.com") by vger.kernel.org with ESMTP id S1751068AbWCYUHs (ORCPT ); Sat, 25 Mar 2006 15:07:48 -0500 Date: Sat, 25 Mar 2006 15:08:45 -0500 From: Jeff Dike To: Jan Engelhardt Cc: Andrew Morton , linux-kernel@vger.kernel.org, user-mode-linux-devel@lists.sourceforge.net Subject: Re: [PATCH 12/16] UML - Memory hotplug Message-ID: <20060325200845.GA4143@ccure.user-mode-linux.org> References: <200603241814.k2OIExNn005555@ccure.user-mode-linux.org> <20060324144535.37b3daf7.akpm@osdl.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.1i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org 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 > #include > 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