Removed some more "statement not reached" warnings.
[obnox/wireshark/wip.git] / epan / filesystem.c
index 13995f2aed2c8e836b3173f413c4ae106e01f7ab..86c37b5f0558aae2fb6c2f42bdaec25f270d2de3 100644 (file)
@@ -386,10 +386,7 @@ init_progfile_dir(const char *arg0
                        return g_strdup_printf("getcwd failed: %s\n",
                            strerror(errno));
                }
-               path = g_malloc(strlen(curdir) + 1 + strlen(arg0) + 1);
-               strcpy(path, curdir);
-               strcat(path, "/");
-               strcat(path, arg0);
+               path = g_strdup_printf("%s/%s", curdir, arg0);
                g_free(curdir);
                prog_pathname = path;
        } else {
@@ -411,8 +408,8 @@ init_progfile_dir(const char *arg0
                                    + strlen(arg0) + 1);
                                memcpy(path, path_start, path_component_len);
                                path[path_component_len] = '\0';
-                               strcat(path, "/");
-                               strcat(path, arg0);
+                               strncat(path, "/", 2);
+                               strncat(path, arg0, strlen(arg0) + 1);
                                if (access(path, X_OK) == 0) {
                                        /*
                                         * Found it!
@@ -793,7 +790,8 @@ set_profile_name(const gchar *profilename)
                g_free (persconfprofile);
        }
 
-       if (profilename && strlen(profilename) > 0) {
+       if (profilename && strlen(profilename) > 0 && 
+           strcmp(profilename, DEFAULT_PROFILE) != 0) {
                persconfprofile = g_strdup (profilename);
        } else {
                /* Default Profile */
@@ -929,9 +927,10 @@ get_persconffile_dir(const gchar *profilename)
                g_free (persconffile_profile_dir);
        }
 
-       if (profilename) {
-         persconffile_profile_dir = g_strdup_printf ("%s%s%s", get_profiles_dir (), G_DIR_SEPARATOR_S,
-                                                     profilename);
+       if (profilename && strlen(profilename) > 0 &&
+           strcmp(profilename, DEFAULT_PROFILE) != 0) {
+         persconffile_profile_dir = g_strdup_printf ("%s%s%s", get_profiles_dir (), 
+                                                     G_DIR_SEPARATOR_S, profilename);
        } else {
          persconffile_profile_dir = g_strdup_printf (get_persconffile_dir_no_profile ());
        }
@@ -959,7 +958,8 @@ delete_directory (const char *directory, char **pf_dir_path_return)
 
        if ((dir = eth_dir_open(directory, 0, NULL)) != NULL) {
                while ((file = eth_dir_read_name(dir)) != NULL) {
-                       filename = g_strdup_printf ("%s%s%s", directory, G_DIR_SEPARATOR_S, eth_dir_get_name(file));
+                       filename = g_strdup_printf ("%s%s%s", directory, G_DIR_SEPARATOR_S, 
+                                                   eth_dir_get_name(file));
                        if (test_for_directory(filename) != EISDIR) {
                                ret = eth_remove(filename);
 #if 0
@@ -1137,9 +1137,7 @@ get_persdatafile_dir(void)
          /* the "My Captures" sub-directory is created (if it doesn't exist)
             by u3util.exe when the U3 Wireshark is first run */
 
-         szPath = g_malloc(strlen(u3devicedocumentpath) + strlen(U3_MY_CAPTURES) + 1);
-         strcpy(szPath, u3devicedocumentpath);
-         strcat(szPath, U3_MY_CAPTURES);
+         szPath = g_strdup_printf("%s%s", u3devicedocumentpath, U3_MY_CAPTURES);
 
          persdatafile_dir = szPath;
          return szPath;
@@ -1189,10 +1187,7 @@ get_home_dir(void)
                         * This is cached, so we don't need to worry about
                         * allocating multiple ones of them.
                         */
-                       homestring =
-                           g_malloc(strlen(homedrive) + strlen(homepath) + 1);
-                       strcpy(homestring, homedrive);
-                       strcat(homestring, homepath);
+                       homestring = g_strdup_printf("%s%s", homedrive, homepath);
 
                        /*
                         * Trim off any trailing slash or backslash.