Skip to content

Commit b4228cb

Browse files
committed
Fix warnings about the OPENSSL_FIPS macro in OpenSSL 1.1.
The commit <c5b2bc1268bcb946ff2eb52904a85278a1dac12c> made the warnings below in the case of OpenSSL 1.1 where the `OPENSSL_FIPS` macro is not defined. ``` $ bundle install --standalone $ bundle exec rake compile -- \ --with-openssl-dir=$HOME/.local/openssl-1.1.1t-debug \ --with-cflags="-Wundef" mkdir -p tmp/x86_64-linux/openssl/3.2.1 cd tmp/x86_64-linux/openssl/3.2.1 /usr/local/ruby-3.2.1/bin/ruby -I. -r.rake-compiler-siteconf.rb ../../../../ext/openssl/extconf.rb -- --with-openssl-dir=/home/jaruga/.local/openssl-1.1.1t-debug --with-cflags=-Wundef ... gcc -I. -I/usr/local/ruby-3.2.1/include/ruby-3.2.0/x86_64-linux -I/usr/local/ruby-3.2.1/include/ruby-3.2.0/ruby/backward -I/usr/local/ruby-3.2.1/include/ruby-3.2.0 -I../../../../ext/openssl -DRUBY_EXTCONF_H=\"extconf.h\" -I/home/jaruga/.local/openssl-1.1.1t-debug/include -fPIC -Wundef -o ossl.o -c ../../../../ext/openssl/ossl.c ../../../../ext/openssl/ossl.c: In function ‘ossl_fips_mode_get’: ../../../../ext/openssl/ossl.c:425:7: warning: "OPENSSL_FIPS" is not defined, evaluates to 0 [-Wundef] 425 | #elif OPENSSL_FIPS | ^~~~~~~~~~~~ ../../../../ext/openssl/ossl.c: In function ‘ossl_fips_mode_set’: ../../../../ext/openssl/ossl.c:460:7: warning: "OPENSSL_FIPS" is not defined, evaluates to 0 [-Wundef] 460 | #elif OPENSSL_FIPS | ^~~~~~~~~~~~ ../../../../ext/openssl/ossl.c: In function ‘Init_openssl’: ../../../../ext/openssl/ossl.c:1218:7: warning: "OPENSSL_FIPS" is not defined, evaluates to 0 [-Wundef] 1218 | #elif OPENSSL_FIPS | ^~~~~~~~~~~~ ... cp tmp/x86_64-linux/openssl/3.2.1/openssl.so tmp/x86_64-linux/stage/lib/openssl.so ```
1 parent c5b2bc1 commit b4228cb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ext/openssl/ossl.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ ossl_fips_mode_get(VALUE self)
422422
VALUE enabled;
423423
enabled = EVP_default_properties_is_fips_enabled(NULL) ? Qtrue : Qfalse;
424424
return enabled;
425-
#elif OPENSSL_FIPS
425+
#elif defined(OPENSSL_FIPS)
426426
VALUE enabled;
427427
enabled = FIPS_mode() ? Qtrue : Qfalse;
428428
return enabled;
@@ -457,7 +457,7 @@ ossl_fips_mode_set(VALUE self, VALUE enabled)
457457
}
458458
}
459459
return enabled;
460-
#elif OPENSSL_FIPS
460+
#elif defined(OPENSSL_FIPS)
461461
if (RTEST(enabled)) {
462462
int mode = FIPS_mode();
463463
if(!mode && !FIPS_mode_set(1)) /* turning on twice leads to an error */
@@ -1215,7 +1215,7 @@ Init_openssl(void)
12151215
/* OpenSSL 3 is FIPS-capable even when it is installed without fips option */
12161216
#if OSSL_OPENSSL_PREREQ(3, 0, 0)
12171217
Qtrue
1218-
#elif OPENSSL_FIPS
1218+
#elif defined(OPENSSL_FIPS)
12191219
Qtrue
12201220
#else
12211221
Qfalse

0 commit comments

Comments
 (0)