Skip to content

random: Remove redundant assignments in php_random_rangeX() #14536

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 3 commits into from
Jun 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions ext/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ PHPAPI uint32_t php_random_range32(php_random_algo_with_state engine, uint32_t u
uint32_t count = 0;

result = 0;
total_size = 0;
do {
php_random_result r = algo->generate(state);
result = result | (((uint32_t) r.result) << (total_size * 8));
Expand Down Expand Up @@ -145,7 +144,6 @@ PHPAPI uint64_t php_random_range64(php_random_algo_with_state engine, uint64_t u
uint32_t count = 0;

result = 0;
total_size = 0;
do {
php_random_result r = algo->generate(state);
result = result | (r.result << (total_size * 8));
Expand Down Expand Up @@ -520,7 +518,7 @@ PHP_FUNCTION(mt_getrandmax)
ZEND_PARSE_PARAMETERS_NONE();

/*
* Melo: it could be 2^^32 but we only use 2^^31 to maintain
* Melo: it could be 2^^32, but we only use 2^^31 to maintain
* compatibility with the previous php_rand
*/
RETURN_LONG(PHP_MT_RAND_MAX); /* 2^^31 */
Expand Down Expand Up @@ -614,7 +612,7 @@ PHPAPI uint64_t php_random_generate_fallback_seed(void)
{
/* Mix various values using SHA-1 as a PRF to obtain as
* much entropy as possible, hopefully generating an
* unpredictable and independent uint64_t. Nevertheless
* unpredictable and independent uint64_t. Nevertheless,
* the output of this function MUST NOT be treated as
* being cryptographically safe.
*/
Expand Down