Clean-up: config: fix -Wshadow error in config_load_session
authorSimon Marchi <simon.marchi@efficios.com>
Wed, 31 Mar 2021 18:37:15 +0000 (14:37 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Tue, 13 Apr 2021 20:21:41 +0000 (16:21 -0400)
Fix:

      CC       libconfig_la-session-config.lo
    /home/simark/src/lttng-tools/src/common/config/session-config.c: In function ‘config_load_session’:
    /home/simark/src/lttng-tools/src/common/config/session-config.c:4020:9: error: declaration of ‘path’ shadows a parameter [-Werror=shadow]
     4020 |    char path[PATH_MAX];
          |         ^~~~
    /home/simark/src/lttng-tools/src/common/config/session-config.c:3999:37: note: shadowed declaration is here
     3999 | int config_load_session(const char *path, const char *session_name,
          |                         ~~~~~~~~~~~~^~~~

Change-Id: Id7d5f6fcf0e88f43dee420dfb174d9bf01aa8fbd
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/config/session-config.c

index 49c06a3531b874d734ac03659f8b09f14d1f0132..c5432c392f884b58e38c84f7a0a59ed580dfa41e 100644 (file)
@@ -4017,16 +4017,17 @@ int config_load_session(const char *path, const char *session_name,
                /* Try home path */
                home_path = utils_get_home_dir();
                if (home_path) {
-                       char path[PATH_MAX];
+                       char path_buf[PATH_MAX];
 
                        /*
                         * Try user session configuration path. Ignore error here so we can
                         * continue loading the system wide sessions.
                         */
                        if (autoload) {
-                               ret = snprintf(path, sizeof(path),
-                                               DEFAULT_SESSION_HOME_CONFIGPATH "/"
-                                               DEFAULT_SESSION_CONFIG_AUTOLOAD, home_path);
+                               ret = snprintf(path_buf, sizeof(path_buf),
+                                               DEFAULT_SESSION_HOME_CONFIGPATH
+                                               "/" DEFAULT_SESSION_CONFIG_AUTOLOAD,
+                                               home_path);
                                if (ret < 0) {
                                        PERROR("snprintf session autoload home config path");
                                        ret = -LTTNG_ERR_INVALID;
@@ -4038,19 +4039,20 @@ int config_load_session(const char *path, const char *session_name,
                                 * avoid any user session daemon to try to load kernel sessions
                                 * automatically and failing all the times.
                                 */
-                               ret = validate_path_creds(path);
+                               ret = validate_path_creds(path_buf);
                                if (ret) {
-                                       path_ptr = path;
+                                       path_ptr = path_buf;
                                }
                        } else {
-                               ret = snprintf(path, sizeof(path),
-                                               DEFAULT_SESSION_HOME_CONFIGPATH, home_path);
+                               ret = snprintf(path_buf, sizeof(path_buf),
+                                               DEFAULT_SESSION_HOME_CONFIGPATH,
+                                               home_path);
                                if (ret < 0) {
                                        PERROR("snprintf session home config path");
                                        ret = -LTTNG_ERR_INVALID;
                                        goto end;
                                }
-                               path_ptr = path;
+                               path_ptr = path_buf;
                        }
                        if (path_ptr) {
                                ret = load_session_from_path(path_ptr, session_name,
This page took 0.026964 seconds and 4 git commands to generate.