]> Kevux Git Server - fll/commit
Bugfix: Invalid seeked value on failure in f_file_seek().
authorKevin Day <Kevin@kevux.org>
Wed, 4 Mar 2026 04:41:14 +0000 (22:41 -0600)
committerKevin Day <Kevin@kevux.org>
Wed, 4 Mar 2026 04:44:51 +0000 (22:44 -0600)
commit6dc28ff5673c86d8d6042b47538c2f66e7726717
treed86e24a0f5fef83d7f22032fb62453c8afd31390
parentebc4fe1b840064f7ca13ceb161c3c0079a910649
Bugfix: Invalid seeked value on failure in f_file_seek().

The `lseek()` can return a negative value.

Use a local variable to get the `lseek()` value.
This then allows for the `seeked` to be NULL.

Change the `seeked` parameter to be optional and when set to NULL then it is not assigned.
This neither breaks API nor ABI.

The `seeked` value is only assigned when the result is `-1`.
The POSIX standard is inconsistent about negative return values.
In the case of `lseek()`, only `-1` is technically an error.
level_0/f_file/c/file.c
level_0/f_file/c/file.h
level_0/f_file/data/documentation/man/man3/f_file_seek.3
level_0/f_file/tests/unit/c/test-file-seek.c