Refactor string comparisons

Clean up use of strcmp/strncmp/strncasecmp for command line arguments.
Never use anything but `strcmp()` unless absolutely neccessary.

Partialy resolves ipmitool/ipmitool#104
This commit is contained in:
Jiang Junyu
2020-02-21 13:53:38 -08:00
committed by Alexander Amelkin
parent 9d5ea21df7
commit 6e037d6bfb
34 changed files with 563 additions and 570 deletions

View File

@ -542,7 +542,7 @@ ipmi_gendev_main(struct ipmi_intf *intf, int argc, char **argv)
lprintf(LOG_ERR, "Rx gendev command: %s", argv[0]);
if (!argc
|| strncmp(argv[0], "help", 4) == 0)
|| strcmp(argv[0], "help") == 0)
{
lprintf(LOG_ERR,
"SDR Commands: list read write");
@ -552,9 +552,9 @@ ipmi_gendev_main(struct ipmi_intf *intf, int argc, char **argv)
" read <sdr name> <file> Read to file eeprom specify by Generic Device Locators");
lprintf(LOG_ERR,
" write <sdr name> <file> Write from file eeprom specify by Generic Device Locators");
} else if (strncmp(argv[0], "list", 4) == 0) {
} else if (strcmp(argv[0], "list") == 0) {
rc = ipmi_sdr_print_sdr(intf, SDR_RECORD_TYPE_GENERIC_DEVICE_LOCATOR);
} else if (strncmp(argv[0], "read", 4) == 0) {
} else if (strcmp(argv[0], "read") == 0) {
if (argc < 3)
lprintf(LOG_ERR, "usage: gendev read <gendev> <filename>");
else {
@ -580,7 +580,7 @@ ipmi_gendev_main(struct ipmi_intf *intf, int argc, char **argv)
ipmi_gendev_read_file(intf, sdr->record.genloc, argv[2]);
}
} else if (strncmp(argv[0], "write", 5) == 0) {
} else if (strcmp(argv[0], "write") == 0) {
if (argc < 3)
lprintf(LOG_ERR, "usage: gendev write <gendev> <filename>");
else {