Skip to content

Commit 5127a22

Browse files
authored
uri: Mark local pointers as const in URI parser implementations (#19581)
* uri: Mark local pointers as `const` in uri_parser_whatwg.c * uri: Mark local pointers as `const` in uri_parser_rfc3986.c
1 parent 7e5ad5c commit 5127a22

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

ext/uri/uri_parser_rfc3986.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ZEND_ATTRIBUTE_NONNULL static UriUriA *uriparser_read_uri(uriparser_uris_t *urip
9898

9999
ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_scheme(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
100100
{
101-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
101+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
102102
ZEND_ASSERT(uriparser_uri != NULL);
103103

104104
if (uriparser_uri->scheme.first != NULL && uriparser_uri->scheme.afterLast != NULL) {
@@ -113,7 +113,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_scheme(const uri_intern
113113

114114
ZEND_ATTRIBUTE_NONNULL zend_result uriparser_read_userinfo(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
115115
{
116-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
116+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
117117
ZEND_ASSERT(uriparser_uri != NULL);
118118

119119
if (uriparser_uri->userInfo.first != NULL && uriparser_uri->userInfo.afterLast != NULL) {
@@ -127,7 +127,7 @@ ZEND_ATTRIBUTE_NONNULL zend_result uriparser_read_userinfo(const uri_internal_t
127127

128128
ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_username(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
129129
{
130-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
130+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
131131
ZEND_ASSERT(uriparser_uri != NULL);
132132

133133
if (uriparser_uri->userInfo.first != NULL && uriparser_uri->userInfo.afterLast != NULL) {
@@ -150,7 +150,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_username(const uri_inte
150150

151151
ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_password(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
152152
{
153-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
153+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
154154
ZEND_ASSERT(uriparser_uri != NULL);
155155

156156
if (uriparser_uri->userInfo.first != NULL && uriparser_uri->userInfo.afterLast != NULL) {
@@ -170,7 +170,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_password(const uri_inte
170170

171171
ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_host(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
172172
{
173-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
173+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
174174
ZEND_ASSERT(uriparser_uri != NULL);
175175

176176
if (uriparser_uri->hostText.first != NULL && uriparser_uri->hostText.afterLast != NULL) {
@@ -206,7 +206,7 @@ ZEND_ATTRIBUTE_NONNULL static size_t str_to_int(const char *str, size_t len)
206206

207207
ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_port(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
208208
{
209-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
209+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
210210
ZEND_ASSERT(uriparser_uri != NULL);
211211

212212
if (uriparser_uri->portText.first != NULL && uriparser_uri->portText.afterLast != NULL) {
@@ -220,7 +220,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_port(const uri_internal
220220

221221
ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_path(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
222222
{
223-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
223+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
224224
ZEND_ASSERT(uriparser_uri != NULL);
225225

226226
if (uriparser_uri->pathHead != NULL) {
@@ -249,7 +249,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_path(const uri_internal
249249

250250
ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_query(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
251251
{
252-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
252+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
253253
ZEND_ASSERT(uriparser_uri != NULL);
254254

255255
if (uriparser_uri->query.first != NULL && uriparser_uri->query.afterLast != NULL) {
@@ -263,7 +263,7 @@ ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_query(const uri_interna
263263

264264
ZEND_ATTRIBUTE_NONNULL static zend_result uriparser_read_fragment(const uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
265265
{
266-
UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
266+
const UriUriA *uriparser_uri = uriparser_read_uri(internal_uri->uri, read_mode);
267267
ZEND_ASSERT(uriparser_uri != NULL);
268268

269269
if (uriparser_uri->fragment.first != NULL && uriparser_uri->fragment.afterLast != NULL) {
@@ -348,7 +348,7 @@ void *uriparser_parse_uri(const char *uri_str, size_t uri_str_len, const void *b
348348
* is discarded altogether. */
349349
ZEND_ATTRIBUTE_NONNULL static void *uriparser_clone_uri(void *uri)
350350
{
351-
uriparser_uris_t *uriparser_uris = uri;
351+
const uriparser_uris_t *uriparser_uris = uri;
352352

353353
uriparser_uris_t *new_uriparser_uris = uriparser_create_uris();
354354
uriparser_copy_uri(&new_uriparser_uris->uri, &uriparser_uris->uri);
@@ -363,7 +363,7 @@ ZEND_ATTRIBUTE_NONNULL static void *uriparser_clone_uri(void *uri)
363363
ZEND_ATTRIBUTE_NONNULL static zend_string *uriparser_uri_to_string(void *uri, uri_recomposition_mode_t recomposition_mode, bool exclude_fragment)
364364
{
365365
uriparser_uris_t *uriparser_uris = uri;
366-
UriUriA *uriparser_uri;
366+
const UriUriA *uriparser_uri;
367367

368368
if (recomposition_mode == URI_RECOMPOSITION_RAW_ASCII || recomposition_mode == URI_RECOMPOSITION_RAW_UNICODE) {
369369
uriparser_uri = &uriparser_uris->uri;

ext/uri/uri_parser_whatwg.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static lxb_status_t lexbor_serialize_callback(const lxb_char_t *data, size_t len
260260

261261
static zend_result lexbor_read_scheme(const struct uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
262262
{
263-
lxb_url_t *lexbor_uri = internal_uri->uri;
263+
const lxb_url_t *lexbor_uri = internal_uri->uri;
264264

265265
ZEND_ASSERT(lexbor_uri->scheme.type != LXB_URL_SCHEMEL_TYPE__UNDEF);
266266

@@ -287,7 +287,7 @@ static zend_result lexbor_write_scheme(struct uri_internal_t *internal_uri, zval
287287

288288
static zend_result lexbor_read_username(const struct uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
289289
{
290-
lxb_url_t *lexbor_uri = internal_uri->uri;
290+
const lxb_url_t *lexbor_uri = internal_uri->uri;
291291

292292
if (lexbor_uri->username.length) {
293293
ZVAL_STRINGL(retval, (const char *) lexbor_uri->username.data, lexbor_uri->username.length);
@@ -316,7 +316,7 @@ static zend_result lexbor_write_username(uri_internal_t *internal_uri, zval *val
316316

317317
static zend_result lexbor_read_password(const struct uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
318318
{
319-
lxb_url_t *lexbor_uri = internal_uri->uri;
319+
const lxb_url_t *lexbor_uri = internal_uri->uri;
320320

321321
if (lexbor_uri->password.length > 0) {
322322
ZVAL_STRINGL(retval, (const char *) lexbor_uri->password.data, lexbor_uri->password.length);
@@ -356,7 +356,7 @@ static zend_result init_idna(void)
356356

357357
static zend_result lexbor_read_host(const struct uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
358358
{
359-
lxb_url_t *lexbor_uri = internal_uri->uri;
359+
const lxb_url_t *lexbor_uri = internal_uri->uri;
360360

361361
if (lexbor_uri->host.type == LXB_URL_HOST_TYPE_IPV4) {
362362
smart_str host_str = {0};
@@ -419,7 +419,7 @@ static zend_result lexbor_write_host(struct uri_internal_t *internal_uri, zval *
419419

420420
static zend_result lexbor_read_port(const struct uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
421421
{
422-
lxb_url_t *lexbor_uri = internal_uri->uri;
422+
const lxb_url_t *lexbor_uri = internal_uri->uri;
423423

424424
if (lexbor_uri->has_port) {
425425
ZVAL_LONG(retval, lexbor_uri->port);
@@ -448,7 +448,7 @@ static zend_result lexbor_write_port(struct uri_internal_t *internal_uri, zval *
448448

449449
static zend_result lexbor_read_path(const struct uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
450450
{
451-
lxb_url_t *lexbor_uri = internal_uri->uri;
451+
const lxb_url_t *lexbor_uri = internal_uri->uri;
452452

453453
if (lexbor_uri->path.str.length) {
454454
ZVAL_STRINGL(retval, (const char *) lexbor_uri->path.str.data, lexbor_uri->path.str.length);
@@ -477,7 +477,7 @@ static zend_result lexbor_write_path(struct uri_internal_t *internal_uri, zval *
477477

478478
static zend_result lexbor_read_query(const struct uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
479479
{
480-
lxb_url_t *lexbor_uri = internal_uri->uri;
480+
const lxb_url_t *lexbor_uri = internal_uri->uri;
481481

482482
if (lexbor_uri->query.length) {
483483
ZVAL_STRINGL(retval, (const char *) lexbor_uri->query.data, lexbor_uri->query.length);
@@ -506,7 +506,7 @@ static zend_result lexbor_write_query(struct uri_internal_t *internal_uri, zval
506506

507507
static zend_result lexbor_read_fragment(const struct uri_internal_t *internal_uri, uri_component_read_mode_t read_mode, zval *retval)
508508
{
509-
lxb_url_t *lexbor_uri = internal_uri->uri;
509+
const lxb_url_t *lexbor_uri = internal_uri->uri;
510510

511511
if (lexbor_uri->fragment.length) {
512512
ZVAL_STRINGL(retval, (const char *) lexbor_uri->fragment.data, lexbor_uri->fragment.length);
@@ -586,14 +586,14 @@ static void *lexbor_parse_uri(const char *uri_str, size_t uri_str_len, const voi
586586

587587
static void *lexbor_clone_uri(void *uri)
588588
{
589-
lxb_url_t *lexbor_uri = (lxb_url_t *) uri;
589+
const lxb_url_t *lexbor_uri = uri;
590590

591591
return lxb_url_clone(lexbor_parser.mraw, lexbor_uri);
592592
}
593593

594594
static zend_string *lexbor_uri_to_string(void *uri, uri_recomposition_mode_t recomposition_mode, bool exclude_fragment)
595595
{
596-
lxb_url_t *lexbor_uri = (lxb_url_t *) uri;
596+
const lxb_url_t *lexbor_uri = uri;
597597
smart_str uri_str = {0};
598598

599599
switch (recomposition_mode) {

0 commit comments

Comments
 (0)