From 69c63e4c742c7fc7dc742ec65074c02d3eb21e60 Mon Sep 17 00:00:00 2001 From: Nelson Ferreira Date: Sat, 12 Dec 2015 16:45:27 -0500 Subject: [PATCH] More eliminate silly warnings * src/search.c (fast_string_match): Use a temporary to avoid warning about constness. * src/openssl.c (Fossl_digest_file): Mark set unused but unused variable. (Fossl_pem_write_public_key): Ditto. (Fossl_pem_write_key): Ditto. (Fossl_ssl_read): Ditto. (Fossl_ssl_write): Ditto. (ossl_ssl_prepare_cmeth): Ignore drop of const qualifier. The alternative of using const for SSL methods everywhere is not workable if we are to support older OpenSSL versions. (ossl_ssl_prepare_smeth): Ditto. * src/alloc.c (make_string_nocopy): Remove unnecessary cast. Signed-off-by: Nelson Ferreira --- src/alloc.c | 2 +- src/openssl.c | 26 +++++++++++++++++++++++++- src/search.c | 7 +++++-- src/symbols.c | 4 ++-- 4 files changed, 33 insertions(+), 6 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 5fc372e..9c07f16 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -3306,7 +3306,7 @@ Lisp_Object make_string_nocopy(Bufbyte *contents, Bytecount length) #ifdef EF_USE_COMPRE s->compre = Qnil; #endif - set_string_data(s, (Bufbyte*)contents); + set_string_data(s, contents); set_string_length(s, length); XSETSTRING(val, s); diff --git a/src/openssl.c b/src/openssl.c index f87f7aa..dc97da1 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -895,6 +895,7 @@ binary string data. mdctx = xnew(EVP_MD_CTX); EVP_MD_CTX_init(mdctx); md_blocksize = (unsigned int)(EVP_MD_block_size(md) / 8); + SXE_SET_UNUSED(md_blocksize); EVP_DigestInit_ex(mdctx, md, NULL); @@ -2980,6 +2981,7 @@ Write PKEY (the public part) in a PEM structure to FILE. pk = XEVPPKEY(pkey)->evp_pkey; pk509 = XEVPPKEY(pkey)->x509; + SXE_SET_UNUSED(pk509); if ((fp = fopen((char *)XSTRING_DATA(file), "w")) == NULL) error ("error opening file."); @@ -3019,6 +3021,7 @@ PASSWORD is ignored in this case. pk = XEVPPKEY(pkey)->evp_pkey; pk509 = XEVPPKEY(pkey)->x509; + SXE_SET_UNUSED(pk509); if (!ossl_pkey_has_private_data(pk)) return Fossl_pem_write_public_key(file, pkey); @@ -3471,13 +3474,21 @@ ossl_bio_dump_callback(BIO *bio, int cmd, const char *argp, static Lisp_Object ossl_ssl_prepare_cmeth(Lisp_Object method) { - SSL_METHOD *meth = NULL; + SSL_METHOD *meth = NULL; Lisp_SSL_CONN *lisp_ssl_conn; /* start preparing the conn object */ SSL_library_init(); SSL_load_error_strings(); + /* I would love to make 'meth' const SSL_METHOD* as well as the + 'ssl_meth' member of 'Lisp_SSL_CONN' unfortunately not all + supported versions of OpenSSL then take const SSL_METHOD* + as arguments, so turning off the cast qualifier warning and + store non-const is a more reasonable solution. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" if (0) { } else if (EQ(method, Qssl2)) { #if HAVE_SSLV2_CLIENT_METHOD @@ -3510,6 +3521,7 @@ ossl_ssl_prepare_cmeth(Lisp_Object method) error("default tlsv1 client method not supported"); #endif } +#pragma GCC diagnostic pop if (!RAND_status()) error("OSSL: not enough random data"); @@ -3533,6 +3545,14 @@ ossl_ssl_prepare_smeth(Lisp_Object method) SSL_library_init(); SSL_load_error_strings(); + /* I would love to make 'meth' const SSL_METHOD* as well as the + 'ssl_meth' member of 'Lisp_SSL_CONN' unfortunately not all + supported versions of OpenSSL then take const SSL_METHOD* + as arguments, so turning off the cast qualifier warning and + store non-const is a more reasonable solution. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wcast-qual" if (0) { } else if (EQ(method, Qssl2)) { #if HAVE_SSLV2_SERVER_METHOD @@ -3565,6 +3585,7 @@ ossl_ssl_prepare_smeth(Lisp_Object method) error("default sslv23 client method not supported"); #endif } +#pragma GCC diagnostic pop if (!RAND_status()) error("OSSL: not enough random data"); @@ -4259,6 +4280,8 @@ block of data sent through SSL-CONN. error("SSL connection dead"); conn = XSSLCONN(ssl_conn)->ssl_conn; + SXE_SET_UNUSED(conn); + process = XSSLCONN(ssl_conn)->parent; /* Make sure the process is really alive. */ @@ -4307,6 +4330,7 @@ Send STRING to the tunnel SSL-CONN. /* store the original process filter */ proc_filter = XPROCESS(process)->filter; + SXE_SET_UNUSED(proc_filter); ret = Lstream_write(out, XSTRING_DATA(string), XSTRING_LENGTH(string)); Lstream_flush(out); diff --git a/src/search.c b/src/search.c index 1a5f0a1..ff9f338 100644 --- a/src/search.c +++ b/src/search.c @@ -766,8 +766,11 @@ fast_string_match(Lisp_Object regexp, const Bufbyte * nonreloc, return with failure... */ return -1; - newnonreloc = alloca(length); - memcpy((void*)newnonreloc, (void*)XSTRING_DATA(reloc), length); + Bufbyte *copy = alloca(length); + memcpy((void*)copy, + (const void*)XSTRING_DATA(reloc), + length); + newnonreloc = copy; } } diff --git a/src/symbols.c b/src/symbols.c index a7d9f5e..f02591b 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -612,11 +612,11 @@ SUBR must be a built-in function. */ (subr)) { - const char *name; + const char *name; if (!SUBRP (subr)) wrong_type_argument (Qsubrp, subr); name = XSUBR (subr)->name; - return make_string ((Bufbyte *)name, strlen (name)); + return make_string ((const Bufbyte *)name, strlen (name)); } -- 2.25.1