[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/32] os-posix: Clean up global variable shadowing
From: |
Markus Armbruster |
Subject: |
[PULL 13/32] os-posix: Clean up global variable shadowing |
Date: |
Fri, 6 Oct 2023 13:36:38 +0200 |
From: Philippe Mathieu-Daudé <philmd@linaro.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é <philmd@linaro.org>
Message-ID: <20231004120019.93101-5-philmd@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
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)
--
2.41.0
- [PULL 27/32] hw/usb: Silence compiler warnings in USB code when compiling with -Wshadow, (continued)
- [PULL 27/32] hw/usb: Silence compiler warnings in USB code when compiling with -Wshadow, Markus Armbruster, 2023/10/06
- [PULL 26/32] target/ppc: Clean up local variable shadowing in kvm_arch_*_registers(), Markus Armbruster, 2023/10/06
- [PULL 06/32] hw/net/vhost_net: Silence compiler warning when compiling with -Wshadow, Markus Armbruster, 2023/10/06
- [PULL 21/32] util/guest-random: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 09/32] dump: Silence compiler warning in dump code when compiling with -Wshadow, Markus Armbruster, 2023/10/06
- [PULL 05/32] audio/ossaudio: Fix compiler warning with -Wshadow, Markus Armbruster, 2023/10/06
- [PULL 01/32] hw/cxl: Fix local variable shadowing of cap_hdrs, Markus Armbruster, 2023/10/06
- [PULL 07/32] hw/virtio/virtio-pci: Avoid compiler warning with -Wshadow, Markus Armbruster, 2023/10/06
- [PULL 31/32] linux-user/syscall.c: clean up local variable shadowing in TARGET_NR_getcpu, Markus Armbruster, 2023/10/06
- [PULL 18/32] semihosting: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 13/32] os-posix: Clean up global variable shadowing,
Markus Armbruster <=
- [PULL 32/32] linux-user/syscall.c: clean up local variable shadowing in xattr syscalls, Markus Armbruster, 2023/10/06
- [PULL 29/32] linux-user/mmap.c: clean up local variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 12/32] net/net: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 14/32] plugins/loader: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 16/32] qemu-io: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 03/32] target/ppc: Rename variables to avoid local variable shadowing in VUPKPX, Markus Armbruster, 2023/10/06
- [PULL 19/32] ui/cocoa: Clean up global variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 22/32] semihosting/arm-compat: Clean up local variable shadowing, Markus Armbruster, 2023/10/06
- [PULL 20/32] util/cutils: Clean up global variable shadowing in get_relocated_path(), Markus Armbruster, 2023/10/06
- [PULL 25/32] trace/control: Clean up global variable shadowing, Markus Armbruster, 2023/10/06