Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0dcfb06

Browse files
committed
s:snprintf(..., MAXPGPATH, "%s/%s", ...):join_path_components(...):g
1 parent4ba1d65 commit0dcfb06

File tree

5 files changed

+12
-13
lines changed

5 files changed

+12
-13
lines changed

‎src/catalog.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ IsDir(const char *dirpath, const char *entry, fio_location location)
829829
charpath[MAXPGPATH];
830830
structstatst;
831831

832-
snprintf(path,MAXPGPATH,"%s/%s",dirpath,entry);
832+
join_path_components(path,dirpath,entry);
833833

834834
returnfio_stat(path,&st, false,location)==0&&S_ISDIR(st.st_mode);
835835
}
@@ -941,7 +941,7 @@ catalog_get_backup_list(const char *instance_name, time_t requested_backup_id)
941941
join_path_components(data_path,backup_instance_path,data_ent->d_name);
942942

943943
/* read backup information from BACKUP_CONTROL_FILE */
944-
snprintf(backup_conf_path,MAXPGPATH,"%s/%s",data_path,BACKUP_CONTROL_FILE);
944+
join_path_components(backup_conf_path,data_path,BACKUP_CONTROL_FILE);
945945
backup=readBackupControlFile(backup_conf_path);
946946

947947
if (!backup)

‎src/parsexlog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1017,7 +1017,7 @@ SimpleXLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr,
10171017

10181018
GetXLogFileName(xlogfname,reader_data->tli,reader_data->xlogsegno,wal_seg_size);
10191019

1020-
snprintf(reader_data->xlogpath,MAXPGPATH,"%s/%s",wal_archivedir,xlogfname);
1020+
join_path_components(reader_data->xlogpath,wal_archivedir,xlogfname);
10211021
snprintf(reader_data->gz_xlogpath,MAXPGPATH,"%s.gz",reader_data->xlogpath);
10221022

10231023
/* We fall back to using .partial segment in case if we are running

‎src/restore.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ update_recovery_options_before_v12(pgBackup *backup,
14801480
}
14811481

14821482
elog(LOG,"update recovery settings in recovery.conf");
1483-
snprintf(path,lengthof(path),"%s/recovery.conf",instance_config.pgdata);
1483+
join_path_components(path,instance_config.pgdata,"recovery.conf");
14841484

14851485
fp=fio_fopen(path,"w",FIO_DB_HOST);
14861486
if (fp==NULL)
@@ -1537,8 +1537,7 @@ update_recovery_options(pgBackup *backup,
15371537

15381538
time2iso(current_time_str,lengthof(current_time_str),current_time, false);
15391539

1540-
snprintf(postgres_auto_path,lengthof(postgres_auto_path),
1541-
"%s/postgresql.auto.conf",instance_config.pgdata);
1540+
join_path_components(postgres_auto_path,instance_config.pgdata,"postgresql.auto.conf");
15421541

15431542
if (fio_stat(postgres_auto_path,&st, false,FIO_DB_HOST)<0)
15441543
{
@@ -1648,7 +1647,7 @@ update_recovery_options(pgBackup *backup,
16481647
if (params->recovery_settings_mode==PITR_REQUESTED)
16491648
{
16501649
elog(LOG,"creating recovery.signal file");
1651-
snprintf(path,lengthof(path),"%s/recovery.signal",instance_config.pgdata);
1650+
join_path_components(path,instance_config.pgdata,"recovery.signal");
16521651

16531652
fp=fio_fopen(path,PG_BINARY_W,FIO_DB_HOST);
16541653
if (fp==NULL)
@@ -1664,7 +1663,7 @@ update_recovery_options(pgBackup *backup,
16641663
if (params->restore_as_replica)
16651664
{
16661665
elog(LOG,"creating standby.signal file");
1667-
snprintf(path,lengthof(path),"%s/standby.signal",instance_config.pgdata);
1666+
join_path_components(path,instance_config.pgdata,"standby.signal");
16681667

16691668
fp=fio_fopen(path,PG_BINARY_W,FIO_DB_HOST);
16701669
if (fp==NULL)
@@ -2160,7 +2159,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
21602159
{
21612160
charpid_file[MAXPGPATH];
21622161

2163-
snprintf(pid_file,MAXPGPATH,"%s/postmaster.pid",pgdata);
2162+
join_path_components(pid_file,pgdata,"postmaster.pid");
21642163
elog(WARNING,"Pid file \"%s\" is mangled, cannot determine whether postmaster is running or not",
21652164
pid_file);
21662165
success= false;
@@ -2201,7 +2200,7 @@ check_incremental_compatibility(const char *pgdata, uint64 system_identifier,
22012200
*/
22022201
if (incremental_mode==INCR_LSN)
22032202
{
2204-
snprintf(backup_label,MAXPGPATH,"%s/backup_label",pgdata);
2203+
join_path_components(backup_label,pgdata,"backup_label");
22052204
if (fio_access(backup_label,F_OK,FIO_DB_HOST)==0)
22062205
{
22072206
elog(WARNING,"Destination directory contains \"backup_control\" file. "

‎src/util.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ set_min_recovery_point(pgFile *file, const char *backup_path,
418418
FIN_CRC32C(ControlFile.crc);
419419

420420
/* overwrite pg_control */
421-
snprintf(fullpath,sizeof(fullpath),"%s/%s",backup_path,XLOG_CONTROL_FILE);
421+
join_path_components(fullpath,backup_path,XLOG_CONTROL_FILE);
422422
writeControlFile(&ControlFile,fullpath,FIO_LOCAL_HOST);
423423

424424
/* Update pg_control checksum in backup_list */
@@ -569,7 +569,7 @@ check_postmaster(const char *pgdata)
569569
pid_tpid;
570570
charpid_file[MAXPGPATH];
571571

572-
snprintf(pid_file,MAXPGPATH,"%s/postmaster.pid",pgdata);
572+
join_path_components(pid_file,pgdata,"postmaster.pid");
573573

574574
fp=fopen(pid_file,"r");
575575
if (fp==NULL)

‎src/utils/pgut.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ pgut_rmtree(const char *path, bool rmtopdir, bool strict)
11841184
/* now we have the names we can start removing things */
11851185
for (filename=filenames;*filename;filename++)
11861186
{
1187-
snprintf(pathbuf,MAXPGPATH,"%s/%s",path,*filename);
1187+
join_path_components(pathbuf,path,*filename);
11881188

11891189
if (lstat(pathbuf,&statbuf)!=0)
11901190
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp