From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by sourceware.org (Postfix) with ESMTPS id 98AEC3857C46 for ; Tue, 18 Jan 2022 11:23:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 98AEC3857C46 Received: by mail-oo1-xc32.google.com with SMTP id b15-20020a4a878f000000b002dccc412166so5855962ooi.11 for ; Tue, 18 Jan 2022 03:23:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=iDwZ7XuZWYQPFU0R7LfxkEApJ4+8HOKg09sERdeGhnM=; b=XnGt/vUVxp4c3ZO9fgwrCOXVcuKETjO4jtsIwwudNGHiORL0wWp/SBVwjsgslCfLL2 QqZRquyOB4zfi2wbFERZI5AShl8Uz4S41qyNUVqHGTbARzCdoFnF8lB7CWqW2VDGGh65 FXLIEWyl1xCFzFN52tgKCaNZBvevvwkW0gooSKuidQe19WiEmBVLP6Bi19xylHQSng/U nkjOqLBS5s3VcBunBrFojXStR7PpDomNmziPThM1FfGXWfelHmV6dVjcyFKAzeZJo0/a +ScinRkmfa6vJfIGzl1UmAaWHfV46WxFWp2kWHeiNMCQQbVGerl3FYfLQVSg320ekdjG NQcw== X-Gm-Message-State: AOAM533Y66/SXnIVHeneqFbWbo+BFZLcboAn+tlf2mJJubDkDJZ2XlgY VliXQ1xBbWdaWz1f7k/4SNZodw== X-Google-Smtp-Source: ABdhPJx73K7W5fLXomQaZZXJOZlgueYohejotrFA4w9EmtMFsRyR0xopMq+j/HbU1Vdgh752eqrJCg== X-Received: by 2002:a4a:c44b:: with SMTP id h11mr17855190ooq.54.1642505007923; Tue, 18 Jan 2022 03:23:27 -0800 (PST) Received: from ?IPV6:2804:431:c7cb:989a:d7f1:4df2:e2ef:5281? ([2804:431:c7cb:989a:d7f1:4df2:e2ef:5281]) by smtp.gmail.com with ESMTPSA id p24sm6823716oto.32.2022.01.18.03.23.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 18 Jan 2022 03:23:27 -0800 (PST) Message-ID: Date: Tue, 18 Jan 2022 08:23:25 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH] src/ext4_resize.c: set errno to 0 before the strtoull call Content-Language: en-US To: "xuyang2018.jy@fujitsu.com" , Theodore Ts'o , "fweimer@redhat.com" Cc: "libc-alpha@sourceware.org" , "fstests@vger.kernel.org" References: <1642405014-3287-1-git-send-email-xuyang2018.jy@fujitsu.com> <61E6298D.80006@fujitsu.com> <61E64FED.2010906@fujitsu.com> From: Adhemerval Zanella In-Reply-To: <61E64FED.2010906@fujitsu.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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 11:23:30 -0000 On 18/01/2022 02:27, xuyang2018.jy--- via Libc-alpha wrote: > on 2022/1/18 11:56, Theodore Ts'o wrote: >> On Tue, Jan 18, 2022 at 02:43:26AM +0000, xuyang2018.jy@fujitsu.com wrote: >>>> You're right of course, but out of curiosity, which C library are you >>>> using? >>> I use glibc-2.34. >> >> Hmm, ok. I'm using glibc 2.31, and in this particular program, errno >> shouldn't have been set by any prior system call. I'm guessing maybe >> it was something in crt0 which ended up setting errno? > It maybe a glibc bug. > I cc glibc mailing list and see whether they have met this problem. > > @Florian > > Now, I use glibc-2.34 and run the following program[1] but the errno is > not 0 in the beginning. So is this a known bug on glibc-2.34(Theodore > doesn't meet this problem on glicb-2.31)? > > [1]https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git/tree/src/ext4_resize.c The errno should be only set on a failure, no function shall set errno to 0 (it is a POSIX definition which glibc adheres). The application need to explicitly set errno to 0 before the function call to check if an error occurs. So you need to do: errno = 0 new_size = strtoull(argv[2], &tmp, 10); if ((errno) || (*tmp != '\0')) { ... }