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:

committed by
Jeffrey Altman

parent
02200d55ea
commit
5f63215d0d
@@ -990,7 +990,7 @@ get_open_type_defn_fields(const Type *t,
|
||||
}
|
||||
/* Look for the type ID member identified in the previous loop */
|
||||
HEIM_TAILQ_FOREACH(m, t->members, members) {
|
||||
if (!m->type->subtype || strcmp(m->name, idmembername))
|
||||
if (!m->type->subtype || strcmp(m->name, idmembername) != 0)
|
||||
continue;
|
||||
if (m->type->constraint &&
|
||||
m->type->constraint->ctype == CT_TABLE_CONSTRAINT)
|
||||
@@ -1040,7 +1040,7 @@ define_open_type(int level, const char *newbasename, const char *name, const cha
|
||||
newbasename);
|
||||
for (i = 0; i < nobjs; i++) {
|
||||
HEIM_TAILQ_FOREACH(of, objects[i]->objfields, objfields) {
|
||||
if (strcmp(of->name, typeidfield->name))
|
||||
if (strcmp(of->name, typeidfield->name) != 0)
|
||||
continue;
|
||||
if (!of->value || !of->value->s)
|
||||
errx(1, "Unknown value in value field %s of object %s",
|
||||
@@ -1060,7 +1060,7 @@ define_open_type(int level, const char *newbasename, const char *name, const cha
|
||||
HEIM_TAILQ_FOREACH(of, objects[i]->objfields, objfields) {
|
||||
char *n = NULL;
|
||||
|
||||
if (strcmp(of->name, opentypefield->name))
|
||||
if (strcmp(of->name, opentypefield->name) != 0)
|
||||
continue;
|
||||
if (!of->type || (!of->type->symbol && of->type->type != TTag) ||
|
||||
of->type->tag.tagclass != ASN1_C_UNIV) {
|
||||
@@ -1631,7 +1631,8 @@ generate_type_header (const Symbol *s)
|
||||
t = s->type->symbol->type;
|
||||
}
|
||||
|
||||
if (t->type == TType && t->symbol && strcmp(t->symbol->name, "HEIM_ANY")) {
|
||||
if (t->type == TType && t->symbol &&
|
||||
strcmp(t->symbol->name, "HEIM_ANY") != 0) {
|
||||
/*
|
||||
* This type is ultimately an alias of an imported type, so we don't
|
||||
* know its outermost tag here.
|
||||
|
Reference in New Issue
Block a user