Skip to content

Commit 44096f1

Browse files
committed
Fix portability breakage in pg_dump.
Commit 0eea804 introduced some overly optimistic assumptions about what could be in a local struct variable's initializer. (This might in fact be valid code according to C99, but I've got at least one pre-C99 compiler that falls over on those nonconstant address expressions.) There is no reason whatsoever for main()'s workspace to not be static, so revert long_options[] to a static and make the DumpOptions struct static as well.
1 parent 8883bae commit 44096f1

File tree

3 files changed

+91
-84
lines changed

3 files changed

+91
-84
lines changed

src/bin/pg_dump/pg_backup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ extern void PrintTOCSummary(Archive *AH, RestoreOptions *ropt);
269269
extern RestoreOptions *NewRestoreOptions(void);
270270

271271
extern DumpOptions *NewDumpOptions(void);
272+
extern void InitDumpOptions(DumpOptions *opts);
272273
extern DumpOptions *dumpOptionsFromRestoreOptions(RestoreOptions *ropt);
273274

274275
/* Rearrange and filter TOC entries */

src/bin/pg_dump/pg_backup_archiver.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,27 @@ static void mark_create_done(ArchiveHandle *AH, TocEntry *te);
109109
static void inhibit_data_for_failed_table(ArchiveHandle *AH, TocEntry *te);
110110

111111
/*
112-
* Allocate a new DumpOptions block.
113-
* This is mainly so we can initialize it, but also for future expansion.
114-
* We pg_malloc0 the structure, so we don't need to initialize whatever is
115-
* 0, NULL or false anyway.
112+
* Allocate a new DumpOptions block containing all default values.
116113
*/
117114
DumpOptions *
118115
NewDumpOptions(void)
119116
{
120-
DumpOptions *opts;
117+
DumpOptions *opts = (DumpOptions *) pg_malloc(sizeof(DumpOptions));
121118

122-
opts = (DumpOptions *) pg_malloc0(sizeof(DumpOptions));
119+
InitDumpOptions(opts);
120+
return opts;
121+
}
123122

123+
/*
124+
* Initialize a DumpOptions struct to all default values
125+
*/
126+
void
127+
InitDumpOptions(DumpOptions *opts)
128+
{
129+
memset(opts, 0, sizeof(DumpOptions));
124130
/* set any fields that shouldn't default to zeroes */
125131
opts->include_everything = true;
126132
opts->dumpSections = DUMP_UNSECTIONED;
127-
128-
return opts;
129133
}
130134

131135
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy