Fix or silence compiler warnings happening in feature detections to reduce log noise. Warnings may also get promoted to errors in certain cases, causing missed detections. It reduces the number of warnings by 4500+ across the linux, linux-old, macos, non-native and windows GHA workflows (~142 jobs). Also move picky warning logic for MSVC/Borland to `CMake/PickyWarnings.cmake. To make them listed in the picky-warnings log output, and to also apply to feature detections to make them compile under the same conditions as source code. The hope is to help catching issues faster. It also improves code quality of feature tests. Fixed/silenced: ``` warning #177: variable "dummy" was declared but never referenced warning #177: variable "flag" was declared but never referenced warning #177: variable "res" was declared but never referenced warning #592: variable "s" is used before its value is set warning #1011: missing return statement at end of non-void function "main" warning #1786: function "SSL_CTX_set_srp_password" (declared at line 1888 of "/usr/include/openssl/ssl.h") was declared deprecated ("Since OpenSSL 3.0") warning #1786: function "SSL_CTX_set_srp_username" (declared at line 1887 of "/usr/include/openssl/ssl.h") was declared deprecated ("Since OpenSSL 3.0") warning #2332: a value of type "const char *" cannot be assigned to an entity of type "char *" (dropping qualifiers) warning: 'SSL_CTX_set_srp_password' is deprecated [-Wdeprecated-declarations] warning: 'SSL_CTX_set_srp_password' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations] warning: 'SSL_CTX_set_srp_username' is deprecated [-Wdeprecated-declarations] warning: 'SSL_CTX_set_srp_username' is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations] warning: 'b' is used uninitialized [-Wuninitialized] warning: 'gethostname' redeclared without dllimport attribute: previous dllimport ignored [-Wattributes] warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn] warning: Value stored to 'i' is never read [deadcode.DeadStores] warning: assigning to 'char *' from 'const char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] warning: control reaches end of non-void function [-Wreturn-type] warning: empty expression statement has no effect; remove unnecessary ';' to silence this warning [-Wextra-semi-stmt] warning: excess elements in struct initializer warning: initialization discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] warning: macro "_FILE_OFFSET_BITS" is not used [-Wunused-macros] warning: macro "_REENTRANT" is not used [-Wunused-macros] warning: missing braces around initializer [-Wmissing-braces] warning: no previous extern declaration for non-static variable 'off_t_is_large' [-Wmissing-variable-declarations] warning: no previous prototype for 'check' [-Wmissing-prototypes] warning: no previous prototype for function 'check' [-Wmissing-prototypes] warning: null argument where non-null required (argument 2) [-Wnonnull] warning: passing 'const char[1]' to parameter of type 'char *' discards qualifiers [-Wincompatible-pointer-types-discards-qualifiers] warning: passing argument 2 of 'SSL_CTX_set_srp_password' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] warning: passing argument 2 of 'SSL_CTX_set_srp_username' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers] warning: unused parameter 'c' [-Wunused-parameter] warning: unused parameter 'f' [-Wunused-parameter] warning: unused variable 'data' [-Wunused-variable] warning: unused variable 'dummy' [-Wunused-variable] warning: unused variable 'flag' [-Wunused-variable] warning: unused variable 'res' [-Wunused-variable] warning: unused variable 's' [-Wunused-variable] warning: variable 's' set but not used [-Wunused-but-set-variable] warning: variable 'ts' set but not used [-Wunused-but-set-variable] ``` Closes #16287
98 lines
3.0 KiB
Plaintext
98 lines
3.0 KiB
Plaintext
#***************************************************************************
|
|
# _ _ ____ _
|
|
# Project ___| | | | _ \| |
|
|
# / __| | | | |_) | |
|
|
# | (__| |_| | _ <| |___
|
|
# \___|\___/|_| \_\_____|
|
|
#
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
|
#
|
|
# This software is licensed as described in the file COPYING, which
|
|
# you should have received as part of this distribution. The terms
|
|
# are also available at https://curl.se/docs/copyright.html.
|
|
#
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
#
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
# KIND, either express or implied.
|
|
#
|
|
# SPDX-License-Identifier: curl
|
|
#
|
|
###########################################################################
|
|
#***************************************************************************
|
|
#***************************************************************************
|
|
|
|
# File version for 'aclocal' use. Keep it a single number.
|
|
# serial 7
|
|
|
|
dnl CURL_OVERRIDE_AUTOCONF
|
|
dnl -------------------------------------------------
|
|
dnl Placing a call to this macro in configure.ac after
|
|
dnl the one to AC_INIT will make macros in this file
|
|
dnl visible to the rest of the compilation overriding
|
|
dnl those from Autoconf.
|
|
|
|
AC_DEFUN([CURL_OVERRIDE_AUTOCONF], [
|
|
AC_BEFORE([$0],[AC_PROG_LIBTOOL])
|
|
# using curl-override.m4
|
|
])
|
|
|
|
dnl Override Autoconf's AC_LANG_PROGRAM (C)
|
|
dnl -------------------------------------------------
|
|
dnl This is done to prevent compiler warning
|
|
dnl 'function declaration isn't a prototype'
|
|
dnl in function main. This requires at least
|
|
dnl a C89 compiler and does not support K&R.
|
|
|
|
m4_define([AC_LANG_PROGRAM(C)],
|
|
[$1
|
|
int main(void)
|
|
{
|
|
$2
|
|
return 0;
|
|
}])
|
|
|
|
dnl Override Autoconf's AC_LANG_CALL (C)
|
|
dnl -------------------------------------------------
|
|
dnl This is a backport of Autoconf's 2.60 with the
|
|
dnl embedded comments that hit the resulting script
|
|
dnl removed. This is done to reduce configure size
|
|
dnl and use fixed macro across Autoconf versions.
|
|
|
|
m4_define([AC_LANG_CALL(C)],
|
|
[AC_LANG_PROGRAM([$1
|
|
m4_if([$2], [main], ,
|
|
[
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
#endif
|
|
char $2 ();])], [return $2 ();])])
|
|
|
|
dnl Override Autoconf's AC_LANG_FUNC_LINK_TRY (C)
|
|
dnl -------------------------------------------------
|
|
dnl This is a backport of Autoconf's 2.60 with the
|
|
dnl embedded comments that hit the resulting script
|
|
dnl removed. This is done to reduce configure size
|
|
dnl and use fixed macro across Autoconf versions.
|
|
|
|
m4_define([AC_LANG_FUNC_LINK_TRY(C)],
|
|
[AC_LANG_PROGRAM(
|
|
[
|
|
#define $1 innocuous_$1
|
|
#ifdef __STDC__
|
|
# include <limits.h>
|
|
#else
|
|
# include <assert.h>
|
|
#endif
|
|
#undef $1
|
|
#ifdef __cplusplus
|
|
extern "C"
|
|
#endif
|
|
char $1 ();
|
|
#if defined __stub_$1 || defined __stub___$1
|
|
#error force compilation error
|
|
#endif
|
|
], [return $1 ();])])
|