Adds use of str2NUM() functions for the most of user input parameters in

'lib/main.c'. Error messages added as well.
This commit is contained in:
Zdenek Styblik 2012-01-25 15:27:13 +00:00
parent 3423c1d92f
commit ca062647be

View File

@ -631,22 +631,46 @@ ipmi_main(int argc, char ** argv,
authtype = str2val(optarg, ipmi_authtype_session_vals); authtype = str2val(optarg, ipmi_authtype_session_vals);
break; break;
case 't': case 't':
target_addr = (uint8_t)strtol(optarg, NULL, 0); if (str2uchar(optarg, &target_addr) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-t'.");
rc = -1;
goto out_free;
}
break; break;
case 'b': case 'b':
target_channel = (uint8_t)strtol(optarg, NULL, 0); if (str2uchar(optarg, &target_channel) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-b'.");
rc = -1;
goto out_free;
}
break; break;
case 'T': case 'T':
transit_addr = (uint8_t)strtol(optarg, NULL, 0); if (str2uchar(optarg, &transit_addr) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-T'.");
rc = -1;
goto out_free;
}
break; break;
case 'B': case 'B':
transit_channel = (uint8_t)strtol(optarg, NULL, 0); if (str2uchar(optarg, &transit_channel) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-B'.");
rc = -1;
goto out_free;
}
break; break;
case 'l': case 'l':
target_lun = (uint8_t)strtol(optarg, NULL, 0); if (str2uchar(optarg, &target_lun) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-l'.");
rc = 1;
goto out_free;
}
break; break;
case 'm': case 'm':
my_addr = (uint8_t)strtol(optarg, NULL, 0); if (str2uchar(optarg, &my_addr) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-m'.");
rc = -1;
goto out_free;
}
break; break;
case 'e': case 'e':
sol_escape_char = optarg[0]; sol_escape_char = optarg[0];
@ -659,7 +683,11 @@ ipmi_main(int argc, char ** argv,
} }
break; break;
case 'z': case 'z':
my_long_packet_size = (uint8_t)strtol(optarg, NULL, 0); if (str2ushort(optarg, &my_long_packet_size) != 0) {
lprintf(LOG_ERR, "Invalid parameter given or out of range for '-z'.");
rc = -1;
goto out_free;
}
break; break;
/* Retry and Timeout */ /* Retry and Timeout */
case 'R': case 'R':