Always perform == or != operation on cmp function result

Although not required to address bad code generation in
some versions of gcc 9 and 10, a coding style that requires
explicit comparison of the result to zero before use is
both clearer and would have avoided the generation of bad
code.

This change converts all use of cmp function usage from

```
    if (strcmp(a, b) || !strcmp(c, d)) ...
```

to

```
    if (strcmp(a, b) != 0 || strcmp(c, d)) == 0
```

for all C library cmp functions and related:

 - strcmp(), strncmp()
 - strcasecmp(), strncasecmp()
 - stricmp(), strnicmp()
 - memcmp()

Change-Id: Ic60c15e1e3a07e4faaf10648eefe3adae2543188
This commit is contained in:
Nicolas Williams
2021-11-14 23:52:50 -06:00
committed by Jeffrey Altman
parent 02200d55ea
commit 5f63215d0d
46 changed files with 119 additions and 116 deletions

View File

@@ -272,7 +272,7 @@ read_token(gss_buffer_t in, int negotiate)
tmp = inbuf;
if (negotiate) {
if (strncasecmp("Negotiate ", inbuf, 10)) {
if (strncasecmp("Negotiate ", inbuf, 10) != 0) {
fprintf(stderr, "Token doesn't begin with "
"\"Negotiate \"\n");
ret = -1;