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

Commite262725

Browse files
committed
Suppress possibly-uninitialized-variable warnings from gcc 4.5.
It appears that gcc 4.5 can issue such warnings for whole structs, notjust scalar variables as in the past. Refactor some pg_dump code slightlyso that the OutputContext local variables are always initialized, evenif they won't be used. It's cheap enough to not be worth worrying about.
1 parent116ce2f commite262725

File tree

2 files changed

+29
-21
lines changed

2 files changed

+29
-21
lines changed

‎src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 29 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,13 @@ typedef struct _parallel_slot
7575

7676
#defineNO_SLOT (-1)
7777

78+
/* state needed to save/restore an archive's output target */
79+
typedefstruct_outputContext
80+
{
81+
void*OF;
82+
intgzOut;
83+
}OutputContext;
84+
7885
constchar*progname;
7986

8087
staticconstchar*modulename=gettext_noop("archiver");
@@ -114,8 +121,9 @@ static void _write_msg(const char *modulename, const char *fmt, va_list ap);
114121
staticvoid_die_horribly(ArchiveHandle*AH,constchar*modulename,constchar*fmt,va_listap);
115122

116123
staticvoiddumpTimestamp(ArchiveHandle*AH,constchar*msg,time_ttim);
117-
staticOutputContextSetOutput(ArchiveHandle*AH,char*filename,intcompression);
118-
staticvoidResetOutput(ArchiveHandle*AH,OutputContextsavedContext);
124+
staticvoidSetOutput(ArchiveHandle*AH,char*filename,intcompression);
125+
staticOutputContextSaveOutput(ArchiveHandle*AH);
126+
staticvoidRestoreOutput(ArchiveHandle*AH,OutputContextsavedContext);
119127

120128
staticintrestore_toc_entry(ArchiveHandle*AH,TocEntry*te,
121129
RestoreOptions*ropt,boolis_parallel);
@@ -299,8 +307,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
299307
/*
300308
* Setup the output file if necessary.
301309
*/
310+
sav=SaveOutput(AH);
302311
if (ropt->filename||ropt->compression)
303-
sav=SetOutput(AH,ropt->filename,ropt->compression);
312+
SetOutput(AH,ropt->filename,ropt->compression);
304313

305314
ahprintf(AH,"--\n-- PostgreSQL database dump\n--\n\n");
306315

@@ -420,7 +429,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
420429
AH->stage=STAGE_FINALIZING;
421430

422431
if (ropt->filename||ropt->compression)
423-
ResetOutput(AH,sav);
432+
RestoreOutput(AH,sav);
424433

425434
if (ropt->useDB)
426435
{
@@ -782,8 +791,9 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
782791
OutputContextsav;
783792
char*fmtName;
784793

794+
sav=SaveOutput(AH);
785795
if (ropt->filename)
786-
sav=SetOutput(AH,ropt->filename,0/* no compression */ );
796+
SetOutput(AH,ropt->filename,0/* no compression */ );
787797

788798
ahprintf(AH,";\n; Archive created at %s",ctime(&AH->createDate));
789799
ahprintf(AH,"; dbname: %s\n; TOC Entries: %d\n; Compression: %d\n",
@@ -839,7 +849,7 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
839849
}
840850

841851
if (ropt->filename)
842-
ResetOutput(AH,sav);
852+
RestoreOutput(AH,sav);
843853
}
844854

845855
/***********
@@ -1117,16 +1127,11 @@ archprintf(Archive *AH, const char *fmt,...)
11171127
* Stuff below here should be 'private' to the archiver routines
11181128
*******************************/
11191129

1120-
staticOutputContext
1130+
staticvoid
11211131
SetOutput(ArchiveHandle*AH,char*filename,intcompression)
11221132
{
1123-
OutputContextsav;
11241133
intfn;
11251134

1126-
/* Replace the AH output file handle */
1127-
sav.OF=AH->OF;
1128-
sav.gzOut=AH->gzOut;
1129-
11301135
if (filename)
11311136
fn=-1;
11321137
elseif (AH->FH)
@@ -1182,12 +1187,21 @@ SetOutput(ArchiveHandle *AH, char *filename, int compression)
11821187
die_horribly(AH,modulename,"could not open output file: %s\n",
11831188
strerror(errno));
11841189
}
1190+
}
1191+
1192+
staticOutputContext
1193+
SaveOutput(ArchiveHandle*AH)
1194+
{
1195+
OutputContextsav;
1196+
1197+
sav.OF=AH->OF;
1198+
sav.gzOut=AH->gzOut;
11851199

11861200
returnsav;
11871201
}
11881202

11891203
staticvoid
1190-
ResetOutput(ArchiveHandle*AH,OutputContextsav)
1204+
RestoreOutput(ArchiveHandle*AH,OutputContextsavedContext)
11911205
{
11921206
intres;
11931207

@@ -1200,8 +1214,8 @@ ResetOutput(ArchiveHandle *AH, OutputContext sav)
12001214
die_horribly(AH,modulename,"could not close output file: %s\n",
12011215
strerror(errno));
12021216

1203-
AH->gzOut=sav.gzOut;
1204-
AH->OF=sav.OF;
1217+
AH->gzOut=savedContext.gzOut;
1218+
AH->OF=savedContext.OF;
12051219
}
12061220

12071221

‎src/bin/pg_dump/pg_backup_archiver.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -132,12 +132,6 @@ typedef void (*DeClonePtr) (struct _archiveHandle * AH);
132132

133133
typedefsize_t (*CustomOutPtr) (struct_archiveHandle*AH,constvoid*buf,size_tlen);
134134

135-
typedefstruct_outputContext
136-
{
137-
void*OF;
138-
intgzOut;
139-
}OutputContext;
140-
141135
typedefenum
142136
{
143137
SQL_SCAN=0,/* normal */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp