Finalize refactoring of string comparisons

Unify the comparison idioms use.
Always use `if(!strcmp())` for "if string equals"
and `if(strcmp())` for "if string is not equal".
Never use `== 0` and `!= 0` with `strcmp()`.

Minor reformatting of the code immediately surrounding the
refactored lines.

Resolves ipmitool/ipmitool#104

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
This commit is contained in:
Alexander Amelkin
2020-06-10 02:18:46 +03:00
committed by Alexander Amelkin
parent e3fc775d26
commit 956ae2b372
33 changed files with 518 additions and 502 deletions

View File

@@ -167,9 +167,8 @@ void ipmi_intf_print(struct ipmi_intf_support * intflist)
if (intflist) {
found = 0;
for (sup=intflist; sup->name; sup++) {
if (strcmp(sup->name, (*intf)->name) == 0 &&
strcmp(sup->name, (*intf)->name) == 0 &&
sup->supported == 1)
if (!strcmp(sup->name, (*intf)->name)
&& sup->supported)
found = 1;
}
if (found == 0)
@@ -211,7 +210,7 @@ struct ipmi_intf * ipmi_intf_load(char * name)
intf++)
{
i = *intf;
if (strcmp(name, i->name) == 0) {
if (!strcmp(name, i->name)) {
if (i->setup && (i->setup(i) < 0)) {
lprintf(LOG_ERR, "Unable to setup "
"interface %s", name);

View File

@@ -394,7 +394,7 @@ recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
*pp = 0;
/* was it an error? */
if (strcmp(p, "ERR ") == 0) {
if (!strcmp(p, "ERR ")) {
serial_write_line(intf, "\r\r\r\r");
sleep(1);
serial_flush(intf);

View File

@@ -133,7 +133,7 @@ scsiProbeNew(int *num_ami_devices, int *sg_nos)
}
if (sscanf(linebuf, "%s", vendor) == 1) {
if (strcmp(vendor, "AMI") == 0) {
if (!strcmp(vendor, "AMI")) {
numdevfound++;
sg_nos[numdevfound - 1] = lineno;
if (numdevfound == inplen) {
@@ -249,7 +249,7 @@ IsG2Drive(int cd_desc)
return 1;
}
if (strcmp(szSignature, "$$$AMI$$$") != 0) {
if (strcmp(szSignature, "$$$AMI$$$")) {
lprintf(LOG_ERR,
"IsG2Drive:Signature mismatch when ID command sent");
return 1;