-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix Compiler Warnings #84
Conversation
src/crypto/aes.cpp
Outdated
@@ -429,7 +429,7 @@ openssl_thread_config::openssl_thread_config() | |||
} | |||
openssl_thread_config::~openssl_thread_config() | |||
{ | |||
if (CRYPTO_get_id_callback() == &get_thread_id) | |||
if (CRYPTO_get_id_callback() != NULL && CRYPTO_get_id_callback() == &get_thread_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the first check redundant? &get_thread_id
will never be NULL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is redundant. It did avoid a warning, but I would prefer to not add the logic. I took it back out, and the warning returned. But I think it better to live with the warning.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the warning say? Are we missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, including what I am talking about in the note would have been smart. Adding the CRYPTO_get_id_callback() != nullptr &&
to the if
fixed the warning, but I hate adding such code just to squelch a warning.
This is the original warning:
/src/crypto/aes.cpp:432:32: warning: the address of ‘static long unsigned int fc::openssl_thread_config::get_thread_id()’ will never be NULL [-Waddress]
if (CRYPTO_get_id_callback() == &get_thread_id)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRYPTO_get_id_callback
is deprecated - does the warning persist if you switch to CRYPTO_THREADID_[gs]et_callback
? https://linux.die.net/man/3/crypto_lock
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, unfortunately.
I reverted the change for the null check, and the warning has reappeared. Personally, I think the warning should stay there until a better fix is provided. A different quick fix is to do the compare using a macro, casting to void*. But it seems wrong to me to add such code just to avoid a warning. Please share your thoughts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, after some googling is seems that the warning about the non-null function address is a flaw in g++. We should leave it in, hopefully it'll be fixed in a later gcc version.
Fix for bitshares/bitshares-core#1383
Several compiler warnings have appeared due to upgrades of compilers and OpenSSL.
Synopsis of changes:
rand.hpp - OpenSSL's CRYPTO_pseudo_random_bytes has been deprecated. This is used in only 1 place in Bitshares, and should be replaced with fc::rand_bytes (net/node.cpp).
openssl.cpp - OPENSSL_config(nullptr) is no longer needed with OpenSSL 1.1. It has been replaced with an init function that is automatically called with defaults when needed.
The rest of the changes were simply to squelch compiler warnings and SHOULD NOT change code logic.