Skip to content

Commit

Permalink
bug: Changing typedef for offset_t to oscoffset_t
Browse files Browse the repository at this point in the history
Solaris/Illumos have an offset_t type already so this causes a conflict.
Changing our typedef to oscoffset_t to workaround this.

[Seagate/openSeaChest#165]

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
  • Loading branch information
vonericsen committed Oct 30, 2024
1 parent 7f5f827 commit 9862e3d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions include/common_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ extern "C"
typedef unsigned short mode_t;
typedef short nlink_t;
//using our own "type" to make sure we can get as much of the filesize as possible..and workaround Windows issues with off_t -TJE
typedef int64_t offset_t;//NOTE: WinAPI uses __int64_t which is the same as long long which is also what int64_t from stdint.h is defined as
typedef int64_t oscoffset_t;//NOTE: WinAPI uses __int64_t which is the same as long long which is also what int64_t from stdint.h is defined as
typedef unsigned long winsyserror_t;
#else
//using our own "type" to make sure we can get as much of the filesize as possible..and workaround Windows issues with off_t -TJE
typedef off_t offset_t;//to deal with windows differences in off_t definitions in stat
typedef off_t oscoffset_t;//to deal with windows differences in off_t definitions in stat
#endif

#if !defined (HAVE_C11_ANNEX_K) && !defined(__STDC_SECURE_LIB__)
Expand Down
6 changes: 3 additions & 3 deletions include/secure_file.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ extern "C"
uid_t userID;
gid_t groupID;
dev_t representedDeviceID;
offset_t filesize;
oscoffset_t filesize;
int64_t fileLastAccessTime;//milliseconds since Unix epoch (in Windows, converted from Windows file epoch to this value)
int64_t fileModificationTime;//milliseconds since Unix epoch (in Windows, converted from Windows file epoch to this value)
int64_t fileStatusChangeTime;//milliseconds since Unix epoch (in Windows, converted from Windows file epoch to this value)
Expand Down Expand Up @@ -201,9 +201,9 @@ extern "C"

M_NODISCARD eSecureFileError secure_Read_File(secureFileInfo* M_RESTRICT fileInfo, void* M_RESTRICT buffer, size_t buffersize, size_t elementsize, size_t count, size_t* numberread/*optional*/);
M_NODISCARD eSecureFileError secure_Write_File(secureFileInfo* M_RESTRICT fileInfo, void* M_RESTRICT buffer, size_t buffersize, size_t elementsize, size_t count, size_t* numberwritten/*optional*/);
M_NODISCARD eSecureFileError secure_Seek_File(secureFileInfo* fileInfo, offset_t offset, int initialPosition);
M_NODISCARD eSecureFileError secure_Seek_File(secureFileInfo* fileInfo, oscoffset_t offset, int initialPosition);
M_NODISCARD eSecureFileError secure_Rewind_File(secureFileInfo* fileInfo);
M_NODISCARD offset_t secure_Tell_File(secureFileInfo* fileInfo);
M_NODISCARD oscoffset_t secure_Tell_File(secureFileInfo* fileInfo);

//This function will unlink the file if it is still open, otherwise it will remove it.
M_NODISCARD eSecureFileError secure_Remove_File(secureFileInfo* fileInfo);
Expand Down
6 changes: 3 additions & 3 deletions src/secure_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ M_NODISCARD eSecureFileError secure_Write_File(secureFileInfo* M_RESTRICT fileIn
return SEC_FILE_INVALID_SECURE_FILE;
}

M_NODISCARD eSecureFileError secure_Seek_File(secureFileInfo* fileInfo, offset_t offset, int initialPosition)
M_NODISCARD eSecureFileError secure_Seek_File(secureFileInfo* fileInfo, oscoffset_t offset, int initialPosition)
{
if (fileInfo)
{
Expand Down Expand Up @@ -773,7 +773,7 @@ M_NODISCARD eSecureFileError secure_Rewind_File(secureFileInfo* fileInfo)
return SEC_FILE_INVALID_SECURE_FILE;
}

M_NODISCARD offset_t secure_Tell_File(secureFileInfo* fileInfo)
M_NODISCARD oscoffset_t secure_Tell_File(secureFileInfo* fileInfo)
{
if (fileInfo)
{
Expand All @@ -784,7 +784,7 @@ M_NODISCARD offset_t secure_Tell_File(secureFileInfo* fileInfo)
fileInfo->error = SEC_FILE_INVALID_FILE;
if (fileInfo->file)
{
offset_t tellres = 0;
oscoffset_t tellres = 0;
//Windows has _fseeki64, which may be better to use instead for larger files or to be compatible with larger files.
//Linux/posix have fseeko and ftello which use off_t which can be wider as well. (POSIX 2001)
errno = 0;//ISO secure coding standard recommends this to ensure errno is interpretted correctly after this call
Expand Down

0 comments on commit 9862e3d

Please sign in to comment.