Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Sun, 10 Nov 2002 23:17:57 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Sun, 10 Nov 2002 23:17:57 -0500 Received: from air-2.osdl.org ([65.172.181.6]:52679 "EHLO mail.osdl.org") by vger.kernel.org with ESMTP id ; Sun, 10 Nov 2002 23:17:56 -0500 Date: Sun, 10 Nov 2002 20:19:35 -0800 (PST) From: "Randy.Dunlap" X-X-Sender: To: "Henning P. Schmiedehausen" cc: Subject: Re: [PATCH] Re: sscanf("-1", "%d", &i) fails, returns 0 In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1394 Lines: 41 On Sun, 10 Nov 2002, Randy.Dunlap wrote: | On Sun, 10 Nov 2002, Henning P. Schmiedehausen wrote: | | | "Randy.Dunlap" writes: | | | | >+ digit = *str; | | >+ if (is_sign && digit == '-') | | >+ digit = *(str + 1); | | | | If signed is not allowed and you get a "-", you're in an error case | | again... | | Yes, and a 0 value is returned. | IOW, asking for an unsigned number (in the format string) | and getting "-123" does return 0. | | What should it do? | This function can't return -EINPUTERROR or -EILSEQ. | (since it's after feature-freeze :) | And the original problem was that a leading '-' sign on a | signed number (!) caused a return of 0. At least that is fixed. | | So now the problem (?) is that a '-' sign on an unsigned number | returns 0. We can always add a big printk() there that | something is foul. Other ideas? It's noteworthy that vsscanf() completely gives up on scanning the rest of the input data at this point. E.g.: count = sscanf (input, "%x %i %i", &level, &next, &other); with = "-42 -86 -99" gives up on "-42" and returns 0 (as number of items scanned/converted). -- ~Randy - 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/