Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754195AbZCKRXN (ORCPT ); Wed, 11 Mar 2009 13:23:13 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752191AbZCKRW5 (ORCPT ); Wed, 11 Mar 2009 13:22:57 -0400 Received: from mail-ew0-f177.google.com ([209.85.219.177]:38470 "EHLO mail-ew0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751670AbZCKRW4 (ORCPT ); Wed, 11 Mar 2009 13:22:56 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:message-id:from:to:cc:subject:in-reply-to:references :user-agent:mime-version:content-type; b=YRA9FMvknyPG3E46JUr4P3GY4odNN5ruLtodJJxmmNfajmo9d6lARuElZlF5HeRgi9 vCBeJUcNPqa8HQ2ntfb155QqocCIU8xg5BjtknZoeB4KT3DTpN8s62nEHsRx19NbB8gi wTcD1yoKzWaYQt94EEEoCyOwrHEPxHbst0Yz0= Date: Wed, 11 Mar 2009 18:23:08 +0100 Message-ID: <8763ig7z43.wl%vmayatsk@redhat.com> From: Vitaly Mayatskikh To: Linus Torvalds Cc: Vitaly Mayatskikh , linux-kernel@vger.kernel.org Subject: Re: your mail In-Reply-To: References: <87ljrccp57.wl%vmayatsk@redhat.com> User-Agent: Wanderlust/2.15.6 (Almost Unreal) Emacs/22.3 Mule/5.0 (SAKAKI) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1082 Lines: 43 > On Wed, 11 Mar 2009, Vitaly Mayatskikh wrote: > > > > (v)scnprintf says it should return 0 when size is 0, but doesn't do > > so. Also size_t is unsigned, it can't be less then 0. Fix the code and > > comments. > > That is bogus. > > The code really does (od "did"? Maybe you removed it) check for _smaller_ > than 0: Well, (v)scnprintf says it returns 0 for size <= 0, but really returns -1 for size == 0. I think, this code can't return 0 for size == 0: i=vsnprintf(buf,size,fmt,args); return (i >= size) ? (size - 1) : i; Systemtap's script: function test:long() %{ char tmp[256]; long err; err = scnprintf(tmp, 0, "%lu", (long)128); THIS->__retvalue = err; %} probe begin { printf("scnprintf returns %d\n", test()); } stap -g scnprintf.stp scnprintf returns -1 -- wbr, Vitaly -- 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/