]> git.ipfire.org Git - thirdparty/curl.git/commit
lib: prefer `var = time(NULL)` over `time(&var)`
authorViktor Szakats <commit@vsz.me>
Tue, 28 May 2024 14:16:01 +0000 (16:16 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 29 May 2024 19:45:28 +0000 (21:45 +0200)
commit3b9569c3e2b6c35c915a1760a71c3434e570f49c
treeb3c766afbec6123d3d7a84cf94ddafdcf7978d75
parent0b520e125081096f174788cc599d49b19796e6d8
lib: prefer `var = time(NULL)` over `time(&var)`

Following up on previous occurrences showing up as gcc warnings, replace
the remaining `time(&var)` calls with `var = time(NULL)`, though these
aren't specifically causing compiler warnings. These are in the TFTP
client code (`lib/tftp.c`), except one which is in a debug branch in
`lib/http_aws_sigv4.c`.

What's unexplainable is that this patch seems to mitigate TFTP tests
often hanging or going into an infinite loop on GHA windows workflows
with MSYS2, mingw-w64 and MSVC (Cygwin is unaffected):
  https://github.com/curl/curl/pull/13599#issuecomment-2119372376
TFTP hangs did not entirely disappear though, so could be unrelated.

`time()` docs:
https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/time-time32-time64
https://manpages.debian.org/bookworm/manpages-dev/time.2.en.html

Follow-up to 58ca0a2f0743a586716ca357c382b29e3f08db69 #13800
Follow-up to d0728c9109629ee82b855b350a4c3f1f52ee61df #13643
Closes #13815
lib/http_aws_sigv4.c
lib/tftp.c