Skip to content

lib: fix gcc warning in certain debug builds#13800

Closed
vszakats wants to merge 1 commit intocurl:masterfrom
vszakats:lib-gcc-warn-debug
Closed

lib: fix gcc warning in certain debug builds#13800
vszakats wants to merge 1 commit intocurl:masterfrom
vszakats:lib-gcc-warn-debug

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented May 27, 2024

curl/lib/http_aws_sigv4.c:536:10: error: 'clock' may be used uninitialized [-Werror=maybe-uninitialized]
  536 |   time_t clock;
      |          ^~~~~

Ref: https://github.com/curl/curl/actions/runs/9158755123/job/25177765000#step:13:79

Cherry-picked from #13718
Closes #13800

```
curl/lib/http_aws_sigv4.c:536:10: error: 'clock' may be used uninitialized [-Werror=maybe-uninitialized]
  536 |   time_t clock;
      |          ^~~~~
```
Ref: https://github.com/curl/curl/actions/runs/9158755123/job/25177765000#step:13:79

Closes #xxxxx
@vszakats vszakats added the build label May 27, 2024
@vszakats vszakats closed this in 58ca0a2 May 27, 2024
@vszakats vszakats deleted the lib-gcc-warn-debug branch May 27, 2024 20:29
vszakats added a commit that referenced this pull request May 27, 2024
…uilds

It affected cmake-unity shared-curltool curldebug mingw-w64 gcc builds
when building the `testdeps` target.

Apply the solution already used in `lib/base64.c` and `lib/dynbuf.c`
to fix it.

Also update an existing GHA CI job to test the issue fixed.

```
In file included from curl/lib/version_win32.c:35,
                 from curl/_bld/src/CMakeFiles/curl.dir/Unity/unity_0_c.c:145:
curl/lib/memdebug.h:52:14: error: redundant redeclaration of 'curl_dbg_logfile' [-Werror=redundant-decls]
   52 | extern FILE *curl_dbg_logfile;
      |              ^~~~~~~~~~~~~~~~
In file included from curl/src/slist_wc.c:32,
                 from curl/_bld/src/CMakeFiles/curl.dir/Unity/unity_0_c.c:4:
curl/lib/memdebug.h:52:14: note: previous declaration of 'curl_dbg_logfile' with type 'FILE *' {aka 'struct _iobuf *'}
   52 | extern FILE *curl_dbg_logfile;
      |              ^~~~~~~~~~~~~~~~
curl/lib/memdebug.h:55:44: error: redundant redeclaration of 'curl_dbg_malloc' [-Werror=redundant-decls]
   55 | CURL_EXTERN ALLOC_FUNC ALLOC_SIZE(1) void *curl_dbg_malloc(size_t size,
      |                                            ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:55:44: note: previous declaration of 'curl_dbg_malloc' with type 'void *(size_t,  int,  const char *)' {aka 'void *(long long unsigned int,  int,  const char *)'}
   55 | CURL_EXTERN ALLOC_FUNC ALLOC_SIZE(1) void *curl_dbg_malloc(size_t size,
      |                                            ^~~~~~~~~~~~~~~
[...]
curl/lib/memdebug.h:110:17: error: redundant redeclaration of 'curl_dbg_fclose' [-Werror=redundant-decls]
  110 | CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
      |                 ^~~~~~~~~~~~~~~
curl/lib/memdebug.h:110:17: note: previous declaration of 'curl_dbg_fclose' with type 'int(FILE *, int,  const char *)' {aka 'int(struct _iobuf *, int,  const char *)'}
  110 | CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
      |                 ^~~~~~~~~~~~~~~
```
Ref: https://ci.appveyor.com/project/curlorg/curl/builds/49840554/job/a4aoet17e9qnqx1a#L362

After: https://ci.appveyor.com/project/curlorg/curl/builds/49843735/job/hbo2uah2vj0ns523

Ref: #13689 (CI testing this PR with `DEBUGBUILD`/`CURLDEBUG`/shared-static combinations)
Depends-on: #13694
Depends-on: #13800
Closes #13705
vszakats added a commit to vszakats/curl that referenced this pull request May 28, 2024
Following up on previous occurrences showing up as gcc warnings, replace
the remaining few `time(&var)` calls with `= time(NULL)`, though these
aren't specifically causing compiler warnings. All of these are in the
TFTP client code (`lib/tftp.c`), except one which is in a debug branch
in `lib/http_aws_sigv4`.

What's unexplainable is that this patch seems to stabilize the TFTP
tests regularly hanging or going into an infinite loop on GHA windows
workflows with MSYS2, mingw-w64 and MSVC (Cygwin is unaffected):
  curl#13599 (comment)

I figure it's something worth trying even if it turns out to be a dead
end.

`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 58ca0a2 curl#13800
Follow-up to d0728c9 curl#13643
Closes #xxxxx
vszakats added a commit that referenced this pull request May 29, 2024
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):
  #13599 (comment)
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 58ca0a2 #13800
Follow-up to d0728c9 #13643
Closes #13815
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant