Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d4f1ba

Browse files
committed
Update types in File API
Make the argument types of the File API match stdio better: - Change the data buffer to void *, from char *. - Change FileWrite() data buffer to const on top of that. - Change amounts to size_t, from int. In passing, change the FilePrefetch() amount argument from int to off_t, to match the underlying posix_fadvise(). Discussion: https://www.postgresql.org/message-id/flat/11dda853-bb5b-59ba-a746-e168b1ce4bdb%40enterprisedb.com
1 parent 4b3e379 commit 2d4f1ba

File tree

2 files changed

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

2 files changed

+7
-7
lines changed

src/backend/storage/file/fd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@ FileClose(File file)
19801980
* to read into.
19811981
*/
19821982
int
1983-
FilePrefetch(File file, off_t offset, int amount, uint32 wait_event_info)
1983+
FilePrefetch(File file, off_t offset, off_t amount, uint32 wait_event_info)
19841984
{
19851985
#if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_WILLNEED)
19861986
int returnCode;
@@ -2031,15 +2031,15 @@ FileWriteback(File file, off_t offset, off_t nbytes, uint32 wait_event_info)
20312031
}
20322032

20332033
int
2034-
FileRead(File file, char *buffer, int amount, off_t offset,
2034+
FileRead(File file, void *buffer, size_t amount, off_t offset,
20352035
uint32 wait_event_info)
20362036
{
20372037
int returnCode;
20382038
Vfd *vfdP;
20392039

20402040
Assert(FileIsValid(file));
20412041

2042-
DO_DB(elog(LOG, "FileRead: %d (%s) " INT64_FORMAT " %d %p",
2042+
DO_DB(elog(LOG, "FileRead: %d (%s) " INT64_FORMAT " %zu %p",
20432043
file, VfdCache[file].fileName,
20442044
(int64) offset,
20452045
amount, buffer));
@@ -2087,7 +2087,7 @@ FileRead(File file, char *buffer, int amount, off_t offset,
20872087
}
20882088

20892089
int
2090-
FileWrite(File file, char *buffer, int amount, off_t offset,
2090+
FileWrite(File file, const void *buffer, size_t amount, off_t offset,
20912091
uint32 wait_event_info)
20922092
{
20932093
int returnCode;

src/include/storage/fd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ extern File PathNameOpenFile(const char *fileName, int fileFlags);
102102
extern File PathNameOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode);
103103
extern File OpenTemporaryFile(bool interXact);
104104
extern void FileClose(File file);
105-
extern int FilePrefetch(File file, off_t offset, int amount, uint32 wait_event_info);
106-
extern int FileRead(File file, char *buffer, int amount, off_t offset, uint32 wait_event_info);
107-
extern int FileWrite(File file, char *buffer, int amount, off_t offset, uint32 wait_event_info);
105+
extern int FilePrefetch(File file, off_t offset, off_t amount, uint32 wait_event_info);
106+
extern int FileRead(File file, void *buffer, size_t amount, off_t offset, uint32 wait_event_info);
107+
extern int FileWrite(File file, const void *buffer, size_t amount, off_t offset, uint32 wait_event_info);
108108
extern int FileSync(File file, uint32 wait_event_info);
109109
extern off_t FileSize(File file);
110110
extern int FileTruncate(File file, off_t offset, uint32 wait_event_info);

0 commit comments

Comments
 (0)