Skip to content

Commit 005e5c3

Browse files
committed
Use less cryptic variable names
1 parent 2411fbd commit 005e5c3

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

src/bin/pg_basebackup/pg_basebackup.c

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static char *xstrdup(const char *s);
5959
static void *xmalloc0(int size);
6060
static void usage(void);
6161
static void verify_dir_is_empty_or_create(char *dirname);
62-
static void progress_report(int tablespacenum, char *fn);
62+
static void progress_report(int tablespacenum, const char *filename);
6363
static PGconn *GetConnection(void);
6464

6565
static void ReceiveTarFile(PGconn *conn, PGresult *res, int rownum);
@@ -201,7 +201,7 @@ verify_dir_is_empty_or_create(char *dirname)
201201
* is enabled, also print the current file name.
202202
*/
203203
static void
204-
progress_report(int tablespacenum, char *fn)
204+
progress_report(int tablespacenum, const char *filename)
205205
{
206206
int percent = (int) ((totaldone / 1024) * 100 / totalsize);
207207

@@ -210,7 +210,7 @@ progress_report(int tablespacenum, char *fn)
210210

211211
if (verbose)
212212
{
213-
if (!fn)
213+
if (!filename)
214214

215215
/*
216216
* No filename given, so clear the status line (used for last
@@ -225,7 +225,7 @@ progress_report(int tablespacenum, char *fn)
225225
INT64_FORMAT "/" INT64_FORMAT " kB (%d%%) %d/%d tablespaces (%-30.30s)\r",
226226
totaldone / 1024, totalsize,
227227
percent,
228-
tablespacenum, tablespacecount, fn);
228+
tablespacenum, tablespacecount, filename);
229229
}
230230
else
231231
fprintf(stderr, INT64_FORMAT "/" INT64_FORMAT " kB (%d%%) %d/%d tablespaces\r",
@@ -248,7 +248,7 @@ progress_report(int tablespacenum, char *fn)
248248
static void
249249
ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
250250
{
251-
char fn[MAXPGPATH];
251+
char filename[MAXPGPATH];
252252
char *copybuf = NULL;
253253
FILE *tarfile = NULL;
254254

@@ -283,8 +283,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
283283
#ifdef HAVE_LIBZ
284284
if (compresslevel != 0)
285285
{
286-
snprintf(fn, sizeof(fn), "%s/base.tar.gz", basedir);
287-
ztarfile = gzopen(fn, "wb");
286+
snprintf(filename, sizeof(filename), "%s/base.tar.gz", basedir);
287+
ztarfile = gzopen(filename, "wb");
288288
if (gzsetparams(ztarfile, compresslevel, Z_DEFAULT_STRATEGY) != Z_OK)
289289
{
290290
fprintf(stderr, _("%s: could not set compression level %d: %s\n"),
@@ -295,8 +295,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
295295
else
296296
#endif
297297
{
298-
snprintf(fn, sizeof(fn), "%s/base.tar", basedir);
299-
tarfile = fopen(fn, "wb");
298+
snprintf(filename, sizeof(filename), "%s/base.tar", basedir);
299+
tarfile = fopen(filename, "wb");
300300
}
301301
}
302302
else
@@ -307,8 +307,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
307307
#ifdef HAVE_LIBZ
308308
if (compresslevel != 0)
309309
{
310-
snprintf(fn, sizeof(fn), "%s/%s.tar.gz", basedir, PQgetvalue(res, rownum, 0));
311-
ztarfile = gzopen(fn, "wb");
310+
snprintf(filename, sizeof(filename), "%s/%s.tar.gz", basedir, PQgetvalue(res, rownum, 0));
311+
ztarfile = gzopen(filename, "wb");
312312
if (gzsetparams(ztarfile, compresslevel, Z_DEFAULT_STRATEGY) != Z_OK)
313313
{
314314
fprintf(stderr, _("%s: could not set compression level %d: %s\n"),
@@ -319,8 +319,8 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
319319
else
320320
#endif
321321
{
322-
snprintf(fn, sizeof(fn), "%s/%s.tar", basedir, PQgetvalue(res, rownum, 0));
323-
tarfile = fopen(fn, "wb");
322+
snprintf(filename, sizeof(filename), "%s/%s.tar", basedir, PQgetvalue(res, rownum, 0));
323+
tarfile = fopen(filename, "wb");
324324
}
325325
}
326326

@@ -331,7 +331,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
331331
{
332332
/* Compression is in use */
333333
fprintf(stderr, _("%s: could not create compressed file \"%s\": %s\n"),
334-
progname, fn, get_gz_error(ztarfile));
334+
progname, filename, get_gz_error(ztarfile));
335335
disconnect_and_exit(1);
336336
}
337337
}
@@ -342,7 +342,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
342342
if (!tarfile)
343343
{
344344
fprintf(stderr, _("%s: could not create file \"%s\": %s\n"),
345-
progname, fn, strerror(errno));
345+
progname, filename, strerror(errno));
346346
disconnect_and_exit(1);
347347
}
348348
}
@@ -386,7 +386,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
386386
if (gzwrite(ztarfile, zerobuf, sizeof(zerobuf)) != sizeof(zerobuf))
387387
{
388388
fprintf(stderr, _("%s: could not write to compressed file \"%s\": %s\n"),
389-
progname, fn, get_gz_error(ztarfile));
389+
progname, filename, get_gz_error(ztarfile));
390390
}
391391
}
392392
else
@@ -395,7 +395,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
395395
if (fwrite(zerobuf, sizeof(zerobuf), 1, tarfile) != 1)
396396
{
397397
fprintf(stderr, _("%s: could not write to file \"%s\": %s\n"),
398-
progname, fn, strerror(errno));
398+
progname, filename, strerror(errno));
399399
disconnect_and_exit(1);
400400
}
401401
}
@@ -432,7 +432,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
432432
if (gzwrite(ztarfile, copybuf, r) != r)
433433
{
434434
fprintf(stderr, _("%s: could not write to compressed file \"%s\": %s\n"),
435-
progname, fn, get_gz_error(ztarfile));
435+
progname, filename, get_gz_error(ztarfile));
436436
}
437437
}
438438
else
@@ -441,13 +441,13 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
441441
if (fwrite(copybuf, r, 1, tarfile) != 1)
442442
{
443443
fprintf(stderr, _("%s: could not write to file \"%s\": %s\n"),
444-
progname, fn, strerror(errno));
444+
progname, filename, strerror(errno));
445445
disconnect_and_exit(1);
446446
}
447447
}
448448
totaldone += r;
449449
if (showprogress)
450-
progress_report(rownum, fn);
450+
progress_report(rownum, filename);
451451
} /* while (1) */
452452

