aboutsummaryrefslogtreecommitdiffstats
path: root/gtk/prefs_dlg.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2011-06-10 02:10:44 +0000
committerBill Meier <wmeier@newsguy.com>2011-06-10 02:10:44 +0000
commitd2629a533595f67e6ca50f12873daec20b9a09f0 (patch)
treef40fcacb8213c37b4eff4162c4aa896b2f7feade /gtk/prefs_dlg.c
parent61eacf0d54cf39613be7b46bda840b6f1e1a7e00 (diff)
Add a hack to prevent a gcc warning "ignoring return value of 'strtoul'..."
for some gcc configurations (see _FORTIFY_SOURCE). This hack is used instead of storing the result returned by strtoul() in a dummy variable so as to prevent a gcc 4.6 with -Wextra warning: "set but not used ...". TBD: will this hack pass muster with other validators such as Coverity, CLang, & etc ? For much gory detail: see the message thread starting at: http://www.wireshark.org/lists/wireshark-dev/201106/msg00088.html svn path=/trunk/; revision=37642
Diffstat (limited to 'gtk/prefs_dlg.c')
-rw-r--r--gtk/prefs_dlg.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/gtk/prefs_dlg.c b/gtk/prefs_dlg.c
index 3864716267..6425697c19 100644
--- a/gtk/prefs_dlg.c
+++ b/gtk/prefs_dlg.c
@@ -926,7 +926,6 @@ 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) {
@@ -934,7 +933,21 @@ pref_check(pref_t *pref, gpointer user_data)
case PREF_UINT:
str_val = gtk_entry_get_text(GTK_ENTRY(pref->control));
errno = 0;
- val = strtoul(str_val, &p, pref->info.base);
+
+ /* XXX: The following ugly hack prevents a gcc warning
+ "ignoring return value of 'strtoul', declared with attribute warn_unused_result"
+ which can occur when using certain gcc configurations (see _FORTIFY_SOURCE).
+ A dummy variable is not used because when using gcc 4.6 with -Wextra a
+ "set but not used [-Wunused-but-set-variable]" warning will occur.
+ TBD: will this hack pass muster with other validators such as Coverity, CLang, & etc
+
+ [Guy Harris comment:
+ "... perhaps either using spin buttons for numeric preferences, or otherwise making
+ it impossible to type something that's not a number into the GUI for those preferences,
+ and thus avoiding the need to check whether it's a valid number, would also be a good idea."
+ ]
+ */
+ if(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 */