From patchwork Wed Oct 4 12:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 729292 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a4e:0:b0:31d:da82:a3b4 with SMTP id v14csp303509wrs; Wed, 4 Oct 2023 05:03:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFdaHxRL8n7IPLcfMWudgkvE241ojaMUmLmgXOv7wJHaDEzE4r7prF1lImgMGZuFm5bnNOx X-Received: by 2002:a0c:ec90:0:b0:65d:f1d:d383 with SMTP id u16-20020a0cec90000000b0065d0f1dd383mr2200506qvo.3.1696421000081; Wed, 04 Oct 2023 05:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696421000; cv=none; d=google.com; s=arc-20160816; b=jnbHYjjdasKIIsDOMxFGvReK27QFZfWqK8rAt3SJk/IoPoIhSvk6s0q4SIqDrkGyLk 4WJdajgCEoMkZzZJ3aS3mwjA5TowlC+Wp4XxKa5LzzdGV1/E6m6yBOjzdADXOCXhWRcR EmxPbexm7KGEjOmGfE2qrbNFCwKEJ18OJ6X+PfVshKExMENTQqD5H4puznP35ei5xgGE 3FNOrfbieOlkEFqwaSz9aOVJlBRWjX+XLgO6sh/aQbr2roZCtCvSvVm0WCs9aJ/DC4Jf eJjdcPc713okKaI3NrLiIxceH7DjOPsl3fY6p9Ac0hEDKsKlbY0ErC5Ok6RQhCFS7yR2 lnIQ== 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=f0GICmTJrrPt/1QlpCchvnQWSMZXbQVxu/WDlIYHaUw=; fh=DGsemwhdqtom3k1xyp/Ay3eBo/+/1/cVk5wggzCgk24=; b=dLXCApUnvXQfjX4qtxu0nkT/bkbefzJvlsMXwKFmqmmG/RxjWmMndSIBDPsaM5D9Ay 3sz9yzIATEmo0QnRpIyRqMdVmPySm2rCKW2r266Sl7IiJvtkZjK6uuMTe+4jNjQeAKXB nkyp4YvS9FDae4kDA7+TJSuVaU8QmrHfi31q/cpwjFaKAwBuJ/OR+0FAgeJqYjQHsZW5 Bn6T4DhBD06JT/3t3hAxudhVWdRlegNgRN+oNoFfY+C6ALIgNEcfUdaR1Yj405kVQisE 4RFHzRS5r1u3AlhiUXDkEEjJLj0oYeHIhI9qre8rsjSJaxBASqec8nQZ8GXauZVkBcpA wUSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nkBv0Brz; 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=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f12-20020a0ccc8c000000b0065b305bbc43si1348614qvl.534.2023.10.04.05.03.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 04 Oct 2023 05:03:20 -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=@linaro.org header.s=google header.b=nkBv0Brz; 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=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qo0ao-0001Wx-31; Wed, 04 Oct 2023 08:03:06 -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 1qo0Yd-0008Um-Km for qemu-devel@nongnu.org; Wed, 04 Oct 2023 08:01:04 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qo0Yb-00010J-J5 for qemu-devel@nongnu.org; Wed, 04 Oct 2023 08:00:50 -0400 Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-32487efc319so2025082f8f.1 for ; Wed, 04 Oct 2023 05:00:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1696420847; x=1697025647; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f0GICmTJrrPt/1QlpCchvnQWSMZXbQVxu/WDlIYHaUw=; b=nkBv0Brz1RN7FapVpWhzuWM8V6GSNfbuacwqPnZBgPvFQzLZa75lk6m47VIgbdN6lP 3j9XojSuwyCJoaRiaQJy4J6BLWtCT6QZ0ql2uKvhVRe/WCPV3S/GSXJWbY1JRnMlZdME QVnvq5dh9+MJub9SdfAl4fWN7+k6qFKZa+PuxiWweYBR7Z7ChNuVqCeyLwcjJshK5FbV 43ojjzFc7roXh9fb9WSeE8Y3aR3aH3AEtpOafLFMhdFhN7pV6Mcqe3GxOt/4yaTHpWjy KOn9MPDvpgfk1PaAgYjS9fZh1tnf+cs1drywL6qyCWcZ1wLcCix9oelOU5U/RsfVCfVe sNIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696420847; x=1697025647; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f0GICmTJrrPt/1QlpCchvnQWSMZXbQVxu/WDlIYHaUw=; b=Kkj09+6xuKK2a8F06JWSEQ/9Q9TozhM5tGv3KPLtLqH55jK7zhp1tCu1bWzBagV9NW fPelRoveaD2JLdqEln9iIDe0H1MCHtyj9uQ39oVkc59FUdDyWNm7RFK5xV/QJ5pZu3Yl 7rm8NS9v/h1eiHJS33y3dxWFepB3J1lzdFJHCJo0OQEZ7fj583v3TfWkkqNZEqeTDfWm o29J34QOr6soqx5Gmfmvr0hoHPoRmLg8P6Omr7HUMCgMh+3ppWD7d6nhVSlFPtLIt/SG 7IuaFNzl1Y1ccva5XccvMORY1+hjHov97QTbQmTw9Ucm6r6V+HBq916SU91VnE+DqrgE VTkQ== X-Gm-Message-State: AOJu0YwiOZVvAxmk0Y5OAhjlBL2AzVvRm7nUXyhnKm6Zdpq19cc3H3Fc sumE3oWBWn6CJ97M7MaReNcNEtOiCd9rbGPha1U= X-Received: by 2002:a5d:504e:0:b0:320:bbb:5ab1 with SMTP id h14-20020a5d504e000000b003200bbb5ab1mr1955791wrt.14.1696420846661; Wed, 04 Oct 2023 05:00:46 -0700 (PDT) Received: from m1x-phil.lan (5ep85-h01-176-173-163-52.dslam.bbox.fr. [176.173.163.52]) by smtp.gmail.com with ESMTPSA id q4-20020a5d5744000000b003231a0ca5ebsm3817200wrw.49.2023.10.04.05.00.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 04 Oct 2023 05:00:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Markus Armbruster , Thomas Huth , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Paolo Bonzini Subject: [PATCH v3 04/16] os-posix: Clean up global variable shadowing Date: Wed, 4 Oct 2023 14:00:07 +0200 Message-ID: <20231004120019.93101-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231004120019.93101-1-philmd@linaro.org> References: <20231004120019.93101-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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 Fix: os-posix.c:103:31: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] bool os_set_runas(const char *optarg) ^ os-posix.c:176:32: error: declaration shadows a variable in the global scope [-Werror,-Wshadow] void os_set_chroot(const 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é Reviewed-by: Eric Blake --- include/sysemu/os-posix.h | 4 ++-- os-posix.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/sysemu/os-posix.h b/include/sysemu/os-posix.h index 6dfdcbb086..dff32ae185 100644 --- a/include/sysemu/os-posix.h +++ b/include/sysemu/os-posix.h @@ -49,8 +49,8 @@ void os_setup_signal_handling(void); int os_set_daemonize(bool d); bool is_daemonized(void); void os_daemonize(void); -bool os_set_runas(const char *optarg); -void os_set_chroot(const char *optarg); +bool os_set_runas(const char *user_id); +void os_set_chroot(const char *path); void os_setup_post(void); int os_mlock(void); diff --git a/os-posix.c b/os-posix.c index f90dfda9b0..52ef6990ff 100644 --- a/os-posix.c +++ b/os-posix.c @@ -94,13 +94,13 @@ static uid_t user_uid = (uid_t)-1; /* -1 -1 >=0 */ static gid_t user_gid = (gid_t)-1; /* -1 -1 >=0 */ /* - * Prepare to change user ID. optarg can be one of 3 forms: + * Prepare to change user ID. user_id can be one of 3 forms: * - a username, in which case user ID will be changed to its uid, * with primary and supplementary groups set up too; * - a numeric uid, in which case only the uid will be set; * - a pair of numeric uid:gid. */ -bool os_set_runas(const char *optarg) +bool os_set_runas(const char *user_id) { unsigned long lv; const char *ep; @@ -108,14 +108,14 @@ bool os_set_runas(const char *optarg) gid_t got_gid; int rc; - user_pwd = getpwnam(optarg); + user_pwd = getpwnam(user_id); if (user_pwd) { user_uid = -1; user_gid = -1; return true; } - rc = qemu_strtoul(optarg, &ep, 0, &lv); + rc = qemu_strtoul(user_id, &ep, 0, &lv); got_uid = lv; /* overflow here is ID in C99 */ if (rc || *ep != ':' || got_uid != lv || got_uid == (uid_t)-1) { return false; @@ -173,9 +173,9 @@ static void change_process_uid(void) static const char *chroot_dir; -void os_set_chroot(const char *optarg) +void os_set_chroot(const char *path) { - chroot_dir = optarg; + chroot_dir = path; } static void change_root(void)