Skip to content

Reduce scope of r in rand_rangeXX #9678

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 1 commit into from
Oct 6, 2022
Merged
Changes from all commits
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
12 changes: 6 additions & 6 deletions ext/random/random.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,14 @@ static zend_object_handlers random_randomizer_object_handlers;

static inline uint32_t rand_range32(const php_random_algo *algo, php_random_status *status, uint32_t umax)
{
uint32_t result, limit, r;
uint32_t result, limit;
size_t total_size = 0;
uint32_t count = 0;

result = 0;
total_size = 0;
do {
r = algo->generate(status);
uint32_t r = algo->generate(status);
result = result | (r << (total_size * 8));
total_size += status->last_generated_size;
if (EG(exception)) {
Expand Down Expand Up @@ -132,7 +132,7 @@ static inline uint32_t rand_range32(const php_random_algo *algo, php_random_stat
result = 0;
total_size = 0;
do {
r = algo->generate(status);
uint32_t r = algo->generate(status);
result = result | (r << (total_size * 8));
total_size += status->last_generated_size;
if (EG(exception)) {
Expand All @@ -146,14 +146,14 @@ static inline uint32_t rand_range32(const php_random_algo *algo, php_random_stat

static inline uint64_t rand_range64(const php_random_algo *algo, php_random_status *status, uint64_t umax)
{
uint64_t result, limit, r;
uint64_t result, limit;
size_t total_size = 0;
uint32_t count = 0;

result = 0;
total_size = 0;
do {
r = algo->generate(status);
uint64_t r = algo->generate(status);
result = result | (r << (total_size * 8));
total_size += status->last_generated_size;
if (EG(exception)) {
Expand Down Expand Up @@ -188,7 +188,7 @@ static inline uint64_t rand_range64(const php_random_algo *algo, php_random_stat
result = 0;
total_size = 0;
do {
r = algo->generate(status);
uint64_t r = algo->generate(status);
result = result | (r << (total_size * 8));
total_size += status->last_generated_size;
if (EG(exception)) {
Expand Down