From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-out.m-online.net (mail-out.m-online.net [IPv6:2001:a60:0:28:0:1:25:1]) by sourceware.org (Postfix) with ESMTPS id B178B3858D28 for ; Tue, 18 Jan 2022 15:30:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B178B3858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=linux-m68k.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nefkom.net Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 4JdXlJ57T0z1sCwg; Tue, 18 Jan 2022 16:30:04 +0100 (CET) Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 4JdXlJ4r6Yz1qqkS; Tue, 18 Jan 2022 16:30:04 +0100 (CET) X-Virus-Scanned: amavisd-new at mnet-online.de Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id ms0OsPIHUXAS; Tue, 18 Jan 2022 16:30:03 +0100 (CET) X-Auth-Info: OLQcrkia3lUn3OlIT9/y7Hby9U/w/Ek0g17+8sK+XdVNWq2wZLxes6xdtymz5csr Received: from igel.home (ppp-46-244-174-214.dynamic.mnet-online.de [46.244.174.214]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Tue, 18 Jan 2022 16:30:03 +0100 (CET) Received: by igel.home (Postfix, from userid 1000) id 0222A2C3A01; Tue, 18 Jan 2022 16:30:02 +0100 (CET) From: Andreas Schwab To: "H.J. Lu via Libc-alpha" Cc: Yann Droneaud , "H.J. Lu" Subject: Re: [PATCH] src/ext4_resize.c: set errno to 0 before the strtoull call References: <1642405014-3287-1-git-send-email-xuyang2018.jy@fujitsu.com> <61E6298D.80006@fujitsu.com> <61E64FED.2010906@fujitsu.com> <87fspl6s44.fsf@igel.home> <1f209861-9ab7-340a-f4a9-f28423a39a4c@opteya.com> X-Yow: There's a little picture of ED MCMAHON doing BAD THINGS to JOAN RIVERS in a $200,000 MALIBU BEACH HOUSE!! Date: Tue, 18 Jan 2022 16:30:02 +0100 In-Reply-To: (H. J. Lu via Libc-alpha's message of "Tue, 18 Jan 2022 06:54:43 -0800") Message-ID: <87bl096ozp.fsf@igel.home> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.91 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2022 15:30:07 -0000 On Jan 18 2022, H.J. Lu via Libc-alpha wrote: >> Something like: >> >> errno = 0; /* must be cleared to distinguish error */ > ^^^^^^^^^^^^^^^^^ Remove it. You cannot remove that. strtoull will not modify errno when there is no error, so if you want to distinguish a valid return value from an erroneous one you need to clear errno before the call. https://pubs.opengroup.org/onlinepubs/9699919799/functions/strtoul.html Since 0, {ULONG_MAX}, and {ULLONG_MAX} are returned on error and are also valid returns on success, an application wishing to check for error situations should set errno to 0, then call strtoul() or strtoull(), then check errno. -- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."