453453
if (copybuf != NULL)
@@ -468,7 +468,7 @@ static void
468468
ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
469469
{
470470
char current_path[MAXPGPATH];
471-
char fn[MAXPGPATH];
471+
char filename[MAXPGPATH];
472472
int current_len_left;
473473
int current_padding = 0;
474474
char *copybuf = NULL;
@@ -563,8 +563,8 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
563563
/*
564564
* First part of header is zero terminated filename
565565
*/
566-
snprintf(fn, sizeof(fn), "%s/%s", current_path, copybuf);
567-
if (fn[strlen(fn) - 1] == '/')
566+
snprintf(filename, sizeof(filename), "%s/%s", current_path, copybuf);
567+
if (filename[strlen(filename) - 1] == '/')
568568
{
569569
/*
570570
* Ends in a slash means directory or symlink to directory
@@ -574,31 +574,31 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
574574
/*
575575
* Directory
576576
*/
577-
fn[strlen(fn) - 1] = '\0'; /* Remove trailing slash */
578-
if (mkdir(fn, S_IRWXU) != 0)
577+
filename[strlen(filename) - 1] = '\0'; /* Remove trailing slash */
578+
if (mkdir(filename, S_IRWXU) != 0)
579579
{
580580
fprintf(stderr,
581581
_("%s: could not create directory \"%s\": %s\n"),
582-
progname, fn, strerror(errno));
582+
progname, filename, strerror(errno));
583583
disconnect_and_exit(1);
584584
}
585585
#ifndef WIN32
586-
if (chmod(fn, (mode_t) filemode))
586+
if (chmod(filename, (mode_t) filemode))
587587
fprintf(stderr, _("%s: could not set permissions on directory \"%s\": %s\n"),
588-
progname, fn, strerror(errno));
588+
progname, filename, strerror(errno));
589589
#endif
590590
}
591591
else if (copybuf[156] == '2')
592592
{
593593
/*
594594
* Symbolic link
595595
*/
596-
fn[strlen(fn) - 1] = '\0'; /* Remove trailing slash */
597-
if (symlink(&copybuf[157], fn) != 0)
596+
filename[strlen(filename) - 1] = '\0'; /* Remove trailing slash */
597+
if (symlink(&copybuf[157], filename) != 0)
598598
{
599599
fprintf(stderr,
600600
_("%s: could not create symbolic link from \"%s\" to \"%s\": %s\n"),
601-
progname, fn, &copybuf[157], strerror(errno));
601+
progname, filename, &copybuf[157], strerror(errno));
602602
disconnect_and_exit(1);
603603
}
604604
}
@@ -614,18 +614,18 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
614614
/*
615615
* regular file
616616
*/
617-
file = fopen(fn, "wb");
617+
file = fopen(filename, "wb");
618618
if (!file)
619619
{
620620
fprintf(stderr, _("%s: could not create file \"%s\": %s\n"),
621-
progname, fn, strerror(errno));
621+
progname, filename, strerror(errno));
622622
disconnect_and_exit(1);
623623
}
624624

625625
#ifndef WIN32
626-
if (chmod(fn, (mode_t) filemode))
626+
if (chmod(filename, (mode_t) filemode))
627627
fprintf(stderr, _("%s: could not set permissions on file \"%s\": %s\n"),
628-
progname, fn, strerror(errno));
628+
progname, filename, strerror(errno));
629629
#endif
630630

631631
if (current_len_left == 0)
@@ -658,12 +658,12 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
658658
if (fwrite(copybuf, r, 1, file) != 1)
659659
{
660660
fprintf(stderr, _("%s: could not write to file \"%s\": %s\n"),
661-
progname, fn, strerror(errno));
661+
progname, filename, strerror(errno));
662662
disconnect_and_exit(1);
663663
}
664664
totaldone += r;
665665
if (showprogress)
666-
progress_report(rownum, fn);
666+
progress_report(rownum, filename);
667667

668668
current_len_left -= r;
669669
if (current_len_left == 0 && current_padding == 0)

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