Skip to content

Commit

Permalink
utils_base.c: Fix unused value and parentheses warnings
Browse files Browse the repository at this point in the history
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)) {
                        ^
                        ==
  • Loading branch information
mjtrangoni committed Jun 24, 2018
1 parent 227cf4c commit 743f27b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/utils_base.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down

0 comments on commit 743f27b

Please sign in to comment.