-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix warning: 'arc4random_addrandom' is deprecated: use arc4random_stir #1631
base: master
Are you sure you want to change the base?
Conversation
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.
LGTM, but MacOS CI is broken now, and it should be fixed first (#1632)
/* Define to 1 if you have the `arc4random_addrandom' function. */ | ||
#cmakedefine EVENT__HAVE_ARC4RANDOM_ADDRANDOM 1 | ||
/* Define to 1 if you have the `arc4random_stir' function. */ | ||
#cmakedefine EVENT__HAVE_ARC4RANDOM_STIR 1 |
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.
This will not work without changing cmake rules and don't forget about autotools
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.
I'm not understanding this. I've changed all the occurrences of EVENT__HAVE_ARC4RANDOM_ADDRANDOM in the repository.
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.
This is not how it works. You need to add the function arc4random_stir
into
Line 563 in c6a74ee
arc4random_addrandom |
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.
And same in configure.ac
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.
Ah I see. I've added the symbol in 54f621a.
I didn't remove the previous one, since there is still a path that uses it (#if !defined(EVENT__HAVE_ARC4RANDOM)
).
I've also sorted the symbols alphabetically.
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.
I've also sorted the symbols alphabetically.
Given this code is for an RNG, it'd be good if you didn't make random, unrelated style changes to the code at the same time. At the very least, any changes should be in separate commits (with proper & complete commit messages), so it's clear what is changing, and how.
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.
.
b3804b9
to
54f621a
Compare
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.
Ideally, arc4random_addrandom should never be used. It's deprecated in favor of arc4random_stir.
Can you expand the PR description to explain what you're doing and why, with links to the supposed deprecations (or at least the relevant warning output). The original PR description had something about macOS, but this code is going to effect systems other than macOS, so that's not the only thing that should be considered.
From a quick look at one manpage, i.e https://man.archlinux.org/man/arc4random_stir.3bsd.en, arc4random_addrandom
and arc4random_stir
are similar in function, but not marked as deprecated?
I also see:
It is not necessary for an application to call arc4random_stir() or arc4random_addrandom() before calling other arc4random functions.
Additionally, arc4random_stir() and arc4random_addrandom() may abort the process in the highly unlikely event that the operating system fails to provide entropy.
So it could be considered as unnecessary to call arc4random_stir
as use arc4random_addrandom
, so it's not clear why swapping the usage of one, for the other, here, is an improvement, or the right change to make?
/* Define to 1 if you have the `arc4random_addrandom' function. */ | ||
#cmakedefine EVENT__HAVE_ARC4RANDOM_ADDRANDOM 1 | ||
/* Define to 1 if you have the `arc4random_stir' function. */ | ||
#cmakedefine EVENT__HAVE_ARC4RANDOM_STIR 1 |
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.
I've also sorted the symbols alphabetically.
Given this code is for an RNG, it'd be good if you didn't make random, unrelated style changes to the code at the same time. At the very least, any changes should be in separate commits (with proper & complete commit messages), so it's clear what is changing, and how.
@@ -193,9 +193,11 @@ evutil_secure_rng_get_bytes(void *buf, size_t n) | |||
void | |||
evutil_secure_rng_add_bytes(const char *buf, size_t n) | |||
{ | |||
#if !defined(EVENT__HAVE_ARC4RANDOM) || defined(EVENT__HAVE_ARC4RANDOM_ADDRANDOM) |
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.
If you're removing the use of EVENT__HAVE_ARC4RANDOM_ADDRANDOM
, then why is the check for arc4random_addrandom
being retained in both build systems?
Ideally, arc4random_addrandom should never be used. It's deprecated in favor of arc4random_stir.