Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3b5f5d9

Browse files
committed
Fix aboriginal bug in _tarAddFile(): when complaining that the amount of data
read from the temp file didn't match the file length reported by ftello(),the wrong variable's value was printed, and so the message made no sense.Clean up a couple other coding infelicities while at it.
1 parentc7b6593 commit3b5f5d9

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

‎src/bin/pg_dump/pg_backup_tar.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
*
1818
* IDENTIFICATION
19-
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.59 2007/08/06 01:38:15 tgl Exp $
19+
*$PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.60 2007/08/29 16:31:36 tgl Exp $
2020
*
2121
*-------------------------------------------------------------------------
2222
*/
@@ -1059,36 +1059,38 @@ _tarAddFile(ArchiveHandle *AH, TAR_MEMBER *th)
10591059
*/
10601060
fseeko(tmp,0,SEEK_END);
10611061
th->fileLen=ftello(tmp);
1062+
fseeko(tmp,0,SEEK_SET);
10621063

10631064
/*
1064-
* Some compilerswith throw a warning knowing this test can never be true
1065-
* because pgoff_t can't exceed the compared maximum.
1065+
* Some compilerswill throw a warning knowing this test can never be true
1066+
* because pgoff_t can't exceed the compared maximum on their platform.
10661067
*/
10671068
if (th->fileLen>MAX_TAR_MEMBER_FILELEN)
10681069
die_horribly(AH,modulename,"archive member too large for tar format\n");
1069-
fseeko(tmp,0,SEEK_SET);
10701070

10711071
_tarWriteHeader(th);
10721072

1073-
while ((cnt=fread(&buf[0],1,32767,tmp))>0)
1073+
while ((cnt=fread(buf,1,sizeof(buf),tmp))>0)
10741074
{
1075-
res=fwrite(&buf[0],1,cnt,th->tarFH);
1075+
res=fwrite(buf,1,cnt,th->tarFH);
10761076
if (res!=cnt)
10771077
die_horribly(AH,modulename,
1078-
"could not write to output file: %s\n",strerror(errno));
1078+
"could not write to output file: %s\n",
1079+
strerror(errno));
10791080
len+=res;
10801081
}
10811082

10821083
if (fclose(tmp)!=0)/* This *should* delete it... */
1083-
die_horribly(AH,modulename,"could not close temporary file: %s\n",strerror(errno));
1084+
die_horribly(AH,modulename,"could not close temporary file: %s\n",
1085+
strerror(errno));
10841086

10851087
if (len!=th->fileLen)
10861088
{
1087-
charbuf1[100],
1088-
buf2[100];
1089+
charbuf1[32],
1090+
buf2[32];
10891091

10901092
snprintf(buf1,sizeof(buf1),INT64_FORMAT, (int64)len);
1091-
snprintf(buf2,sizeof(buf2),INT64_FORMAT, (int64)th->pos);
1093+
snprintf(buf2,sizeof(buf2),INT64_FORMAT, (int64)th->fileLen);
10921094
die_horribly(AH,modulename,"actual file length (%s) does not match expected (%s)\n",
10931095
buf1,buf2);
10941096
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp