Skip to content

ext/random: Various minor refactorings#18435

Open
Girgias wants to merge 7 commits into
php:masterfrom
Girgias:random-refacto
Open

ext/random: Various minor refactorings#18435
Girgias wants to merge 7 commits into
php:masterfrom
Girgias:random-refacto

Conversation

@Girgias
Copy link
Copy Markdown
Member

@Girgias Girgias commented Apr 26, 2025

Commits should be reviewed in order.

@Girgias Girgias changed the title Random refacto ext/random: Various minor refactorings Apr 26, 2025
@Girgias Girgias marked this pull request as ready for review August 3, 2025 18:35
Comment thread ext/random/php_random.h
Comment thread ext/random/random.c Outdated
{
size_t len = hexstr->len >> 1;
unsigned char *str = (unsigned char *) hexstr->val, c, l, d;
const unsigned char *str = (unsigned char *) hexstr->val;
unsigned char c, l, d;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These could also be pulled into the for(). In fact php_hex2bin (which is referenced in the comment above this function) already does. It makes sense to keep the two functions aligned.

Comment thread ext/random/randomizer.c Outdated
Copy link
Copy Markdown
Member

@TimWolla TimWolla left a comment

Choose a reason for hiding this comment

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

LGTM except the hex2bin changes. Perhaps they should be done in a separate PR, since they are fixing an actual bug?

Comment thread ext/random/random.c Outdated
unsigned char *ptr = (unsigned char *) dest;
int is_letter, i = 0;
uint32_t i = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This one is a uint32_t used as an offset. Please:

Suggested change
uint32_t i = 0;
size_t i = 0;

Alternatively pointer arithmetic could be used on str.

Comment thread ext/random/random.c Outdated
Comment thread ext/standard/string.c
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In fact here it was correct 😒

@Girgias Girgias removed the request for review from bukka March 26, 2026 12:33
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.

2 participants