Skip to content

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


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