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>
This commit is contained in:
Guy Harris 2018-09-09 20:00:42 -07:00
parent a93698a4ff
commit aa0c067529
1 changed files with 6 additions and 2 deletions

View File

@ -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.