use argument instead of global variable

Поиск
Список
Период
Сортировка
От Junwang Zhao
Тема use argument instead of global variable
Дата
Msg-id CAEG8a3+ACNH3-iKi388O4_MtWM3fKiMXGhpHj-Ak1pcLZf1jKg@mail.gmail.com
обсуждение исходный текст
Список 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 по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: SQL/JSON features for v15
Следующее
От: Tom Lane
Дата:
Сообщение: Re: moving basebackup code to its own directory