pg_upgrade: Avoid shadowing global var in function
authorDaniel Gustafsson <dgustafsson@postgresql.org>
Wed, 23 Aug 2023 07:41:22 +0000 (09:41 +0200)
committerDaniel Gustafsson <dgustafsson@postgresql.org>
Wed, 23 Aug 2023 07:41:22 +0000 (09:41 +0200)
The new_cluster parameter in check_for_new_tablespace_dir was
shadowing the globally defined new_cluster variable, causing
compiler warnings when running with -Wshadow. The function is
only applicable to the new cluster, so remove the parameter
rather than rename to match check_new_cluster_is_empty which
also only applies to the new cluster.

Author: Peter Smith <peter.b.smith@fujitsu.com>
Discussion: https://postgr.es/m/CAHut+PvS_PHLntWy1yTgXv0O1tWm4iVcKBQFzpoQRDsm2Ce_Fg@mail.gmail.com

src/bin/pg_upgrade/check.c

index 64024e3b9ec00eda5093399e5fdf92a2d30f89fa..65ced1289e0cc6e2e49f5d87488f02d9511c61c8 100644 (file)
@@ -28,7 +28,7 @@ static void check_for_reg_data_type_usage(ClusterInfo *cluster);
 static void check_for_aclitem_data_type_usage(ClusterInfo *cluster);
 static void check_for_jsonb_9_4_usage(ClusterInfo *cluster);
 static void check_for_pg_role_prefix(ClusterInfo *cluster);
-static void check_for_new_tablespace_dir(ClusterInfo *new_cluster);
+static void check_for_new_tablespace_dir(void);
 static void check_for_user_defined_encoding_conversions(ClusterInfo *cluster);
 
 
@@ -209,7 +209,7 @@ check_new_cluster(void)
 
    check_for_prepared_transactions(&new_cluster);
 
-   check_for_new_tablespace_dir(&new_cluster);
+   check_for_new_tablespace_dir();
 }
 
 
@@ -377,7 +377,7 @@ check_new_cluster_is_empty(void)
  * during schema restore.
  */
 static void
-check_for_new_tablespace_dir(ClusterInfo *new_cluster)
+check_for_new_tablespace_dir(void)
 {
    int         tblnum;
    char        new_tablespace_dir[MAXPGPATH];
@@ -390,7 +390,7 @@ check_for_new_tablespace_dir(ClusterInfo *new_cluster)
 
        snprintf(new_tablespace_dir, MAXPGPATH, "%s%s",
                 os_info.old_tablespaces[tblnum],
-                new_cluster->tablespace_suffix);
+                new_cluster.tablespace_suffix);
 
        if (stat(new_tablespace_dir, &statbuf) == 0 || errno != ENOENT)
            pg_fatal("new cluster tablespace directory already exists: \"%s\"",