Skip to content

Commit 74d9e43

Browse files
committed
PGPRO-1646: Use int for write_size instead of size_t
1 parent 0a849e8 commit 74d9e43

File tree

6 files changed

+29
-33
lines changed

6 files changed

+29
-33
lines changed

src/backup.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ remote_copy_file(PGconn *conn, pgFile* file)
357357
elog(ERROR, "final receive failed: status %d ; %s",PQresultStatus(res), PQerrorMessage(conn));
358358
}
359359

360-
file->write_size = file->read_size;
360+
file->write_size = (int) file->read_size;
361361
FIN_CRC32C(file->crc);
362362

363363
fclose(out);
@@ -438,8 +438,8 @@ remote_backup_files(void *arg)
438438
/* receive the data from stream and write to backup file */
439439
remote_copy_file(file_backup_conn, file);
440440

441-
elog(VERBOSE, "File \"%s\". Copied %lu bytes",
442-
file->path, (unsigned long) file->write_size);
441+
elog(VERBOSE, "File \"%s\". Copied %d bytes",
442+
file->path, file->write_size);
443443
PQfinish(file_backup_conn);
444444
}
445445

@@ -2099,27 +2099,24 @@ backup_files(void *arg)
20992099
continue;
21002100
}
21012101
}
2102-
else
2103-
/* TODO:
2104-
* Check if file exists in previous backup
2105-
* If exists:
2106-
* if mtime > start_backup_time of parent backup,
2107-
* copy file to backup
2108-
* if mtime < start_backup_time
2109-
* calculate crc, compare crc to old file
2110-
* if crc is the same -> skip file
2111-
*/
2112-
if (!copy_file(arguments->from_root,
2113-
arguments->to_root,
2114-
file))
2102+
/* TODO:
2103+
* Check if file exists in previous backup
2104+
* If exists:
2105+
* if mtime > start_backup_time of parent backup,
2106+
* copy file to backup
2107+
* if mtime < start_backup_time
2108+
* calculate crc, compare crc to old file
2109+
* if crc is the same -> skip file
2110+
*/
2111+
else if (!copy_file(arguments->from_root, arguments->to_root, file))
21152112
{
21162113
file->write_size = BYTES_INVALID;
21172114
elog(VERBOSE, "File \"%s\" was not copied to backup", file->path);
21182115
continue;
21192116
}
21202117

2121-
elog(VERBOSE, "File \"%s\". Copied %lu bytes",
2122-
file->path, (unsigned long) file->write_size);
2118+
elog(VERBOSE, "File \"%s\". Copied %d bytes",
2119+
file->path, file->write_size);
21232120
}
21242121
else
21252122
elog(LOG, "unexpected file type %d", buf.st_mode);

src/data.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,8 @@ backup_data_page(backup_files_args *arguments,
229229
BackupMode backup_mode)
230230
{
231231
BackupPageHeader header;
232-
Page page = malloc(BLCKSZ);
233-
Page compressed_page = NULL;
232+
Page page = malloc(BLCKSZ);
233+
Page compressed_page = NULL;
234234
XLogRecPtr page_lsn = 0;
235235
size_t write_buffer_size;
236236
char write_buffer[BLCKSZ+sizeof(header)];
@@ -385,7 +385,7 @@ backup_data_page(backup_files_args *arguments,
385385
/* write data page */
386386
if(fwrite(write_buffer, 1, write_buffer_size, out) != write_buffer_size)
387387
{
388-
int errno_tmp = errno;
388+
int errno_tmp = errno;
389389
fclose(in);
390390
fclose(out);
391391
elog(ERROR, "File: %s, cannot write backup at block %u : %s",
@@ -843,7 +843,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
843843
file->read_size += read_len;
844844
}
845845

846-
file->write_size = file->read_size;
846+
file->write_size = (int) file->read_size;
847847
/* finish CRC calculation and store into pgFile */
848848
FIN_CRC32C(crc);
849849
file->crc = crc;

src/dir.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -821,11 +821,11 @@ print_file_list(FILE *out, const parray *files, const char *root)
821821
if (root && strstr(path, root) == path)
822822
path = GetRelativePath(path, root);
823823

824-
fprintf(out, "{\"path\":\"%s\", \"size\":\"%lu\",\"mode\":\"%u\","
824+
fprintf(out, "{\"path\":\"%s\", \"size\":\"%d\",\"mode\":\"%u\","
825825
"\"is_datafile\":\"%u\", \"is_cfs\":\"%u\", \"crc\":\"%u\","
826826
"\"compress_alg\":\"%s\"",
827-
path, (unsigned long) file->write_size, file->mode,
828-
file->is_datafile?1:0, file->is_cfs?1:0, file->crc,
827+
path, file->write_size, file->mode,
828+
file->is_datafile ? 1 : 0, file->is_cfs ? 1 : 0, file->crc,
829829
deparse_compress_alg(file->compress_alg));
830830

831831
if (file->is_datafile)
@@ -1032,7 +1032,7 @@ dir_read_file_list(const char *root, const char *file_txt)
10321032

10331033
file = pgFileInit(filepath);
10341034

1035-
file->write_size = (size_t) write_size;
1035+
file->write_size = (int) write_size;
10361036
file->mode = (mode_t) mode;
10371037
file->is_datafile = is_datafile ? true : false;
10381038
file->is_cfs = is_cfs ? true : false;

src/pg_probackup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ typedef struct pgFile
8888
size_t size; /* size of the file */
8989
size_t read_size; /* size of the portion read (if only some pages are
9090
backed up, it's different from size) */
91-
size_t write_size; /* size of the backed-up file. BYTES_INVALID means
91+
int write_size; /* size of the backed-up file. BYTES_INVALID means
9292
that the file existed but was not backed up
9393
because not modified since last backup. */
9494
pg_crc32 crc; /* CRC value of the file, regular file only */
@@ -160,7 +160,7 @@ typedef enum ShowFormat
160160

161161

162162
/* special values of pgBackup fields */
163-
#define INVALID_BACKUP_ID 0 /* backup ID is not provided by user */
163+
#define INVALID_BACKUP_ID 0 /* backup ID is not provided by user */
164164
#define BYTES_INVALID (-1)
165165

166166
typedef struct pgBackupConfig

src/restore.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,8 @@ restore_files(void *arg)
777777

778778
/* print size of restored file */
779779
if (file->write_size != BYTES_INVALID)
780-
elog(LOG, "Restored file %s : %lu bytes",
781-
file->path, (unsigned long) file->write_size);
780+
elog(LOG, "Restored file %s : %d bytes",
781+
file->path, file->write_size);
782782
}
783783

784784
/* Data files restoring is successful */

src/validate.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ pgBackupValidateFiles(void *arg)
189189

190190
if (file->write_size != st.st_size)
191191
{
192-
elog(WARNING, "Invalid size of backup file \"%s\" : %lu. Expected %lu",
193-
file->path, (unsigned long) file->write_size,
194-
(unsigned long) st.st_size);
192+
elog(WARNING, "Invalid size of backup file \"%s\" : %d. Expected %lu",
193+
file->path, file->write_size, (unsigned long) st.st_size);
195194
arguments->corrupted = true;
196195
break;
197196
}

0 commit comments

Comments
 (0)