[klibc] [PATCH v1 1/3] dash: shell: Fix clang warnings

Bill Wendling morbo at google.com
Mon Nov 9 14:13:34 PST 2020


A couple of warnings from clang about old-style field designators and a
logical "not" used in an unconventional way and needs parentheses.

-----------------------------------------------------------------------
usr/dash/eval.c:106:2: warning: use of GNU old-style field designator extension [-Wgnu-designator]
        name: nullstr,
        ^~~~~
        .name =
usr/dash/eval.c:107:2: warning: use of GNU old-style field designator extension [-Wgnu-designator]
        builtin: bltincmd
        ^~~~~~~~
        .builtin =
usr/dash/eval.c:277:7: warning: logical not is only applied to the left hand side of this comparison [-Wlogical-not-parentheses]
                if (!exitstatus == isor)
                    ^           ~~
usr/dash/eval.c:277:7: note: add parentheses after the '!' to evaluate the comparison first
                if (!exitstatus == isor)
                    ^
                     (                 )
usr/dash/eval.c:277:7: note: add parentheses around left hand side expression to silence this warning
                if (!exitstatus == isor)
                    ^
                    (          )
-----------------------------------------------------------------------

Signed-off-by: Bill Wendling <morbo at google.com>
---
 usr/dash/eval.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/usr/dash/eval.c b/usr/dash/eval.c
index dd144948..145e0b46 100644
--- a/usr/dash/eval.c
+++ b/usr/dash/eval.c
@@ -103,8 +103,8 @@ STATIC int bltincmd(int, char **);
 
 
 STATIC const struct builtincmd bltin = {
-	name: nullstr,
-	builtin: bltincmd
+	.name = nullstr,
+	.builtin = bltincmd
 };
 
 
@@ -274,7 +274,7 @@ checkexit:
 			n->nbinary.ch1,
 			(flags | ((isor >> 1) - 1)) & EV_TESTED
 		);
-		if (!exitstatus == isor)
+		if ((!exitstatus) == isor)
 			break;
 		if (!evalskip) {
 			n = n->nbinary.ch2;
-- 
2.29.2.222.g5d2a92d10f8-goog



More information about the klibc mailing list