mirror of
https://github.com/curl/curl.git
synced 2026-04-12 00:11:42 +08:00
Extend `#pragma diagnostic push`/`pop` guards to the whole codebase
(from tests and examples only) to disable it for GCC <4.6. Rename guard
to `CURL_HAVE_DIAG` and make it include llvm/clang to be interchangeable
with `__GNUC__ || __clang__` in this context.
The above means no longer disabling certain warnings locally, so pair
this with disabling all picky warnings for GCC <4.6.
Also:
- drop global workarounds for misbehaving GCC <4.6 compiler warnings.
Not needed with picky warnings disabled.
Reported-by: fds242 on github
Reported-by: Sergey Fedorov
Thanks-to: Orgad Shaneh
Follow-up to f07a98ae11 #20366
Fixes #20892
Fixes #20924
Closes #20902
Closes #20907
50 lines
1.7 KiB
C
50 lines
1.7 KiB
C
/***************************************************************************
|
|
* _ _ ____ _
|
|
* 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
|
|
*
|
|
***************************************************************************/
|
|
#include "curlx/snprintf.h"
|
|
|
|
#ifdef _WIN32
|
|
#include <stdarg.h>
|
|
|
|
/* Simplified wrapper for the Windows platform to use the correct symbol and
|
|
ensuring null-termination. Omit returning a length to keep it simple. */
|
|
void curlx_win32_snprintf(char *buf, size_t maxlen, const char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
if(!maxlen)
|
|
return;
|
|
va_start(ap, fmt);
|
|
#ifdef CURL_HAVE_DIAG
|
|
#pragma GCC diagnostic push
|
|
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
|
|
#endif
|
|
/* !checksrc! disable BANNEDFUNC 1 */
|
|
(void)vsnprintf(buf, maxlen, fmt, ap);
|
|
#ifdef CURL_HAVE_DIAG
|
|
#pragma GCC diagnostic pop
|
|
#endif
|
|
buf[maxlen - 1] = 0;
|
|
va_end(ap);
|
|
}
|
|
#endif /* _WIN32 */
|