autotools: stop setting -std=gnu89 with --enable-warnings

Do not alter the C standard when building with `--enable-warnings` when
building with gcc.

On one hand this alters warning results compared to a default build.
On the other, it may produce different binaries, which is unexpected.

Also fix new warnings that appeared after removing `-std=gnu89`:

- include: fix public curl headers to use the correct printf mask for
  `CURL_FORMAT_CURL_OFF_T` and `CURL_FORMAT_CURL_OFF_TU` with mingw-w64
  and Visual Studio 2013 and newer. This fixes the printf mask warnings
  in examples and tests. E.g. [1]

- conncache: fix printf format string [2].

- http2: fix potential null pointer dereference [3].
  (seen on Slackware with gcc 11.)

- libssh: fix printf format string in SFTP code [4].
  Also make MSVC builds compatible with old CRT versions.

- libssh2: fix printf format string in SFTP code for MSVC.
  Applying the same fix as for libssh above.

- unit1395: fix `argument is null` and related issues [5]:
  - stop calling `strcmp()` with NULL to avoid undefined behaviour.
  - fix checking results if some of them were NULL.
  - do not pass NULL to printf `%s`.

- ci: keep a build job with `-std=gnu89` to continue testing for
  C89-compliance. We can apply this to other gcc jobs as needed.
  Ref: b23ce2cee7 (2022-09-23) #9542

[1] https://dev.azure.com/daniel0244/curl/_build/results?buildId=18581&view=logs&jobId=ccf9cc6d-2ef1-5cf2-2c09-30f0c14f923b
[2] https://github.com/curl/curl/actions/runs/6896854263/job/18763831142?pr=12346#step:6:67
[3] https://github.com/curl/curl/actions/runs/6896854253/job/18763839238?pr=12346#step:30:214
[4] https://github.com/curl/curl/actions/runs/6896854253/job/18763838007?pr=12346#step:29:895
[5] https://github.com/curl/curl/actions/runs/6896854253/job/18763836775?pr=12346#step:33:1689

Closes #12346
This commit is contained in:
Viktor Szakats 2023-11-16 21:44:45 +00:00
parent 95231921b2
commit 413a0fedd0
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
8 changed files with 59 additions and 27 deletions

View file

@ -1160,13 +1160,23 @@ static CURLcode myssh_statemach_act(struct Curl_easy *data, bool *block)
break;
}
else if(statvfs) {
#ifdef _MSC_VER
#define LIBSSH_VFS_SIZE_MASK "I64u"
#else
#define LIBSSH_VFS_SIZE_MASK PRIu64
#endif
char *tmp = aprintf("statvfs:\n"
"f_bsize: %llu\n" "f_frsize: %llu\n"
"f_blocks: %llu\n" "f_bfree: %llu\n"
"f_bavail: %llu\n" "f_files: %llu\n"
"f_ffree: %llu\n" "f_favail: %llu\n"
"f_fsid: %llu\n" "f_flag: %llu\n"
"f_namemax: %llu\n",
"f_bsize: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_frsize: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_blocks: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_bfree: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_bavail: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_files: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_ffree: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_favail: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_fsid: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_flag: %" LIBSSH_VFS_SIZE_MASK "\n"
"f_namemax: %" LIBSSH_VFS_SIZE_MASK "\n",
statvfs->f_bsize, statvfs->f_frsize,
statvfs->f_blocks, statvfs->f_bfree,
statvfs->f_bavail, statvfs->f_files,

View file

@ -1962,13 +1962,23 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
break;
}
else if(rc == 0) {
#ifdef _MSC_VER
#define LIBSSH2_VFS_SIZE_MASK "I64u"
#else
#define LIBSSH2_VFS_SIZE_MASK "llu"
#endif
char *tmp = aprintf("statvfs:\n"
"f_bsize: %llu\n" "f_frsize: %llu\n"
"f_blocks: %llu\n" "f_bfree: %llu\n"
"f_bavail: %llu\n" "f_files: %llu\n"
"f_ffree: %llu\n" "f_favail: %llu\n"
"f_fsid: %llu\n" "f_flag: %llu\n"
"f_namemax: %llu\n",
"f_bsize: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_frsize: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_blocks: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_bfree: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_bavail: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_files: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_ffree: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_favail: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_fsid: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_flag: %" LIBSSH2_VFS_SIZE_MASK "\n"
"f_namemax: %" LIBSSH2_VFS_SIZE_MASK "\n",
statvfs.f_bsize, statvfs.f_frsize,
statvfs.f_blocks, statvfs.f_bfree,
statvfs.f_bavail, statvfs.f_files,