Skip to content

Commit 676d637

Browse files
committed
Do not initialize local variables unnecessarily
By initializing them to something it makes it look like there is an intent behind it which there in all of these cases is not.
1 parent 332064b commit 676d637

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

contrib/pg_tde/src/access/pg_tde_tdemap.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pg_tde_create_wal_key(InternalKey *rel_key_data, const RelFileLocator *newrlocat
253253
void
254254
pg_tde_delete_tde_files(Oid dbOid)
255255
{
256-
char db_map_path[MAXPGPATH] = {0};
256+
char db_map_path[MAXPGPATH];
257257

258258
pg_tde_set_db_file_path(dbOid, db_map_path);
259259

@@ -266,7 +266,7 @@ pg_tde_save_principal_key_redo(const TDESignedPrincipalKeyInfo *signed_key_info)
266266
{
267267
int map_fd;
268268
off_t curr_pos;
269-
char db_map_path[MAXPGPATH] = {0};
269+
char db_map_path[MAXPGPATH];
270270

271271
pg_tde_set_db_file_path(signed_key_info->data.databaseId, db_map_path);
272272

@@ -289,9 +289,9 @@ pg_tde_save_principal_key_redo(const TDESignedPrincipalKeyInfo *signed_key_info)
289289
void
290290
pg_tde_save_principal_key(const TDEPrincipalKey *principal_key, bool write_xlog)
291291
{
292-
int map_fd = -1;
292+
int map_fd;
293293
off_t curr_pos = 0;
294-
char db_map_path[MAXPGPATH] = {0};
294+
char db_map_path[MAXPGPATH];
295295
TDESignedPrincipalKeyInfo signed_key_Info;
296296

297297
pg_tde_set_db_file_path(principal_key->keyInfo.databaseId, db_map_path);
@@ -419,8 +419,8 @@ pg_tde_write_one_map_entry(int fd, const TDEMapEntry *map_entry, off_t *offset,
419419
void
420420
pg_tde_write_key_map_entry(const RelFileLocator *rlocator, InternalKey *rel_key_data, TDEPrincipalKey *principal_key, bool write_xlog)
421421
{
422-
char db_map_path[MAXPGPATH] = {0};
423-
int map_fd = -1;
422+
char db_map_path[MAXPGPATH];
423+
int map_fd;
424424
off_t curr_pos = 0;
425425
off_t prev_pos = 0;
426426
TDEMapEntry write_map_entry;
@@ -487,8 +487,8 @@ pg_tde_write_key_map_entry(const RelFileLocator *rlocator, InternalKey *rel_key_
487487
void
488488
pg_tde_write_key_map_entry_redo(const TDEMapEntry *write_map_entry, TDESignedPrincipalKeyInfo *signed_key_info)
489489
{
490-
char db_map_path[MAXPGPATH] = {0};
491-
int map_fd = -1;
490+
char db_map_path[MAXPGPATH];
491+
int map_fd;
492492
off_t curr_pos = 0;
493493
off_t prev_pos = 0;
494494

@@ -701,10 +701,10 @@ void
701701
pg_tde_write_map_keydata_file(off_t file_size, char *file_data)
702702
{
703703
TDEFileHeader *fheader;
704+
char db_map_path[MAXPGPATH];
704705
char path_new[MAXPGPATH];
705706
int fd_new;
706707
off_t curr_pos = 0;
707-
char db_map_path[MAXPGPATH] = {0};
708708
bool is_err = false;
709709

710710
/* Let's get the header. Buff should start with the map file header. */
@@ -746,7 +746,7 @@ void
746746
pg_tde_wal_last_key_set_lsn(XLogRecPtr lsn, const char *keyfile_path)
747747
{
748748
LWLock *lock_pk = tde_lwlock_enc_keys();
749-
int fd = -1;
749+
int fd;
750750
off_t read_pos,
751751
write_pos,
752752
last_key_idx;
@@ -848,7 +848,7 @@ pg_tde_get_key_from_file(const RelFileLocator *rlocator, uint32 key_type)
848848
TDEMapEntry map_entry;
849849
TDEPrincipalKey *principal_key;
850850
LWLock *lock_pk = tde_lwlock_enc_keys();
851-
char db_map_path[MAXPGPATH] = {0};
851+
char db_map_path[MAXPGPATH];
852852
InternalKey *rel_key;
853853

854854
Assert(rlocator);
@@ -1059,7 +1059,7 @@ pg_tde_read_one_map_entry2(int fd, int32 key_index, TDEMapEntry *map_entry, Oid
10591059
/* Read the encrypted key */
10601060
if (pg_pread(fd, map_entry, MAP_ENTRY_SIZE, read_pos) != MAP_ENTRY_SIZE)
10611061
{
1062-
char db_map_path[MAXPGPATH] = {0};
1062+
char db_map_path[MAXPGPATH];
10631063

10641064
pg_tde_set_db_file_path(databaseId, db_map_path);
10651065
ereport(FATAL,
@@ -1076,11 +1076,11 @@ pg_tde_read_one_map_entry2(int fd, int32 key_index, TDEMapEntry *map_entry, Oid
10761076
TDESignedPrincipalKeyInfo *
10771077
pg_tde_get_principal_key_info(Oid dbOid)
10781078
{
1079-
int fd = -1;
1079+
char db_map_path[MAXPGPATH];
1080+
int fd;
10801081
TDEFileHeader fheader;
10811082
TDESignedPrincipalKeyInfo *signed_key_info = NULL;
10821083
off_t bytes_read = 0;
1083-
char db_map_path[MAXPGPATH] = {0};
10841084

10851085
pg_tde_set_db_file_path(dbOid, db_map_path);
10861086

@@ -1198,12 +1198,12 @@ InternalKey *
11981198
pg_tde_read_last_wal_key(void)
11991199
{
12001200
RelFileLocator rlocator = GLOBAL_SPACE_RLOCATOR(XLOG_TDE_OID);
1201-
char db_map_path[MAXPGPATH] = {0};
1201+
char db_map_path[MAXPGPATH];
12021202
off_t read_pos = 0;
12031203
LWLock *lock_pk = tde_lwlock_enc_keys();
12041204
TDEPrincipalKey *principal_key;
1205-
int fd = -1;
1206-
int file_idx = 0;
1205+
int fd;
1206+
int file_idx;
12071207
TDEMapEntry map_entry;
12081208
InternalKey *rel_key_data;
12091209
off_t fsize;
@@ -1242,11 +1242,11 @@ WALKeyCacheRec *
12421242
pg_tde_fetch_wal_keys(XLogRecPtr start_lsn)
12431243
{
12441244
RelFileLocator rlocator = GLOBAL_SPACE_RLOCATOR(XLOG_TDE_OID);
1245-
char db_map_path[MAXPGPATH] = {0};
1245+
char db_map_path[MAXPGPATH];
12461246
off_t read_pos = 0;
12471247
LWLock *lock_pk = tde_lwlock_enc_keys();
12481248
TDEPrincipalKey *principal_key;
1249-
int fd = -1;
1249+
int fd;
12501250
int keys_count;
12511251
WALKeyCacheRec *return_wal_rec = NULL;
12521252

0 commit comments

Comments
 (0)