diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2015-03-29 20:02:14 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2015-03-29 20:02:14 -0400 |
commit | c67f366fa9f748257861ee233b47b80eb5ffa857 (patch) | |
tree | c76f6288f45e7d9979b1294cda0df01684f75ad3 /src/bin/pg_rewind/filemap.h | |
parent | e4cbfd673d530a3e841db26a74f22e11a991205a (diff) |
Fix multiple bugs and infelicities in pg_rewind.
Bugs all spotted by Coverity, including wrong realloc() size request
and memory leaks. Cosmetic improvements by me.
The usage of the global variable "filemap" here is still pretty awful,
but at least I got rid of the gratuitous aliasing in several routines
(which was helping to annoy Coverity, as well as being a bug risk).
Diffstat (limited to 'src/bin/pg_rewind/filemap.h')
-rw-r--r-- | src/bin/pg_rewind/filemap.h | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/src/bin/pg_rewind/filemap.h b/src/bin/pg_rewind/filemap.h index 57f0f92fb90..8fa19390bc3 100644 --- a/src/bin/pg_rewind/filemap.h +++ b/src/bin/pg_rewind/filemap.h @@ -29,8 +29,7 @@ typedef enum FILE_ACTION_NONE, /* no action (we might still copy modified blocks * based on the parsed WAL) */ FILE_ACTION_TRUNCATE, /* truncate local file to 'newsize' bytes */ - FILE_ACTION_REMOVE, /* remove local file / directory / symlink */ - + FILE_ACTION_REMOVE /* remove local file / directory / symlink */ } file_action_t; typedef enum @@ -40,7 +39,7 @@ typedef enum FILE_TYPE_SYMLINK } file_type_t; -struct file_entry_t +typedef struct file_entry_t { char *path; file_type_t type; @@ -58,11 +57,9 @@ struct file_entry_t char *link_target; struct file_entry_t *next; -}; - -typedef struct file_entry_t file_entry_t; +} file_entry_t; -struct filemap_t +typedef struct filemap_t { /* * New entries are accumulated to a linked list, in process_remote_file @@ -70,7 +67,7 @@ struct filemap_t */ file_entry_t *first; file_entry_t *last; - int nlist; + int nlist; /* number of entries currently in list */ /* * After processing all the remote files, the entries in the linked list @@ -80,7 +77,7 @@ struct filemap_t * the array, and the linked list is empty. */ file_entry_t **array; - int narray; + int narray; /* current length of array */ /* * Summary information. total_size is the total size of the source cluster, @@ -88,14 +85,11 @@ struct filemap_t */ uint64 total_size; uint64 fetch_size; -}; - -typedef struct filemap_t filemap_t; - -extern filemap_t * filemap; +} filemap_t; -extern filemap_t *filemap_create(void); +extern filemap_t *filemap; +extern void filemap_create(void); extern void calculate_totals(void); extern void print_filemap(void); |