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 <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2018-02-07 14:20:12 -08:00
parent 62fc862bc6
commit 600b84f4c1
1 changed files with 10 additions and 3 deletions

View File

@ -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);