Fix incorrect return-value check for a scanf like function

pull/328/head
German Service Network 7 months ago committed by Erik Auerswald
parent 118cdc5cc6
commit 94de79153f

@ -621,7 +621,7 @@ int main(int argc, char **argv)
break; break;
case 't': case 't':
if (!sscanf(optparse_state.optarg, "%f", &opt_value_float)) if (sscanf(optparse_state.optarg, "%f", &opt_value_float) != 1)
usage(1); usage(1);
if (opt_value_float < 0) { if (opt_value_float < 0) {
usage(1); usage(1);
@ -631,12 +631,12 @@ int main(int argc, char **argv)
break; break;
case 'r': case 'r':
if (!sscanf(optparse_state.optarg, "%u", &retry)) if (sscanf(optparse_state.optarg, "%u", &retry) != 1)
usage(1); usage(1);
break; break;
case 'i': case 'i':
if (!sscanf(optparse_state.optarg, "%f", &opt_value_float)) if (sscanf(optparse_state.optarg, "%f", &opt_value_float) != 1)
usage(1); usage(1);
if (opt_value_float < 0) { if (opt_value_float < 0) {
usage(1); usage(1);
@ -645,7 +645,7 @@ int main(int argc, char **argv)
break; break;
case 'p': case 'p':
if (!sscanf(optparse_state.optarg, "%f", &opt_value_float)) if (sscanf(optparse_state.optarg, "%f", &opt_value_float) != 1)
usage(1); usage(1);
if (opt_value_float < 0) { if (opt_value_float < 0) {
usage(1); usage(1);
@ -670,7 +670,7 @@ int main(int argc, char **argv)
break; break;
case 'b': case 'b':
if (!sscanf(optparse_state.optarg, "%u", &ping_data_size)) if (sscanf(optparse_state.optarg, "%u", &ping_data_size) != 1)
usage(1); usage(1);
break; break;
@ -687,7 +687,7 @@ int main(int argc, char **argv)
case 'Q': case 'Q':
verbose_flag = 0; verbose_flag = 0;
quiet_flag = 1; quiet_flag = 1;
if (!sscanf(optparse_state.optarg, "%f", &opt_value_float)) if (sscanf(optparse_state.optarg, "%f", &opt_value_float) != 1)
usage(1); usage(1);
if (opt_value_float < 0) { if (opt_value_float < 0) {
usage(1); usage(1);
@ -865,7 +865,7 @@ int main(int argc, char **argv)
break; break;
case 'O': case 'O':
if (sscanf(optparse_state.optarg, "%i", &tos)) { if (sscanf(optparse_state.optarg, "%i", &tos) == 1) {
if (socket4 >= 0) { if (socket4 >= 0) {
if (setsockopt(socket4, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) { if (setsockopt(socket4, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))) {
perror("setting type of service octet IP_TOS"); perror("setting type of service octet IP_TOS");

Loading…
Cancel
Save