xserver icon indicating copy to clipboard operation
xserver copied to clipboard

os: Cleaned up the log functions and handled return values.

Open b-aaz opened this issue 4 months ago • 8 comments

The old function used int for write() return values, that could overflow. And the return values of the write calls were discarded and not checked.

Now if the write() to the log file fails, a warning will be logged to stderr and the log message will be appended after the warning.

If writes to stderr fail the server will abort.

Also used the length returned by strftime for the next write call to eliminate an extra use of strlen.

The -1 was also removed from the buflen argument of strftime because it was unnecessary.

Did some small formatting changes too.

b-aaz avatar Aug 05 '25 12:08 b-aaz

Related to #508.

b-aaz avatar Aug 05 '25 12:08 b-aaz

I know the build fails on mingw32. It is caused by strerror_r not being available on mingw32. But IMHO we should dump mingw32 and use something that can provide a sane POSIX and C foundation (i.e. Cygwin) instead of twisting our code to work with it's lacking features.

b-aaz avatar Aug 05 '25 13:08 b-aaz

@stefan11111 What do you think?

b-aaz avatar Aug 05 '25 18:08 b-aaz

this here seems to fix the log.c codeql alert i gave up on previously great work

HaplessIdiot avatar Aug 05 '25 23:08 HaplessIdiot

@X11Libre/reviewers

metux avatar Sep 05 '25 13:09 metux

@b-aaz needs conflict resolution

metux avatar Sep 24 '25 10:09 metux

@b-aaz ping

metux avatar Sep 26 '25 15:09 metux

@b-aaz needs rebase

metux avatar Nov 26 '25 16:11 metux

@b-aaz ping

cepelinas9000 avatar Dec 04 '25 17:12 cepelinas9000

Will fix this tomorrow.

b-aaz avatar Dec 04 '25 22:12 b-aaz

Done. What do you think? @metux @cepelinas9000

b-aaz avatar Dec 05 '25 06:12 b-aaz

@cepelinas9000 What do you think?

I'll change this to what the consensus decides.

b-aaz avatar Dec 05 '25 16:12 b-aaz

I vote for trying stdout too, but not killing the server on failure.

stefan11111 avatar Dec 05 '25 16:12 stefan11111