From patchwork Fri Oct 6 11:36:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 729993 Delivered-To: patch@linaro.org Received: by 2002:a5d:4005:0:b0:31d:da82:a3b4 with SMTP id n5csp458090wrp; Fri, 6 Oct 2023 04:43:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF9s5crB2+HMk1ivif1Qlx387fNqt8dpj5/IzyLEbkCaqC5LPpLQzp/kPIZe1tO9dnVwS1Q X-Received: by 2002:a25:9c85:0:b0:d7f:d6a7:d57d with SMTP id y5-20020a259c85000000b00d7fd6a7d57dmr7245881ybo.27.1696592610569; Fri, 06 Oct 2023 04:43:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696592610; cv=none; d=google.com; s=arc-20160816; b=TL9Nhvq5sGwND/a0JqfuVECdFnxzjP4a0I3LhdU8S6HxIwWA5OMfeXhuPwDMvMnyq9 TX+X+YDRAjc8BRysXTHK7dFY1sFRwtYpZSryG/gwAeF/eBl00G4qLWEhibu2Mcms16/Y ntq7ik/Lyb2kvHboVEVzUVP4Uv1+Lg/kIyIWyp+Y1E8owvsnCiWYDImAFNQ2+m8989gQ EZywmsL1TUZtyZAiCn01A4WBFXG4ydVwx0WoolcrLlgihCD+aHb1YLKItclHXrz+4J+D 8TyPfL8TcPhVAMWjpyinWaJWv1Ab/fL0J2wBAH45lpmOonk6T+HTFYDEIb0wkNuQDtf7 KViw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=n4zK6KjuMtQLVDggv3EgqW/6JdP/Ds6q2/MlLzdYfIo=; fh=i1pZRuKD5MhOXg6DnHnBvYF8Xhy7p4U+yXFYiz2hjRc=; b=DobUEwmYCgwRPXsqfxbex6VrF/M7nPThaBOJQW7n80tmVNXJ0eJXyyB2tGibNNKYcb aRxxq0TcFVWzObHGY+mc+nbv0i/vX24FXdlvWcD8zUicZnMN0nfXTUEdYQmUs2p8TYO7 Rx7JKbI+j0EiSHQQvNHo8RqcHYUWulOcKZaQ3VWkZfPMIVyqGqePpFrn14eH6zJvlRVC VfK+Qoo38S9MWAcN6CQkGxpVFOzR7dhc+Iw8WB52rvzIiQo92QSTy0t0pByzZjGiSEfW 4q/NSYRq2FyiRbIv+xhBfT01qNmEOfF3Y9nFmuxX8k/GaIvbY7zzUmORbIM6ycWZM8c1 lZXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DQRlTDMk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id c10-20020a0ce14a000000b0065b0fc01a9dsi2202355qvl.385.2023.10.06.04.43.30 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 06 Oct 2023 04:43:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=DQRlTDMk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qoj9V-0005Eu-C5; Fri, 06 Oct 2023 07:37:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoj96-00054D-Qj for qemu-devel@nongnu.org; Fri, 06 Oct 2023 07:37:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoj90-0000EB-Iw for qemu-devel@nongnu.org; Fri, 06 Oct 2023 07:37:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1696592239; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=n4zK6KjuMtQLVDggv3EgqW/6JdP/Ds6q2/MlLzdYfIo=; b=DQRlTDMkRIAhFz8x9k15kOVtRjkQeJM7qX+v+EaurPWii1WqLi/fVurwvomrxGVPFfPmWN bJ7YmMqlezyRK/00AWWhJ/Gz+1z5T44p/GyCNfBire6pmHNNjxluBSEiBZdk7oF/vMs4Bj qUokaaguM8dF0ibvMlSaUtrNaFY8+Pk= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-610-_gTK8oOBPE653dfOeH2B0g-1; Fri, 06 Oct 2023 07:37:01 -0400 X-MC-Unique: _gTK8oOBPE653dfOeH2B0g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D797E3827DE8; Fri, 6 Oct 2023 11:37:00 +0000 (UTC) Received: from blackfin.pond.sub.org (unknown [10.39.192.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 952055CC01; Fri, 6 Oct 2023 11:37:00 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 8076E21E691B; Fri, 6 Oct 2023 13:36:57 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Cc: stefanha@redhat.com, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Eric Blake , Richard Henderson Subject: [PULL 15/32] qemu-img: Clean up global variable shadowing Date: Fri, 6 Oct 2023 13:36:40 +0200 Message-ID: <20231006113657.3803180-16-armbru@redhat.com> In-Reply-To: <20231006113657.3803180-1-armbru@redhat.com> References: <20231006113657.3803180-1-armbru@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé Fix: qemu-img.c:247:46: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] static bool is_valid_option_list(const char *optarg) ^ qemu-img.c:265:53: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] static int accumulate_options(char **options, char *optarg) ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/getopt.h:77:14: note: previous declaration is here extern char *optarg; /* getopt(3) external variables */ ^ Signed-off-by: Philippe Mathieu-Daudé Message-ID: <20231004120019.93101-7-philmd@linaro.org> Reviewed-by: Eric Blake Reviewed-by: Richard Henderson Signed-off-by: Markus Armbruster --- qemu-img.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index a48edb7101..6068ab0d27 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -235,25 +235,25 @@ void help(void) } /* - * Is @optarg safe for accumulate_options()? + * Is @list safe for accumulate_options()? * It is when multiple of them can be joined together separated by ','. - * To make that work, @optarg must not start with ',' (or else a + * To make that work, @list must not start with ',' (or else a * separating ',' preceding it gets escaped), and it must not end with * an odd number of ',' (or else a separating ',' following it gets * escaped), or be empty (or else a separating ',' preceding it can * escape a separating ',' following it). * */ -static bool is_valid_option_list(const char *optarg) +static bool is_valid_option_list(const char *list) { - size_t len = strlen(optarg); + size_t len = strlen(list); size_t i; - if (!optarg[0] || optarg[0] == ',') { + if (!list[0] || list[0] == ',') { return false; } - for (i = len; i > 0 && optarg[i - 1] == ','; i--) { + for (i = len; i > 0 && list[i - 1] == ','; i--) { } if ((len - i) % 2) { return false; @@ -262,19 +262,19 @@ static bool is_valid_option_list(const char *optarg) return true; } -static int accumulate_options(char **options, char *optarg) +static int accumulate_options(char **options, char *list) { char *new_options; - if (!is_valid_option_list(optarg)) { - error_report("Invalid option list: %s", optarg); + if (!is_valid_option_list(list)) { + error_report("Invalid option list: %s", list); return -1; } if (!*options) { - *options = g_strdup(optarg); + *options = g_strdup(list); } else { - new_options = g_strdup_printf("%s,%s", *options, optarg); + new_options = g_strdup_printf("%s,%s", *options, list); g_free(*options); *options = new_options; }