Try to squelch the warning about not using the return value of strtoul()

- we really *are* using it just for its side-effects if it fails; its
return value is not the best way to check for failure, as the failure
return values are also valid return values on success.

While we're at it, check for it setting errno, which is one of the
better ways to check for failure.

svn path=/trunk/; revision=37606
This commit is contained in:
Guy Harris 2011-06-08 04:07:15 +00:00
parent e25095dfe5
commit a3714500fd
1 changed files with 4 additions and 2 deletions

View File

@ -926,14 +926,16 @@ pref_check(pref_t *pref, gpointer user_data)
const char *str_val;
char *p;
pref_t **badpref = user_data;
unsigned long val;
/* Fetch the value of the preference, and check whether it's valid. */
switch (pref->type) {
case PREF_UINT:
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
strtoul(str_val, &p, pref->info.base);
if (p == str_val || *p != '\0') {
errno = 0;
(void) strtoul(str_val, &p, pref->info.base);
if (p == str_val || *p != '\0' || errno != 0) {
*badpref = pref;
return PREFS_SET_SYNTAX_ERR; /* number was bad */
}