build: tidy up local lseek() mappings

- stop redefining system symbol `lseek`, by introducing `curl_lseek()`.
- handle AmigaOS quirk within the macro mapping.
- add missing parenthesis to `LSEEK_ERROR` values.
- tool_util: use curl `lseek` macros in `tool_ftruncate64()`.
- move `LSEEK_ERROR` to right-hand side of if expressions.
- checksrc: disallow direct uses of `_lseeki64`, `llseek`, `lseek`.

Closes #20488
This commit is contained in:
Viktor Szakats 2026-02-01 01:04:58 +01:00
parent 47734f3244
commit 96fa42c7c0
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
7 changed files with 24 additions and 27 deletions

View file

@ -61,13 +61,13 @@ int tool_seek_cb(void *userdata, curl_off_t offset, int whence)
/* this code path does not support other types */
return CURL_SEEKFUNC_FAIL;
if(LSEEK_ERROR == lseek(per->infd, 0, SEEK_SET))
if(curl_lseek(per->infd, 0, SEEK_SET) == LSEEK_ERROR)
/* could not rewind to beginning */
return CURL_SEEKFUNC_FAIL;
while(left) {
long step = (left > OUR_MAX_SEEK_O) ? OUR_MAX_SEEK_L : (long)left;
if(LSEEK_ERROR == lseek(per->infd, step, SEEK_CUR))
if(curl_lseek(per->infd, step, SEEK_CUR) == LSEEK_ERROR)
/* could not seek forwards the desired amount */
return CURL_SEEKFUNC_FAIL;
left -= step;
@ -76,11 +76,7 @@ int tool_seek_cb(void *userdata, curl_off_t offset, int whence)
}
#endif
#ifdef __AMIGA__
if(LSEEK_ERROR == lseek(per->infd, (off_t)offset, whence))
#else
if(LSEEK_ERROR == lseek(per->infd, offset, whence))
#endif
if(curl_lseek(per->infd, offset, whence) == LSEEK_ERROR)
/* could not rewind, the reason is in errno but errno is just not portable
enough and we do not actually care that much why we failed. We will let
libcurl know that it may try other means if it wants to. */

View file

@ -86,7 +86,7 @@ int tool_ftruncate64(int fd, curl_off_t where)
{
intptr_t handle = _get_osfhandle(fd);
if(_lseeki64(fd, where, SEEK_SET) < 0)
if(curl_lseek(fd, where, SEEK_SET) == LSEEK_ERROR)
return -1;
if(!SetEndOfFile((HANDLE)handle))