The new string conversion wrappers detect and flag errors
which occured during the string to integer conversion.
Those modifications required an update of the callees
error checks.
Signed-off-by: Swen Schillig <swen@linux.ibm.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Christof Schmitt <cs@samba.org>
int error = 0;
val = strtoul_err(str, &endptr, 10, &error);
-
- if (str == endptr) {
- return false;
- }
- if (*endptr != '\0') {
- return false;
- }
- if (error != 0) {
+ if (error != 0 || *endptr != '\0') {
return false;
}
+
*result = val; /* Potential crop */
return true;
}
else {
value = strtoul_err(argv[1], &endptr, 10, &err);
- if ((endptr == argv[1]) || (endptr[0] != '\0') || (err != 0)) {
+ if (err != 0 || *endptr != '\0') {
d_printf(_("Unable to set policy \"%s\"! Invalid value "
"\"%s\".\n"),
account_policy, argv[1]);
uint32_t num;
num = strtoul_err(kickoff_time, &endptr, 10, &error);
- if ((endptr == kickoff_time) ||
- (endptr[0] != '\0') ||
- (error != 0))
- {
+ if (error != 0 || *endptr != '\0') {
fprintf(stderr, "Failed to parse kickoff time\n");
return -1;
}
bool dialog_section_text_field_get_uint(struct dialog_section *section,
unsigned long long *out)
{
- bool rv;
const char *buf;
char *endp;
int error = 0;
return false;
}
*out = strtoull_err(buf, &endp, 0, &error);
- rv = true;
- if (endp == buf || endp == NULL || endp[0] != '\0' || error != 0) {
- rv = false;
+ if (error != 0 || *endp != '\0') {
+ return false;
}
- return rv;
+ return true;
}
/* hex editor field */