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

Commit653b55b

Browse files
committed
Return ssize_t in fd.c I/O functions.
In the past, FileRead() and FileWrite() used types based on the Unixread() and write() functions from before C and POSIX standardization,though not exactly (we had int for amount instead of unsigned). Incommit2d4f1ba we changed to the appropriate standard C types, justlike the modern POSIX functions they wrap, but again not exactly: thereturn type stayed as int. In theory, a ssize_t value could be returnedby the underlying call that is too large for an int.That wasn't really a live bug, because we don't expect PostgreSQL codeto perform reads or writes of gigabytes, and OSes probably applyinternal caps smaller than that anyway. This change is done on theprinciple that the return might as well follow the standard interfacesconsistently.Reported-by: Tom Lane <tgl@sss.pgh.pa.us>Reviewed-by: Peter Eisentraut <peter@eisentraut.org>Discussion:https://postgr.es/m/1672202.1703441340%40sss.pgh.pa.us
1 parent655dc31 commit653b55b

File tree

2 files changed

+8
-8
lines changed
  • src
    • backend/storage/file
    • include/storage

2 files changed

+8
-8
lines changed

‎src/backend/storage/file/fd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2132,11 +2132,11 @@ FileWriteback(File file, off_t offset, off_t nbytes, uint32 wait_event_info)
21322132
pgstat_report_wait_end();
21332133
}
21342134

2135-
int
2135+
ssize_t
21362136
FileReadV(Filefile,conststructiovec*iov,intiovcnt,off_toffset,
21372137
uint32wait_event_info)
21382138
{
2139-
intreturnCode;
2139+
ssize_treturnCode;
21402140
Vfd*vfdP;
21412141

21422142
Assert(FileIsValid(file));
@@ -2188,11 +2188,11 @@ FileReadV(File file, const struct iovec *iov, int iovcnt, off_t offset,
21882188
returnreturnCode;
21892189
}
21902190

2191-
int
2191+
ssize_t
21922192
FileWriteV(Filefile,conststructiovec*iov,intiovcnt,off_toffset,
21932193
uint32wait_event_info)
21942194
{
2195-
intreturnCode;
2195+
ssize_treturnCode;
21962196
Vfd*vfdP;
21972197

21982198
Assert(FileIsValid(file));

‎src/include/storage/fd.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ extern File PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fil
107107
externFileOpenTemporaryFile(boolinterXact);
108108
externvoidFileClose(Filefile);
109109
externintFilePrefetch(Filefile,off_toffset,off_tamount,uint32wait_event_info);
110-
externintFileReadV(Filefile,conststructiovec*ioc,intiovcnt,off_toffset,uint32wait_event_info);
111-
externintFileWriteV(Filefile,conststructiovec*ioc,intiovcnt,off_toffset,uint32wait_event_info);
110+
externssize_tFileReadV(Filefile,conststructiovec*ioc,intiovcnt,off_toffset,uint32wait_event_info);
111+
externssize_tFileWriteV(Filefile,conststructiovec*ioc,intiovcnt,off_toffset,uint32wait_event_info);
112112
externintFileSync(Filefile,uint32wait_event_info);
113113
externintFileZero(Filefile,off_toffset,off_tamount,uint32wait_event_info);
114114
externintFileFallocate(Filefile,off_toffset,off_tamount,uint32wait_event_info);
@@ -192,7 +192,7 @@ extern intdurable_unlink(const char *fname, int elevel);
192192
externvoidSyncDataDirectory(void);
193193
externintdata_sync_elevel(intelevel);
194194

195-
staticinlineint
195+
staticinlinessize_t
196196
FileRead(Filefile,void*buffer,size_tamount,off_toffset,
197197
uint32wait_event_info)
198198
{
@@ -204,7 +204,7 @@ FileRead(File file, void *buffer, size_t amount, off_t offset,
204204
returnFileReadV(file,&iov,1,offset,wait_event_info);
205205
}
206206

207-
staticinlineint
207+
staticinlinessize_t
208208
FileWrite(Filefile,constvoid*buffer,size_tamount,off_toffset,
209209
uint32wait_event_info)
210210
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp