Always perform == or != operation on cmp function result
commit5f63215d0d82678233fdfb1c07f4b421f57c528b
authorNicolas Williams <nico@twosigma.com>
Mon, 15 Nov 2021 05:52:50 +0000 (14 23:52 -0600)
committerJeffrey Altman <jaltman@auristor.com>
Thu, 25 Nov 2021 03:30:44 +0000 (24 22:30 -0500)
treefbc5cda723a0789fc0b32a9de665a7f0d3f84838
parent02200d55eaf01a3a21d52eccfa7eea02f9e8df72
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
46 files changed:
appl/dceutils/k5dcecon.c
appl/kf/kf.c
kdc/bx509d.c
kdc/httpkadmind.c
kdc/krb5tgs.c
kdc/mit_dump.c
kdc/process.c
lib/asn1/asn1_print.c
lib/asn1/asn1parse.y
lib/asn1/check-der.c
lib/asn1/check-gen.c
lib/asn1/der_put.c
lib/asn1/gen.c
lib/asn1/gen_decode.c
lib/asn1/gen_template.c
lib/base/db.c
lib/base/log.c
lib/base/plugin.c
lib/base/test_base.c
lib/gssapi/gss-token.c
lib/gssapi/krb5/arcfour.c
lib/gssapi/mech/gss_compare_name.c
lib/gssapi/test_context.c
lib/gssapi/test_oid.c
lib/hdb/hdb-mdb.c
lib/hdb/test_namespace.c
lib/hx509/test_name.c
lib/kadm5/modify_s.c
lib/krb5/acl.c
lib/krb5/dcache.c
lib/krb5/fcache.c
lib/krb5/get_cred.c
lib/krb5/kx509.c
lib/krb5/pac.c
lib/krb5/recvauth.c
lib/krb5/replay.c
lib/krb5/test_expand_toks.c
lib/krb5/test_princ.c
lib/krb5/verify_krb5_conf.c
lib/roken/dirent-test.c
lib/roken/getifaddrs.c
lib/roken/setprogname.c
lib/roken/snprintf.c
lib/roken/test-detach.c
lib/roken/test-mini_inetd.c
lib/sl/slc-gram.y