Răsfoiți Sursa

utils_base.c: Fix unused value and parentheses warnings

See,
In file included from test_utils.c:28:
../../lib/utils_base.c:338:8: warning: expression result unused [-Wunused-value]
                for (varlist; isspace(varlist[0]); varlist++);
                     ^~~~~~~
../../lib/utils_base.c:343:9: warning: expression result unused [-Wunused-value]
                        for (varlist; isspace(varlist[0]); varlist++);
                             ^~~~~~~
../../lib/utils_base.c:349:10: warning: expression result unused
      [-Wunused-value]
                                for (varlist; isspace(varlist[0]); varlist++);
                                     ^~~~~~~
../../lib/utils_base.c:351:13: warning: using the result of an assignment as a
      condition without parentheses [-Wparentheses]
                                if (tmp = index(varlist, sep)) {
                                    ~~~~^~~~~~~~~~~~~~~~~~~~~
../../lib/utils_base.c:351:13: note: place parentheses around the assignment to
      silence this warning
                                if (tmp = index(varlist, sep)) {
                                        ^
                                    (                        )
../../lib/utils_base.c:351:13: note: use '==' to turn this assignment into an
      equality comparison
                                if (tmp = index(varlist, sep)) {
                                        ^
                                        ==
../../lib/utils_base.c:367:11: warning: using the result of an assignment as a
      condition without parentheses [-Wparentheses]
                if (tmp = index(varlist, sep)) {
                    ~~~~^~~~~~~~~~~~~~~~~~~~~
../../lib/utils_base.c:367:11: note: place parentheses around the assignment to
      silence this warning
                if (tmp = index(varlist, sep)) {
                        ^
                    (                        )
../../lib/utils_base.c:367:11: note: use '==' to turn this assignment into an
      equality comparison
                if (tmp = index(varlist, sep)) {
                        ^
                        ==
Mario Trangoni 7 ani în urmă
părinte
comite
743f27bb19
1 a modificat fișierele cu 5 adăugiri și 5 ștergeri
  1. 5 5
      lib/utils_base.c

+ 5 - 5
lib/utils_base.c

@@ -335,20 +335,20 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
 
 	while (1) {
 		/* Strip any leading space */
-		for (varlist; isspace(varlist[0]); varlist++);
+		for (; isspace(varlist[0]); varlist++);
 
 		if (!strncmp(name, varlist, strlen(name))) {
 			varlist += strlen(name);
 			/* strip trailing spaces */
-			for (varlist; isspace(varlist[0]); varlist++);
+			for (; isspace(varlist[0]); varlist++);
 
 			if (varlist[0] == '=') {
 				/* We matched the key, go past the = sign */
 				varlist++;
 				/* strip leading spaces */
-				for (varlist; isspace(varlist[0]); varlist++);
+				for (; isspace(varlist[0]); varlist++);
 
-				if (tmp = index(varlist, sep)) {
+				if ((tmp = index(varlist, sep))) {
 					/* Value is delimited by a comma */
 					if (tmp-varlist == 0) continue;
 					value = (char *)calloc(1, tmp-varlist+1);
@@ -364,7 +364,7 @@ char *np_extract_value(const char *varlist, const char *name, char sep) {
 				break;
 			}
 		}
-		if (tmp = index(varlist, sep)) {
+		if ((tmp = index(varlist, sep))) {
 			/* More keys, keep going... */
 			varlist = tmp + 1;
 		} else {