mirror of
https://github.com/curl/curl.git
synced 2026-01-18 17:21:26 +01:00
checksrc: warn for leading spaces before the preprocessor hash
Fix the 40+ fallouts Closes #20282
This commit is contained in:
@@ -57,11 +57,11 @@
|
||||
#endif
|
||||
|
||||
#if defined(USE_OPENSSL) && defined(HAVE_DES_ECB_ENCRYPT)
|
||||
#define USE_OPENSSL_DES
|
||||
# define USE_OPENSSL_DES
|
||||
#elif defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT)
|
||||
#define USE_OPENSSL_DES
|
||||
# define USE_OPENSSL_DES
|
||||
#elif defined(USE_MBEDTLS) && defined(HAVE_MBEDTLS_DES_CRYPT_ECB)
|
||||
#define USE_MBEDTLS_DES
|
||||
# define USE_MBEDTLS_DES
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENSSL_DES
|
||||
|
||||
@@ -204,7 +204,7 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done)
|
||||
return CURLE_URL_MALFORMAT;
|
||||
}
|
||||
|
||||
#ifdef AMIGA_FILESYSTEM
|
||||
#ifdef AMIGA_FILESYSTEM
|
||||
/*
|
||||
* A leading slash in an AmigaDOS path denotes the parent
|
||||
* directory, and hence we block this as it is relative.
|
||||
@@ -227,10 +227,10 @@ static CURLcode file_connect(struct Curl_easy *data, bool *done)
|
||||
fd = curlx_open(real_path, O_RDONLY);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#else
|
||||
fd = curlx_open(real_path, O_RDONLY);
|
||||
file->path = real_path;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
curlx_free(file->freepath);
|
||||
file->freepath = real_path; /* free this when done */
|
||||
|
||||
@@ -233,19 +233,19 @@ CURLcode Curl_output_negotiate(struct Curl_easy *data,
|
||||
}
|
||||
|
||||
*state = GSS_AUTHSENT;
|
||||
#ifdef HAVE_GSSAPI
|
||||
#ifdef HAVE_GSSAPI
|
||||
if(neg_ctx->status == GSS_S_COMPLETE ||
|
||||
neg_ctx->status == GSS_S_CONTINUE_NEEDED) {
|
||||
*state = GSS_AUTHDONE;
|
||||
}
|
||||
#else
|
||||
#ifdef USE_WINDOWS_SSPI
|
||||
#else
|
||||
#ifdef USE_WINDOWS_SSPI
|
||||
if(neg_ctx->status == SEC_E_OK ||
|
||||
neg_ctx->status == SEC_I_CONTINUE_NEEDED) {
|
||||
*state = GSS_AUTHDONE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
if(*state == GSS_AUTHDONE || *state == GSS_AUTHSUCC) {
|
||||
|
||||
@@ -70,10 +70,10 @@
|
||||
#if defined(USE_WOLFSSL) && !defined(WOLFSSL_NO_MD4)
|
||||
|
||||
#ifdef OPENSSL_COEXIST
|
||||
#define MD4_CTX WOLFSSL_MD4_CTX
|
||||
#define MD4_Init wolfSSL_MD4_Init
|
||||
#define MD4_Update wolfSSL_MD4_Update
|
||||
#define MD4_Final wolfSSL_MD4_Final
|
||||
# define MD4_CTX WOLFSSL_MD4_CTX
|
||||
# define MD4_Init wolfSSL_MD4_Init
|
||||
# define MD4_Update wolfSSL_MD4_Update
|
||||
# define MD4_Final wolfSSL_MD4_Final
|
||||
#endif
|
||||
|
||||
#elif defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD4)
|
||||
|
||||
32
lib/md5.c
32
lib/md5.c
@@ -30,28 +30,28 @@
|
||||
#include "curl_hmac.h"
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
#include <openssl/opensslconf.h>
|
||||
#if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
#define USE_OPENSSL_MD5
|
||||
#endif
|
||||
#include <openssl/opensslconf.h>
|
||||
#if !defined(OPENSSL_NO_MD5) && !defined(OPENSSL_NO_DEPRECATED_3_0)
|
||||
#define USE_OPENSSL_MD5
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_WOLFSSL
|
||||
#include <wolfssl/options.h>
|
||||
#ifndef NO_MD5
|
||||
#define USE_WOLFSSL_MD5
|
||||
#endif
|
||||
#include <wolfssl/options.h>
|
||||
#ifndef NO_MD5
|
||||
#define USE_WOLFSSL_MD5
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_MBEDTLS
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#include <psa/crypto_config.h>
|
||||
#if defined(PSA_WANT_ALG_MD5) && PSA_WANT_ALG_MD5 /* mbedTLS 4+ */
|
||||
#define USE_MBEDTLS_MD5
|
||||
#endif
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#include <psa/crypto_config.h>
|
||||
#if defined(PSA_WANT_ALG_MD5) && PSA_WANT_ALG_MD5 /* mbedTLS 4+ */
|
||||
#define USE_MBEDTLS_MD5
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_GNUTLS
|
||||
|
||||
16
lib/sha256.c
16
lib/sha256.c
@@ -30,14 +30,14 @@
|
||||
#include "curl_sha256.h"
|
||||
|
||||
#ifdef USE_MBEDTLS
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#include <psa/crypto_config.h>
|
||||
#if defined(PSA_WANT_ALG_SHA_256) && PSA_WANT_ALG_SHA_256 /* mbedTLS 4+ */
|
||||
#define USE_MBEDTLS_SHA256
|
||||
#endif
|
||||
#include <mbedtls/version.h>
|
||||
#if MBEDTLS_VERSION_NUMBER < 0x03020000
|
||||
#error "mbedTLS 3.2.0 or later required"
|
||||
#endif
|
||||
#include <psa/crypto_config.h>
|
||||
#if defined(PSA_WANT_ALG_SHA_256) && PSA_WANT_ALG_SHA_256 /* mbedTLS 4+ */
|
||||
#define USE_MBEDTLS_SHA256
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_OPENSSL
|
||||
|
||||
@@ -2639,7 +2639,7 @@ static CURLcode cf_connect_start(struct Curl_cfilter *cf,
|
||||
#elif defined(USE_WOLFSSL)
|
||||
ngtcp2_conn_set_tls_native_handle(ctx->qconn, ctx->tls.wssl.ssl);
|
||||
#else
|
||||
#error "ngtcp2 TLS backend not defined"
|
||||
#error "ngtcp2 TLS backend not defined"
|
||||
#endif
|
||||
|
||||
ngtcp2_ccerr_default(&ctx->last_error);
|
||||
|
||||
@@ -751,11 +751,11 @@ static int myssh_in_SFTP_QUOTE_STATVFS(struct Curl_easy *data,
|
||||
return SSH_OK;
|
||||
}
|
||||
else if(statvfs) {
|
||||
#ifdef _MSC_VER
|
||||
#define CURL_LIBSSH_VFS_SIZE_MASK "I64u"
|
||||
#else
|
||||
#define CURL_LIBSSH_VFS_SIZE_MASK PRIu64
|
||||
#endif
|
||||
#ifdef _MSC_VER
|
||||
#define CURL_LIBSSH_VFS_SIZE_MASK "I64u"
|
||||
#else
|
||||
#define CURL_LIBSSH_VFS_SIZE_MASK PRIu64
|
||||
#endif
|
||||
CURLcode result = CURLE_OK;
|
||||
char *tmp = curl_maprintf("statvfs:\n"
|
||||
"f_bsize: %" CURL_LIBSSH_VFS_SIZE_MASK "\n"
|
||||
|
||||
@@ -152,6 +152,7 @@ my %warnings = (
|
||||
'COMMENTNOSPACESTART' => 'no space following /*',
|
||||
'COPYRIGHT' => 'file missing a copyright statement',
|
||||
'CPPCOMMENTS' => '// comment detected',
|
||||
"CPPSPACE" => 'space before preprocessor hash',
|
||||
'DOBRACE' => 'A single space between do and open brace',
|
||||
'EMPTYLINEBRACE' => 'Empty line before the open brace',
|
||||
'EQUALSNOSPACE' => 'equals sign without following space',
|
||||
@@ -672,6 +673,11 @@ sub scanfile {
|
||||
$includes{$path} = $l;
|
||||
}
|
||||
|
||||
# detect leading space before the hash
|
||||
if($l =~ /^([ \t]+)\#/) {
|
||||
checkwarn("CPPSPACE",
|
||||
$line, 0, $file, $l, "space before preprocessor hash");
|
||||
}
|
||||
# detect and strip preprocessor directives
|
||||
if($l =~ /^[ \t]*\#/) {
|
||||
# preprocessor line
|
||||
|
||||
@@ -218,6 +218,9 @@ void startfunc(int a, int b) {
|
||||
./%LOGDIR/code1185.c:65:1: warning: use ifdef/ifndef for single macro checks (IFDEFSINGLE)
|
||||
#if ! defined(__macro_10)
|
||||
^
|
||||
./%LOGDIR/code1185.c:65:1: warning: space before preprocessor hash (CPPSPACE)
|
||||
#if ! defined(__macro_10)
|
||||
^
|
||||
./%LOGDIR/code1185.c:71:2: warning: // comment (CPPCOMMENTS)
|
||||
// CPP comment ?
|
||||
^
|
||||
@@ -227,7 +230,7 @@ void startfunc(int a, int b) {
|
||||
./%LOGDIR/code1185.c:1:1: error: Missing closing comment (OPENCOMMENT)
|
||||
%SP
|
||||
^
|
||||
checksrc: 0 errors and 44 warnings
|
||||
checksrc: 0 errors and 45 warnings
|
||||
</stdout>
|
||||
<errorcode>
|
||||
5
|
||||
|
||||
Reference in New Issue
Block a user