os: Cleaned up the log functions and handled return values.
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.
Related to #508.
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.
@stefan11111 What do you think?
this here seems to fix the log.c codeql alert i gave up on previously great work
@X11Libre/reviewers
@b-aaz needs conflict resolution
@b-aaz ping
@b-aaz needs rebase
@b-aaz ping
Will fix this tomorrow.
Done. What do you think? @metux @cepelinas9000
@cepelinas9000 What do you think?
I'll change this to what the consensus decides.
I vote for trying stdout too, but not killing the server on failure.