summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Vatiainen <hvn@radiatorsoftware.com>2023-12-29 13:46:07 +0200
committerHeikki Vatiainen <hvn@radiatorsoftware.com>2023-12-29 15:34:25 +0200
commit001aa0a8871b5d9c0e05eeed9494861407fc27d3 (patch)
treea99fcea2089009638860ad24b4525fa6fc779fcb
parent7cef2af917cf9ca83209470a48d8a38b14fd1206 (diff)
GH-454 More fixes to address 'no code before declaration' warnings.
Fix additional cases with code before variable declarations. These were added before the longer commit by bulk88 which fixed a lot of previously existing cases. Note that Perl 5.35.5 and later relax this requirement because 5.35.5 and later versions use some of C99 (C standard ISO/IEC 9899:1999) features. Gcc and Clang flag -Werror=declaration-after-statement is especially mentioned as something that should only be used with Perl versions earlier than 5.35.5. https://perldoc.perl.org/5.35.5/perldelta#Configuration-and-Compilation SSLeay.xs currently avoids code before declarations.
-rw-r--r--Changes7
-rw-r--r--SSLeay.xs23
2 files changed, 22 insertions, 8 deletions
diff --git a/Changes b/Changes
index dab1fd3..d1baa0c 100644
--- a/Changes
+++ b/Changes
@@ -134,6 +134,13 @@ Revision history for Perl extension Net::SSLeay.
related functions.
- Support finding OpenSSL libraries using
ExtUtils::PkgConfig. Thanks to Paul Howarth for the patch.
+ - Fix a number of cases where variables were declared after
+ code triggering Gcc and Clang warning
+ -Wdeclaration-after-statement. This is supported by C
+ language version C99 and used by Perl 5.35.5 and
+ later. SSLeay.xs is likely compiled with compilers that do
+ not support this, therefore such constructs are avoided in
+ SSLeay.xs. Thanks to GitHub user bulk88 for the patch.
1.93_02 2023-02-22
- Update ppport.h to version 3.68. This eliminates thousands of
diff --git a/SSLeay.xs b/SSLeay.xs
index fca0c2f..787892d 100644
--- a/SSLeay.xs
+++ b/SSLeay.xs
@@ -2997,8 +2997,9 @@ SSL_has_pending(s)
#ifdef NET_SSLEAY_32BIT_INT_PERL
int
OPENSSL_init_ssl(double opts, SV *sv_settings = &PL_sv_undef)
- CODE:
+ PREINIT:
const OPENSSL_INIT_SETTINGS *settings = NULL;
+ CODE:
if (sv_settings != &PL_sv_undef)
settings = INT2PTR(OPENSSL_INIT_SETTINGS *, SvIV(sv_settings));
RETVAL = OPENSSL_init_ssl(opts, settings);
@@ -3007,8 +3008,9 @@ OPENSSL_init_ssl(double opts, SV *sv_settings = &PL_sv_undef)
int
OPENSSL_init_crypto(double opts, SV *sv_settings = &PL_sv_undef)
- CODE:
+ PREINIT:
const OPENSSL_INIT_SETTINGS *settings = NULL;
+ CODE:
if (sv_settings != &PL_sv_undef)
settings = INT2PTR(OPENSSL_INIT_SETTINGS *, SvIV(sv_settings));
RETVAL = OPENSSL_init_crypto(opts, settings);
@@ -3018,8 +3020,9 @@ OPENSSL_init_crypto(double opts, SV *sv_settings = &PL_sv_undef)
#else
int
OPENSSL_init_ssl(uint64_t opts, SV *sv_settings = &PL_sv_undef)
- CODE:
+ PREINIT:
const OPENSSL_INIT_SETTINGS *settings = NULL;
+ CODE:
if (sv_settings != &PL_sv_undef)
settings = INT2PTR(OPENSSL_INIT_SETTINGS *, SvIV(sv_settings));
RETVAL = OPENSSL_init_ssl(opts, settings);
@@ -3028,8 +3031,9 @@ OPENSSL_init_ssl(uint64_t opts, SV *sv_settings = &PL_sv_undef)
int
OPENSSL_init_crypto(uint64_t opts, SV *sv_settings = &PL_sv_undef)
- CODE:
+ PREINIT:
const OPENSSL_INIT_SETTINGS *settings = NULL;
+ CODE:
if (sv_settings != &PL_sv_undef)
settings = INT2PTR(OPENSSL_INIT_SETTINGS *, SvIV(sv_settings));
RETVAL = OPENSSL_init_crypto(opts, settings);
@@ -8656,8 +8660,9 @@ OSSL_LIB_CTX_get0_global_default()
OSSL_PROVIDER *
OSSL_PROVIDER_load(SV *libctx, const char *name)
- CODE:
+ PREINIT:
OSSL_LIB_CTX *ctx = NULL;
+ CODE:
if (libctx != &PL_sv_undef)
ctx = INT2PTR(OSSL_LIB_CTX *, SvIV(libctx));
RETVAL = OSSL_PROVIDER_load(ctx, name);
@@ -8668,8 +8673,9 @@ OSSL_PROVIDER_load(SV *libctx, const char *name)
OSSL_PROVIDER *
OSSL_PROVIDER_try_load(SV *libctx, const char *name, int retain_fallbacks)
- CODE:
+ PREINIT:
OSSL_LIB_CTX *ctx = NULL;
+ CODE:
if (libctx != &PL_sv_undef)
ctx = INT2PTR(OSSL_LIB_CTX *, SvIV(libctx));
RETVAL = OSSL_PROVIDER_try_load(ctx, name, retain_fallbacks);
@@ -8683,8 +8689,9 @@ OSSL_PROVIDER_unload(OSSL_PROVIDER *prov)
int
OSSL_PROVIDER_available(SV *libctx, const char *name)
- CODE:
+ PREINIT:
OSSL_LIB_CTX *ctx = NULL;
+ CODE:
if (libctx != &PL_sv_undef)
ctx = INT2PTR(OSSL_LIB_CTX *, SvIV(libctx));
RETVAL = OSSL_PROVIDER_available(ctx, name);
@@ -8695,8 +8702,8 @@ int
OSSL_PROVIDER_do_all(SV *libctx, SV *perl_cb, SV *perl_cbdata = &PL_sv_undef)
PREINIT:
simple_cb_data_t* cbdata = NULL;
- CODE:
OSSL_LIB_CTX *ctx = NULL;
+ CODE:
if (libctx != &PL_sv_undef)
ctx = INT2PTR(OSSL_LIB_CTX *, SvIV(libctx));