From 039d59d227f2880dbdcb6d0fd4cfeb4f09d8e238 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 6 Nov 2021 21:51:56 -0500 Subject: [PATCH] Replace various x = x declarations with QUIET macro to shut up gcc. (Note: llvm does not produce these false positive warnings, only gcc does.) --- toys/net/ifconfig.c | 2 +- toys/net/sntp.c | 2 +- toys/other/hexedit.c | 4 ++-- toys/other/switch_root.c | 2 +- toys/other/watch.c | 2 +- toys/posix/uudecode.c | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/toys/net/ifconfig.c b/toys/net/ifconfig.c index f8f1277e..e2944579 100644 --- a/toys/net/ifconfig.c +++ b/toys/net/ifconfig.c @@ -248,7 +248,7 @@ static void display_ifconfig(char *name, int always, unsigned long long val[]) for (s = str; *s; s++) { if (flags & mask) xprintf("%s ", *s); - mask = mask << 1; + mask <<= 1; } } else xprintf("[NO FLAGS] "); diff --git a/toys/net/sntp.c b/toys/net/sntp.c index 161cab46..1139b0e0 100644 --- a/toys/net/sntp.c +++ b/toys/net/sntp.c @@ -72,7 +72,7 @@ static void doublyso(unsigned long long now, struct timespec *tv) void sntp_main(void) { struct timespec tv, tv2; - unsigned long long *pktime = (void *)toybuf, now, then, before = before; + unsigned long long *pktime = (void *)toybuf, now, then, before QUIET; long long diff = 0; struct addrinfo *ai; union socksaddr sa; diff --git a/toys/other/hexedit.c b/toys/other/hexedit.c index 4124c779..5bfc598c 100644 --- a/toys/other/hexedit.c +++ b/toys/other/hexedit.c @@ -369,8 +369,8 @@ void hexedit_main(void) if (TT.pos > TT.len-1) TT.pos = TT.len-1; TT.base = TT.pos/16; draw_page(); - } else if (key==KEY_HOME) TT.pos = TT.pos & ~0xf; - else if (key==KEY_END) TT.pos = TT.pos | 0xf; + } else if (key==KEY_HOME) TT.pos &= ~0xf; + else if (key==KEY_END) TT.pos |= 0xf; else if (key==(KEY_CTRL|KEY_HOME)) TT.pos = 0; else if (key==(KEY_CTRL|KEY_END)) TT.pos = TT.len-1; } diff --git a/toys/other/switch_root.c b/toys/other/switch_root.c index eb1e2b0c..3df703dd 100644 --- a/toys/other/switch_root.c +++ b/toys/other/switch_root.c @@ -46,7 +46,7 @@ void switch_root_main(void) char *newroot = *toys.optargs, **cmdline = toys.optargs+1; struct stat st1, st2; struct statfs stfs; - int console = console; // gcc's "may be used" warnings are broken. + int console QUIET; if (getpid() != 1) error_exit("not pid 1"); diff --git a/toys/other/watch.c b/toys/other/watch.c index af650045..06559e25 100644 --- a/toys/other/watch.c +++ b/toys/other/watch.c @@ -67,7 +67,7 @@ void watch_main(void) { char *cmdv[] = {"/bin/sh", "-c", 0, 0}, *cmd, *ss; long long now, then = millitime(); - unsigned width, height, i, cmdlen, len, xx = xx, yy = yy, active = active; + unsigned width, height, i, cmdlen, len, xx QUIET, yy QUIET, active QUIET; struct pollfd pfd[2]; pid_t pid = 0; int fds[2], cc; diff --git a/toys/posix/uudecode.c b/toys/posix/uudecode.c index 4d87ce1c..43f8861e 100644 --- a/toys/posix/uudecode.c +++ b/toys/posix/uudecode.c @@ -27,7 +27,7 @@ GLOBALS( void uudecode_main(void) { FILE *ifp = stdin; - int ofd, idx = 0, m = m, n; + int ofd, idx = 0, m QUIET, n; size_t allocated_length; char *line = 0, mode[16], *class[] = {"begin%*[ ]%15s%*[ ]%n", "begin-base64%*[ ]%15s%*[ ]%n"}; -- 2.39.2