diff options
author | Guy Harris <guy@alum.mit.edu> | 2018-09-09 20:00:42 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2018-09-10 03:01:35 +0000 |
commit | aa0c0675294a6b213feed41827a516064f6a29f2 (patch) | |
tree | 1594ea947118d53510df1238eb3c08a8d27061cc /ui/recent.c | |
parent | a93698a4ff1d2a403691a580dac5f26037047257 (diff) |
Avoid warnings about a format string being a variable.
This also avoids issues if this isn't called in packet scope.
Change-Id: I7dbf5b49c9f7c1b442a1104156b004b339076c26
Reviewed-on: https://code.wireshark.org/review/29527
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/recent.c')
-rw-r--r-- | ui/recent.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ui/recent.c b/ui/recent.c index 7a68a0d9a2..ac5773fcf2 100644 --- a/ui/recent.c +++ b/ui/recent.c @@ -586,6 +586,7 @@ write_recent_enum(FILE *rf, const char *description, const char *name, { const char *if_invalid = NULL; const value_string *valp; + const gchar *str_value; fprintf(rf, "\n# %s.\n", description); fprintf(rf, "# One of: "); @@ -599,8 +600,11 @@ write_recent_enum(FILE *rf, const char *description, const char *name, fprintf(rf, ", "); } fprintf(rf, "\n"); - fprintf(rf, "%s: %s\n", name, - val_to_str(value, values, if_invalid != NULL ? if_invalid : "Unknown")); + str_value = try_val_to_str(value, values); + if (str_value != NULL) + fprintf(rf, "%s: %s\n", name, str_value); + else + fprintf(rf, "%s: %s\n", name, if_invalid != NULL ? if_invalid : "Unknown"); } /* Attempt to write out "recent common" to the user's recent common file. |