]> www.infradead.org Git - users/dwmw2/openconnect.git/commit
Get rid of the trailing new line added by ctime()
authorDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Mon, 24 Apr 2023 12:56:55 +0000 (15:56 +0300)
committerDimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
Sat, 30 Sep 2023 08:50:09 +0000 (10:50 +0200)
commit5ab279fb03acde7edfb8d3c780c2f0240c2f4cb7
tree45e940ebfb8f38fd1194d2acfcf296b6680fcfe1
parent07a4dd2476d672e07243e87210bf90533c604eb4
Get rid of the trailing new line added by ctime()

From the POSIX documentation of ctime:
The ctime() function shall convert the time pointed to
by clock [...] to local time in the form of a string.
It shall be equivalent to:

        asctime(localtime(clock))

From the POSIX documentation of asctime:
The asctime() function shall convert the broken-down time
in the structure pointed to by timeptr into a string in the
form:

Sun Sep 16 01:03:52 1973\n\0

We need to get rid of that new line otherwise it appears in the log.

The POSIX documentation goes on:
These functions are included only for compatibility with older
implementations. They have undefined behavior if the resulting
string would be too long, so the use of these functions should
be discouraged. On implementations that do not detect output
string length overflow, it is possible to overflow the output
buffers in such a way as to cause applications to fail, or
possible system security violations. Also, these functions do
not support localized date and time formats. To avoid these
problems, applications should use strftime() to generate
strings from broken-down times.

Because we have already been using strftime() with gmtime() elsewhere,
using strftime() with locatime() here makes sense.

The i1On mechanisme we currently use to print dates is non-sensical:
we force the format string to "%a, %d %b %Y %H:%M:%S" which might not
make sense in some locales. We shall fix i10n in a different merge
request or commit.

Signed-off-by: Dimitri Papadopoulos <3350651-DimitriPapadopoulos@users.noreply.gitlab.com>
main.c