From 600b84f4c1f35252f8d748098b838c3f4ca20d09 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 7 Feb 2018 14:20:12 -0800 Subject: Clean up the null pointer check in profile_exists(). Check only in the if (global) case, and note that it's necessary in that case; in the !global case, note why we don't have to check for a null pointer. Change-Id: I80322204ec94eb3901f7bceabccb29351794adc8 Reviewed-on: https://code.wireshark.org/review/25674 Reviewed-by: Guy Harris --- wsutil/filesystem.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'wsutil/filesystem.c') diff --git a/wsutil/filesystem.c b/wsutil/filesystem.c index aec82a6c2f..7a2832af36 100644 --- a/wsutil/filesystem.c +++ b/wsutil/filesystem.c @@ -1465,10 +1465,13 @@ profile_exists(const gchar *profilename, gboolean global) { gchar *path = NULL, *global_path; - if (!profilename && global) - return FALSE; - if (global) { + /* + * If we're looking up a global profile, we must have a + * profile name. + */ + if (!profilename) + return FALSE; global_path = get_global_profiles_dir(); path = g_strdup_printf ("%s%s%s", global_path, G_DIR_SEPARATOR_S, profilename); @@ -1478,6 +1481,10 @@ profile_exists(const gchar *profilename, gboolean global) return TRUE; } } else { + /* + * If we didn't supply a profile name, i.e. if profilename is + * null, get_persconffile_dir() returns the default profile. + */ path = get_persconffile_dir (profilename); if (test_for_directory (path) == EISDIR) { g_free (path); -- cgit v1.2.3