use argument instead of global variable - Mailing list pgsql-hackers

From Junwang Zhao
Subject use argument instead of global variable
Date
Msg-id CAEG8a3+ACNH3-iKi388O4_MtWM3fKiMXGhpHj-Ak1pcLZf1jKg@mail.gmail.com
Whole thread Raw
List pgsql-hackers
The caller of `get_stats_option_name` pass optarg as the argument,
it's saner to use the argument instead of the global variable set
by getopt, which is more safe since the argument has a *const*
specifier.

diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c
index 11e802eba9..68552b8779 100644
--- a/src/backend/tcop/postgres.c
+++ b/src/backend/tcop/postgres.c
@@ -3598,9 +3598,9 @@ get_stats_option_name(const char *arg)
        switch (arg[0])
        {
                case 'p':
-                       if (optarg[1] == 'a')   /* "parser" */
+                       if (arg[1] == 'a')      /* "parser" */
                                return "log_parser_stats";
-                       else if (optarg[1] == 'l')      /* "planner"
*/
+                       else if (arg[1] == 'l') /* "planner" */
                                return "log_planner_stats";
                        break;

-- 
Regards
Junwang Zhao



pgsql-hackers by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: SQL/JSON features for v15
Next
From: Tom Lane
Date:
Subject: Re: moving basebackup code to its own directory