]> granicus.if.org Git - nethack/commitdiff
remove unnecessary null-check on wc_set_window_colors()
authorSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 8 Feb 2022 19:57:37 +0000 (04:57 +0900)
committerPatR <rankin@nethack.org>
Sun, 24 Apr 2022 07:08:52 +0000 (00:08 -0700)
mungspaces() returns its argument itself, so `newop` is assigned to `buf`, and always non-null.
`tfg` and `tbg` is assigned to (some addition of) `newop`, so these are also always non-null.

src/options.c

index ec21d574565f67b4075fd82352dc465944c75d8c..2a65d11107b1715b03c3dccb0e56536e78582d10 100644 (file)
@@ -8702,7 +8702,7 @@ wc_set_window_colors(char *op)
 
     Strcpy(buf, op);
     newop = mungspaces(buf);
-    while (newop && *newop) {
+    while (*newop) {
         wn = tfg = tbg = (char *) 0;
 
         /* until first non-space in case there's leading spaces - before
@@ -8757,12 +8757,12 @@ wc_set_window_colors(char *op)
 
         for (j = 0; j < 4; ++j) {
             if (!strcmpi(wn, wnames[j]) || !strcmpi(wn, shortnames[j])) {
-                if (tfg && !strstri(tfg, " ")) {
+                if (!strstri(tfg, " ")) {
                     if (*fgp[j])
                         free((genericptr_t) *fgp[j]);
                     *fgp[j] = dupstr(tfg);
                 }
-                if (tbg && !strstri(tbg, " ")) {
+                if (!strstri(tbg, " ")) {
                     if (*bgp[j])
                         free((genericptr_t) *bgp[j]);
                     *bgp[j] = dupstr(tbg);