mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Remove useless empty string initializations
This coding style probably stems from the days of shell scripts. Reviewed-by: Aleksandr Parfenov <a.parfenov@postgrespro.ru>
This commit is contained in:
parent
9361bc347c
commit
8e67380126
@ -118,29 +118,29 @@ static const char *const auth_methods_local[] = {
|
|||||||
static char *share_path = NULL;
|
static char *share_path = NULL;
|
||||||
|
|
||||||
/* values to be obtained from arguments */
|
/* values to be obtained from arguments */
|
||||||
static char *pg_data = "";
|
static char *pg_data = NULL;
|
||||||
static char *encoding = "";
|
static char *encoding = NULL;
|
||||||
static char *locale = "";
|
static char *locale = NULL;
|
||||||
static char *lc_collate = "";
|
static char *lc_collate = NULL;
|
||||||
static char *lc_ctype = "";
|
static char *lc_ctype = NULL;
|
||||||
static char *lc_monetary = "";
|
static char *lc_monetary = NULL;
|
||||||
static char *lc_numeric = "";
|
static char *lc_numeric = NULL;
|
||||||
static char *lc_time = "";
|
static char *lc_time = NULL;
|
||||||
static char *lc_messages = "";
|
static char *lc_messages = NULL;
|
||||||
static const char *default_text_search_config = "";
|
static const char *default_text_search_config = NULL;
|
||||||
static char *username = "";
|
static char *username = NULL;
|
||||||
static bool pwprompt = false;
|
static bool pwprompt = false;
|
||||||
static char *pwfilename = NULL;
|
static char *pwfilename = NULL;
|
||||||
static char *superuser_password = NULL;
|
static char *superuser_password = NULL;
|
||||||
static const char *authmethodhost = "";
|
static const char *authmethodhost = NULL;
|
||||||
static const char *authmethodlocal = "";
|
static const char *authmethodlocal = NULL;
|
||||||
static bool debug = false;
|
static bool debug = false;
|
||||||
static bool noclean = false;
|
static bool noclean = false;
|
||||||
static bool do_sync = true;
|
static bool do_sync = true;
|
||||||
static bool sync_only = false;
|
static bool sync_only = false;
|
||||||
static bool show_setting = false;
|
static bool show_setting = false;
|
||||||
static bool data_checksums = false;
|
static bool data_checksums = false;
|
||||||
static char *xlog_dir = "";
|
static char *xlog_dir = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* internal vars */
|
/* internal vars */
|
||||||
@ -1285,7 +1285,6 @@ bootstrap_template1(void)
|
|||||||
{
|
{
|
||||||
PG_CMD_DECL;
|
PG_CMD_DECL;
|
||||||
char **line;
|
char **line;
|
||||||
char *talkargs = "";
|
|
||||||
char **bki_lines;
|
char **bki_lines;
|
||||||
char headerline[MAXPGPATH];
|
char headerline[MAXPGPATH];
|
||||||
char buf[64];
|
char buf[64];
|
||||||
@ -1293,9 +1292,6 @@ bootstrap_template1(void)
|
|||||||
printf(_("running bootstrap script ... "));
|
printf(_("running bootstrap script ... "));
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
if (debug)
|
|
||||||
talkargs = "-d 5";
|
|
||||||
|
|
||||||
bki_lines = readfile(bki_file);
|
bki_lines = readfile(bki_file);
|
||||||
|
|
||||||
/* Check that bki file appears to be of the right version */
|
/* Check that bki file appears to be of the right version */
|
||||||
@ -1359,7 +1355,9 @@ bootstrap_template1(void)
|
|||||||
"\"%s\" --boot -x1 %s %s %s",
|
"\"%s\" --boot -x1 %s %s %s",
|
||||||
backend_exec,
|
backend_exec,
|
||||||
data_checksums ? "-k" : "",
|
data_checksums ? "-k" : "",
|
||||||
boot_options, talkargs);
|
boot_options,
|
||||||
|
debug ? "-d 5" : "");
|
||||||
|
|
||||||
|
|
||||||
PG_CMD_OPEN;
|
PG_CMD_OPEN;
|
||||||
|
|
||||||
@ -2136,6 +2134,10 @@ check_locale_name(int category, const char *locale, char **canonname)
|
|||||||
/* save may be pointing at a modifiable scratch variable, so copy it. */
|
/* save may be pointing at a modifiable scratch variable, so copy it. */
|
||||||
save = pg_strdup(save);
|
save = pg_strdup(save);
|
||||||
|
|
||||||
|
/* for setlocale() call */
|
||||||
|
if (!locale)
|
||||||
|
locale = "";
|
||||||
|
|
||||||
/* set the locale with setlocale, to see if it accepts it. */
|
/* set the locale with setlocale, to see if it accepts it. */
|
||||||
res = setlocale(category, locale);
|
res = setlocale(category, locale);
|
||||||
|
|
||||||
@ -2223,19 +2225,19 @@ setlocales(void)
|
|||||||
|
|
||||||
/* set empty lc_* values to locale config if set */
|
/* set empty lc_* values to locale config if set */
|
||||||
|
|
||||||
if (strlen(locale) > 0)
|
if (locale)
|
||||||
{
|
{
|
||||||
if (strlen(lc_ctype) == 0)
|
if (!lc_ctype)
|
||||||
lc_ctype = locale;
|
lc_ctype = locale;
|
||||||
if (strlen(lc_collate) == 0)
|
if (!lc_collate)
|
||||||
lc_collate = locale;
|
lc_collate = locale;
|
||||||
if (strlen(lc_numeric) == 0)
|
if (!lc_numeric)
|
||||||
lc_numeric = locale;
|
lc_numeric = locale;
|
||||||
if (strlen(lc_time) == 0)
|
if (!lc_time)
|
||||||
lc_time = locale;
|
lc_time = locale;
|
||||||
if (strlen(lc_monetary) == 0)
|
if (!lc_monetary)
|
||||||
lc_monetary = locale;
|
lc_monetary = locale;
|
||||||
if (strlen(lc_messages) == 0)
|
if (!lc_messages)
|
||||||
lc_messages = locale;
|
lc_messages = locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2310,7 +2312,7 @@ usage(const char *progname)
|
|||||||
static void
|
static void
|
||||||
check_authmethod_unspecified(const char **authmethod)
|
check_authmethod_unspecified(const char **authmethod)
|
||||||
{
|
{
|
||||||
if (*authmethod == NULL || strlen(*authmethod) == 0)
|
if (*authmethod == NULL)
|
||||||
{
|
{
|
||||||
authwarning = _("\nWARNING: enabling \"trust\" authentication for local connections\n"
|
authwarning = _("\nWARNING: enabling \"trust\" authentication for local connections\n"
|
||||||
"You can change this by editing pg_hba.conf or using the option -A, or\n"
|
"You can change this by editing pg_hba.conf or using the option -A, or\n"
|
||||||
@ -2367,7 +2369,7 @@ setup_pgdata(void)
|
|||||||
char *pgdata_get_env,
|
char *pgdata_get_env,
|
||||||
*pgdata_set_env;
|
*pgdata_set_env;
|
||||||
|
|
||||||
if (strlen(pg_data) == 0)
|
if (!pg_data)
|
||||||
{
|
{
|
||||||
pgdata_get_env = getenv("PGDATA");
|
pgdata_get_env = getenv("PGDATA");
|
||||||
if (pgdata_get_env && strlen(pgdata_get_env))
|
if (pgdata_get_env && strlen(pgdata_get_env))
|
||||||
@ -2479,7 +2481,7 @@ setup_locale_encoding(void)
|
|||||||
lc_time);
|
lc_time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen(encoding) == 0)
|
if (!encoding)
|
||||||
{
|
{
|
||||||
int ctype_enc;
|
int ctype_enc;
|
||||||
|
|
||||||
@ -2589,10 +2591,10 @@ setup_data_file_paths(void)
|
|||||||
void
|
void
|
||||||
setup_text_search(void)
|
setup_text_search(void)
|
||||||
{
|
{
|
||||||
if (strlen(default_text_search_config) == 0)
|
if (!default_text_search_config)
|
||||||
{
|
{
|
||||||
default_text_search_config = find_matching_ts_config(lc_ctype);
|
default_text_search_config = find_matching_ts_config(lc_ctype);
|
||||||
if (default_text_search_config == NULL)
|
if (!default_text_search_config)
|
||||||
{
|
{
|
||||||
printf(_("%s: could not find suitable text search configuration for locale \"%s\"\n"),
|
printf(_("%s: could not find suitable text search configuration for locale \"%s\"\n"),
|
||||||
progname, lc_ctype);
|
progname, lc_ctype);
|
||||||
@ -2728,7 +2730,7 @@ create_xlog_or_symlink(void)
|
|||||||
/* form name of the place for the subdirectory or symlink */
|
/* form name of the place for the subdirectory or symlink */
|
||||||
subdirloc = psprintf("%s/pg_wal", pg_data);
|
subdirloc = psprintf("%s/pg_wal", pg_data);
|
||||||
|
|
||||||
if (strcmp(xlog_dir, "") != 0)
|
if (xlog_dir)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -3131,7 +3133,7 @@ main(int argc, char *argv[])
|
|||||||
* Non-option argument specifies data directory as long as it wasn't
|
* Non-option argument specifies data directory as long as it wasn't
|
||||||
* already specified with -D / --pgdata
|
* already specified with -D / --pgdata
|
||||||
*/
|
*/
|
||||||
if (optind < argc && strlen(pg_data) == 0)
|
if (optind < argc && !pg_data)
|
||||||
{
|
{
|
||||||
pg_data = pg_strdup(argv[optind]);
|
pg_data = pg_strdup(argv[optind]);
|
||||||
optind++;
|
optind++;
|
||||||
@ -3187,7 +3189,7 @@ main(int argc, char *argv[])
|
|||||||
setup_bin_paths(argv[0]);
|
setup_bin_paths(argv[0]);
|
||||||
|
|
||||||
effective_user = get_id();
|
effective_user = get_id();
|
||||||
if (strlen(username) == 0)
|
if (!username)
|
||||||
username = effective_user;
|
username = effective_user;
|
||||||
|
|
||||||
if (strncmp(username, "pg_", 3) == 0)
|
if (strncmp(username, "pg_", 3) == 0)
|
||||||
|
@ -76,7 +76,7 @@ typedef enum
|
|||||||
/* Global options */
|
/* Global options */
|
||||||
static char *basedir = NULL;
|
static char *basedir = NULL;
|
||||||
static TablespaceList tablespace_dirs = {NULL, NULL};
|
static TablespaceList tablespace_dirs = {NULL, NULL};
|
||||||
static char *xlog_dir = "";
|
static char *xlog_dir = NULL;
|
||||||
static char format = 'p'; /* p(lain)/t(ar) */
|
static char format = 'p'; /* p(lain)/t(ar) */
|
||||||
static char *label = "pg_basebackup base backup";
|
static char *label = "pg_basebackup base backup";
|
||||||
static bool noclean = false;
|
static bool noclean = false;
|
||||||
@ -2347,7 +2347,7 @@ main(int argc, char **argv)
|
|||||||
temp_replication_slot = false;
|
temp_replication_slot = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strcmp(xlog_dir, "") != 0)
|
if (xlog_dir)
|
||||||
{
|
{
|
||||||
if (format != 'p')
|
if (format != 'p')
|
||||||
{
|
{
|
||||||
@ -2398,7 +2398,7 @@ main(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create pg_wal symlink, if required */
|
/* Create pg_wal symlink, if required */
|
||||||
if (strcmp(xlog_dir, "") != 0)
|
if (xlog_dir)
|
||||||
{
|
{
|
||||||
char *linkloc;
|
char *linkloc;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user