Check function return values in modify_auto_conf()

This commit is contained in:
Ian Barwick
2020-04-27 14:26:04 +09:00
parent d0c5dffe91
commit 11e1b7a2c5

View File

@@ -1843,10 +1843,17 @@ modify_auto_conf(const char *data_dir, KeyValueList *items)
return false; return false;
} }
// XXX check return value success = ProcessPostgresConfigFile(fp, auto_conf.data, &config, NULL, NULL);
(void) ProcessPostgresConfigFile(fp, auto_conf.data, &config, NULL, NULL);
fclose(fp); fclose(fp);
if (success == false)
{
fprintf(stderr, "unable to process \"%s\"\n",
auto_conf.data);
termPQExpBuffer(&auto_conf);
return false;
}
/* /*
* Append requested items to items extracted from the existing file. * Append requested items to items extracted from the existing file.
*/ */
@@ -1855,7 +1862,6 @@ modify_auto_conf(const char *data_dir, KeyValueList *items)
key_value_list_replace_or_set(&config, key_value_list_replace_or_set(&config,
cell->key, cell->key,
cell->value); cell->value);
} }
initPQExpBuffer(&auto_conf_tmp); initPQExpBuffer(&auto_conf_tmp);
@@ -1911,9 +1917,12 @@ modify_auto_conf(const char *data_dir, KeyValueList *items)
* (unlikely) event that a repmgr built against one of those versions * (unlikely) event that a repmgr built against one of those versions
* is being used against Pg 12 and later. * is being used against Pg 12 and later.
*/ */
// XXX check return values
#if (PG_ACTUAL_VERSION_NUM >= 100000) #if (PG_ACTUAL_VERSION_NUM >= 100000)
(void) durable_rename(auto_conf_tmp.data, auto_conf.data, LOG); if (durable_rename(auto_conf_tmp.data, auto_conf.data, LOG) != 0)
{
success = false;
}
#else #else
if (rename(auto_conf_tmp.data, auto_conf.data) < 0) if (rename(auto_conf_tmp.data, auto_conf.data) < 0)
{ {