mirror of
https://github.com/postgres/postgres.git
synced 2025-04-24 10:47:04 +03:00
Suppress possibly-uninitialized-variable warnings from gcc 4.5.
It appears that gcc 4.5 can issue such warnings for whole structs, not just scalar variables as in the past. Refactor some pg_dump code slightly so that the OutputContext local variables are always initialized, even if they won't be used. It's cheap enough to not be worth worrying about.
This commit is contained in:
parent
116ce2f4d0
commit
e2627258c3
@ -75,6 +75,13 @@ typedef struct _parallel_slot
|
||||
|
||||
#define NO_SLOT (-1)
|
||||
|
||||
/* state needed to save/restore an archive's output target */
|
||||
typedef struct _outputContext
|
||||
{
|
||||
void *OF;
|
||||
int gzOut;
|
||||
} OutputContext;
|
||||
|
||||
const char *progname;
|
||||
|
||||
static const char *modulename = gettext_noop("archiver");
|
||||
@ -114,8 +121,9 @@ static void _write_msg(const char *modulename, const char *fmt, va_list ap);
|
||||
static void _die_horribly(ArchiveHandle *AH, const char *modulename, const char *fmt, va_list ap);
|
||||
|
||||
static void dumpTimestamp(ArchiveHandle *AH, const char *msg, time_t tim);
|
||||
static OutputContext SetOutput(ArchiveHandle *AH, char *filename, int compression);
|
||||
static void ResetOutput(ArchiveHandle *AH, OutputContext savedContext);
|
||||
static void SetOutput(ArchiveHandle *AH, char *filename, int compression);
|
||||
static OutputContext SaveOutput(ArchiveHandle *AH);
|
||||
static void RestoreOutput(ArchiveHandle *AH, OutputContext savedContext);
|
||||
|
||||
static int restore_toc_entry(ArchiveHandle *AH, TocEntry *te,
|
||||
RestoreOptions *ropt, bool is_parallel);
|
||||
@ -299,8 +307,9 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
|
||||
/*
|
||||
* Setup the output file if necessary.
|
||||
*/
|
||||
sav = SaveOutput(AH);
|
||||
if (ropt->filename || ropt->compression)
|
||||
sav = SetOutput(AH, ropt->filename, ropt->compression);
|
||||
SetOutput(AH, ropt->filename, ropt->compression);
|
||||
|
||||
ahprintf(AH, "--\n-- PostgreSQL database dump\n--\n\n");
|
||||
|
||||
@ -420,7 +429,7 @@ RestoreArchive(Archive *AHX, RestoreOptions *ropt)
|
||||
AH->stage = STAGE_FINALIZING;
|
||||
|
||||
if (ropt->filename || ropt->compression)
|
||||
ResetOutput(AH, sav);
|
||||
RestoreOutput(AH, sav);
|
||||
|
||||
if (ropt->useDB)
|
||||
{
|
||||
@ -782,8 +791,9 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
|
||||
OutputContext sav;
|
||||
char *fmtName;
|
||||
|
||||
sav = SaveOutput(AH);
|
||||
if (ropt->filename)
|
||||
sav = SetOutput(AH, ropt->filename, 0 /* no compression */ );
|
||||
SetOutput(AH, ropt->filename, 0 /* no compression */ );
|
||||
|
||||
ahprintf(AH, ";\n; Archive created at %s", ctime(&AH->createDate));
|
||||
ahprintf(AH, "; dbname: %s\n; TOC Entries: %d\n; Compression: %d\n",
|
||||
@ -839,7 +849,7 @@ PrintTOCSummary(Archive *AHX, RestoreOptions *ropt)
|
||||
}
|
||||
|
||||
if (ropt->filename)
|
||||
ResetOutput(AH, sav);
|
||||
RestoreOutput(AH, sav);
|
||||
}
|
||||
|
||||
/***********
|
||||
@ -1117,16 +1127,11 @@ archprintf(Archive *AH, const char *fmt,...)
|
||||
* Stuff below here should be 'private' to the archiver routines
|
||||
*******************************/
|
||||
|
||||
static OutputContext
|
||||
static void
|
||||
SetOutput(ArchiveHandle *AH, char *filename, int compression)
|
||||
{
|
||||
OutputContext sav;
|
||||
int fn;
|
||||
|
||||
/* Replace the AH output file handle */
|
||||
sav.OF = AH->OF;
|
||||
sav.gzOut = AH->gzOut;
|
||||
|
||||
if (filename)
|
||||
fn = -1;
|
||||
else if (AH->FH)
|
||||
@ -1182,12 +1187,21 @@ SetOutput(ArchiveHandle *AH, char *filename, int compression)
|
||||
die_horribly(AH, modulename, "could not open output file: %s\n",
|
||||
strerror(errno));
|
||||
}
|
||||
}
|
||||
|
||||
static OutputContext
|
||||
SaveOutput(ArchiveHandle *AH)
|
||||
{
|
||||
OutputContext sav;
|
||||
|
||||
sav.OF = AH->OF;
|
||||
sav.gzOut = AH->gzOut;
|
||||
|
||||
return sav;
|
||||
}
|
||||
|
||||
static void
|
||||
ResetOutput(ArchiveHandle *AH, OutputContext sav)
|
||||
RestoreOutput(ArchiveHandle *AH, OutputContext savedContext)
|
||||
{
|
||||
int res;
|
||||
|
||||
@ -1200,8 +1214,8 @@ ResetOutput(ArchiveHandle *AH, OutputContext sav)
|
||||
die_horribly(AH, modulename, "could not close output file: %s\n",
|
||||
strerror(errno));
|
||||
|
||||
AH->gzOut = sav.gzOut;
|
||||
AH->OF = sav.OF;
|
||||
AH->gzOut = savedContext.gzOut;
|
||||
AH->OF = savedContext.OF;
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,12 +132,6 @@ typedef void (*DeClonePtr) (struct _archiveHandle * AH);
|
||||
|
||||
typedef size_t (*CustomOutPtr) (struct _archiveHandle * AH, const void *buf, size_t len);
|
||||
|
||||
typedef struct _outputContext
|
||||
{
|
||||
void *OF;
|
||||
int gzOut;
|
||||
} OutputContext;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SQL_SCAN = 0, /* normal */
|
||||
|
Loading…
x
Reference in New Issue
Block a user