Skip to content

random: Convert RANDOM_SEED() from a macro to a function #13575

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

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

TimWolla
Copy link
Member

@TimWolla TimWolla commented Mar 2, 2024

No description provided.

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General idea LGTM

@@ -37,12 +37,19 @@

PHPAPI double php_combined_lcg(void);

static inline zend_long GENERATE_SEED()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be lowercase, the general convention AFAIK is that uppercase means macro, lowercase means functions, especially for a private API

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the casing would result in an unnecessary API break. As the function is static inline there is no behavioral change compared to the macro. Specifically it will not result in any more naming collisions than the macro would, but it does improve type safety and readability somewhat. It also allows to more easily adjust the seed generation, which is terrible (luckily GENERATE_SEED() is effectively only used if the CSPRNG fails, which it never does).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it's a static inline in a header.... yeah sure that's fine

@TimWolla TimWolla merged commit 3d4cb1d into php:master Mar 4, 2024
@TimWolla TimWolla deleted the random-seed-function branch March 4, 2024 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants