From patchwork Wed Apr 29 21:30:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlos O'Donell X-Patchwork-Id: 1279694 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=sourceware.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=QgqOMAJy; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 49CBWQ71Rjz9sSK for ; Thu, 30 Apr 2020 07:30:26 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 57D213894E4A; Wed, 29 Apr 2020 21:30:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 57D213894E4A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1588195824; bh=uQYxgjeSkzxP2cOp8CGA0kJPt5eSEmQeNxaNYWZ+S5I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=QgqOMAJyDhAE37wsz+f8JFzIsREJDkABJIIzTbISoW3pJyhtI5hIqLqNnE5jHB95/ 6T0x+4d9bsDh/639e+3naPeEYSNk1ANiyaTt2VzNfHm0+VpSPM274UZQqyca/TlJEY ArAzI0vjvjQ3SKGDjyfaTVuU3x4ebhl/YU32j3NA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by sourceware.org (Postfix) with ESMTP id 765D53893653 for ; Wed, 29 Apr 2020 21:30:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 765D53893653 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-514-ANro9UViMYOGiKYNuj6zEw-1; Wed, 29 Apr 2020 17:30:19 -0400 X-MC-Unique: ANro9UViMYOGiKYNuj6zEw-1 Received: by mail-qt1-f198.google.com with SMTP id x56so4416360qtc.10 for ; Wed, 29 Apr 2020 14:30:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:organization:message-id:date :user-agent:mime-version:content-language:content-transfer-encoding; bh=uQYxgjeSkzxP2cOp8CGA0kJPt5eSEmQeNxaNYWZ+S5I=; b=SqJuHez0f0W9rPYtDyF2RNNPRxtpupH0RF4L5O554qFPo0AVil3xtYUejeom5NanQi iB7SDdyoJ0YVWTsoM0QMGzzE2SczAM/ePbVJoEiZrykNZah6BhRoq/XGgIRkdcDcyGrH 1z5tocQDNj7CfcdYbRfbMdREsNKbclor0z7yw1sDYlZFCVI4N0cP4ISB1EPpV/xPcD9Q KbmJPAAp4LOgnE2UGK6eYrJg4AffxSKNRqEdvGOXK/dChE+eiHuBgUdyZKmESxoYZm5A J2tRu7ZhU3Aso+rlq2pzHTBrKLZt7yOhxQBzXA+zBiST8B9VyaWQF+Of5mEo+i1gjhQk hsEw== X-Gm-Message-State: AGi0Pua3U2kxM86zD7aFazYe61ATPpRHnOXEJf11xU294kgO43I6X3nj g4UP/hJWFrCDeUkMBwnvzG3SIeU/6+Djo4PdCjK97Zmk0WGikgqTPtzeO1w09Rl9BXRorisH/G8 bJoqMhhyLtU/nia2564X0 X-Received: by 2002:a37:6854:: with SMTP id d81mr519505qkc.238.1588195819249; Wed, 29 Apr 2020 14:30:19 -0700 (PDT) X-Google-Smtp-Source: APiQypLBgoXpUgygMdiPNsWQYr4H9O4znTjXU59NlnzUPWvO87mvG3+jD0N6eefqWlrRKhYORDgckQ== X-Received: by 2002:a37:6854:: with SMTP id d81mr519476qkc.238.1588195818806; Wed, 29 Apr 2020 14:30:18 -0700 (PDT) Received: from [192.168.1.4] (198-84-170-103.cpe.teksavvy.com. [198.84.170.103]) by smtp.gmail.com with ESMTPSA id m7sm279091qke.124.2020.04.29.14.30.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Apr 2020 14:30:18 -0700 (PDT) To: libc-alpha , DJ Delorie Subject: [PATCH] support: Set errno before testing it. Organization: Red Hat Message-ID: <970ad4c1-2666-3a54-c591-e52b8014bd40@redhat.com> Date: Wed, 29 Apr 2020 17:30:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-22.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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-Patchwork-Original-From: Carlos O'Donell via Libc-alpha From: Carlos O'Donell Reply-To: Carlos O'Donell Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" DJ, I looked over the whole tree, and I only found on occurance of TEST_COMPARE (errno, 0); (and some variants) where we forgot to set errno to zero. Likewise in test-container.c we have an instance of strtol which doesn't check error returns. I've put these together in one patch to make testing easier. It fixes both cases, the missing check, and the potentially broken check (depends on what gets called before parse_int()). OK for master? 8< --- 8< --- 8< From 0adf117887d13925d9a00be1a0abd07ded6adfce Mon Sep 17 00:00:00 2001 From: Carlos O'Donell Date: Wed, 29 Apr 2020 16:31:29 -0400 Subject: [PATCH] support: Set errno before testing it. In test-conainer we should set errno to 0 before calling chmod, and check after with TEST_COMPARE. In tst-support_capture_subprocess we should set errno to 0 before checking it after the call to strtol. Tested on x86_64. --- support/test-container.c | 2 ++ support/tst-support_capture_subprocess.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/support/test-container.c b/support/test-container.c index 08d5195b7e..afc23db148 100644 --- a/support/test-container.c +++ b/support/test-container.c @@ -940,7 +940,9 @@ main (int argc, char **argv) else if (nt == 3 && strcmp (the_words[0], "chmod") == 0) { long int m; + errno = 0; m = strtol (the_words[1], NULL, 0); + TEST_COMPARE (errno, 0); if (chmod (the_words[2], m) < 0) FAIL_EXIT1 ("chmod %s: %s\n", the_words[2], strerror (errno)); diff --git a/support/tst-support_capture_subprocess.c b/support/tst-support_capture_subprocess.c index 67bbc1e8ae..6094dba49e 100644 --- a/support/tst-support_capture_subprocess.c +++ b/support/tst-support_capture_subprocess.c @@ -133,7 +133,9 @@ static int parse_int (const char *str) { char *endptr; - long int ret = strtol (str, &endptr, 10); + long int ret; + errno = 0; + ret = strtol (str, &endptr, 10); TEST_COMPARE (errno, 0); TEST_VERIFY (ret >= 0 && ret <= INT_MAX); return ret;