mirror of
https://github.com/ipmitool/ipmitool.git
synced 2026-06-21 04:41:38 +00:00
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:
committed by
Alexander Amelkin
parent
9d5ea21df7
commit
6e037d6bfb
@@ -167,8 +167,8 @@ void ipmi_intf_print(struct ipmi_intf_support * intflist)
|
||||
if (intflist) {
|
||||
found = 0;
|
||||
for (sup=intflist; sup->name; sup++) {
|
||||
if (strncmp(sup->name, (*intf)->name, strlen(sup->name)) == 0 &&
|
||||
strncmp(sup->name, (*intf)->name, strlen((*intf)->name)) == 0 &&
|
||||
if (strcmp(sup->name, (*intf)->name) == 0 &&
|
||||
strcmp(sup->name, (*intf)->name) == 0 &&
|
||||
sup->supported == 1)
|
||||
found = 1;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ struct ipmi_intf * ipmi_intf_load(char * name)
|
||||
intf++)
|
||||
{
|
||||
i = *intf;
|
||||
if (strncmp(name, i->name, strlen(name)) == 0) {
|
||||
if (strcmp(name, i->name) == 0) {
|
||||
if (i->setup && (i->setup(i) < 0)) {
|
||||
lprintf(LOG_ERR, "Unable to setup "
|
||||
"interface %s", name);
|
||||
|
||||
@@ -394,7 +394,7 @@ recv_response(struct ipmi_intf * intf, unsigned char *data, int len)
|
||||
*pp = 0;
|
||||
|
||||
/* was it an error? */
|
||||
if (strncmp(p, "ERR ", 4) == 0) {
|
||||
if (strcmp(p, "ERR ") == 0) {
|
||||
serial_write_line(intf, "\r\r\r\r");
|
||||
sleep(1);
|
||||
serial_flush(intf);
|
||||
|
||||
@@ -133,7 +133,7 @@ scsiProbeNew(int *num_ami_devices, int *sg_nos)
|
||||
}
|
||||
|
||||
if (sscanf(linebuf, "%s", vendor) == 1) {
|
||||
if (strncmp(vendor, "AMI", strlen("AMI")) == 0) {
|
||||
if (strcmp(vendor, "AMI") == 0) {
|
||||
numdevfound++;
|
||||
sg_nos[numdevfound - 1] = lineno;
|
||||
if (numdevfound == inplen) {
|
||||
@@ -249,7 +249,7 @@ IsG2Drive(int cd_desc)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (strncmp(szSignature, "$$$AMI$$$", strlen("$$$AMI$$$")) != 0) {
|
||||
if (strcmp(szSignature, "$$$AMI$$$") != 0) {
|
||||
lprintf(LOG_ERR,
|
||||
"IsG2Drive:Signature mismatch when ID command sent");
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user