Skip to content

Commit 0e682ad

Browse files
committed
ext/filter: Add const qualifiers
1 parent 53bced3 commit 0e682ad

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

ext/filter/logical_filters.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
203203
size_t len;
204204
int error = 0;
205205
zend_long ctx_value;
206-
char *p;
206+
const char *p;
207207

208208
/* Parse options */
209209
FETCH_LONG_OPTION(min_range, "min_range");
@@ -272,7 +272,7 @@ void php_filter_int(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
272272

273273
void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
274274
{
275-
char *str = Z_STRVAL_P(value);
275+
const char *str = Z_STRVAL_P(value);
276276
size_t len = Z_STRLEN_P(value);
277277
int ret;
278278

@@ -342,7 +342,7 @@ void php_filter_boolean(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
342342
void php_filter_float(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
343343
{
344344
size_t len;
345-
char *str, *end;
345+
const char *str, *end;
346346
char *num, *p;
347347
zval *option_val;
348348
char *decimal;
@@ -504,9 +504,9 @@ void php_filter_validate_regexp(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
504504
}
505505
}
506506

507-
static int _php_filter_validate_domain(char * domain, size_t len, zend_long flags) /* {{{ */
507+
static int _php_filter_validate_domain(const char *domain, size_t len, zend_long flags) /* {{{ */
508508
{
509-
char *e, *s, *t;
509+
const char *e, *s, *t;
510510
size_t l;
511511
int hostname = flags & FILTER_FLAG_HOSTNAME;
512512
unsigned char i = 1;
@@ -564,7 +564,7 @@ void php_filter_validate_domain(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
564564
}
565565
/* }}} */
566566

567-
static int is_userinfo_valid(zend_string *str)
567+
static int is_userinfo_valid(const zend_string *str)
568568
{
569569
const char *valid = "-._~!$&'()*+,;=:";
570570
const char *p = ZSTR_VAL(str);
@@ -723,7 +723,7 @@ void php_filter_validate_email(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
723723
}
724724
/* }}} */
725725

726-
static int _php_filter_validate_ipv4(char *str, size_t str_len, int *ip) /* {{{ */
726+
static int _php_filter_validate_ipv4(const char *str, size_t str_len, int *ip) /* {{{ */
727727
{
728728
const char *end = str + str_len;
729729
int num, m;
@@ -763,7 +763,7 @@ static int _php_filter_validate_ipv6(const char *str, size_t str_len, int ip[8])
763763
int compressed_pos = -1;
764764
int blocks = 0;
765765
int num, n, i;
766-
char *ipv4;
766+
const char *ipv4;
767767
const char *end;
768768
int ip4elm[4];
769769
const char *s = str;
@@ -1035,7 +1035,7 @@ void php_filter_validate_ip(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
10351035

10361036
void php_filter_validate_mac(PHP_INPUT_FILTER_PARAM_DECL) /* {{{ */
10371037
{
1038-
char *input = Z_STRVAL_P(value);
1038+
const char *input = Z_STRVAL_P(value);
10391039
size_t input_len = Z_STRLEN_P(value);
10401040
int tokens, length, exp_separator_set;
10411041
size_t exp_separator_len;

ext/filter/sanitizing_filters.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const
6464
{
6565
unsigned char *p;
6666
unsigned char tmp[256];
67-
unsigned char *s = (unsigned char *)chars;
68-
unsigned char *e = s + char_len;
67+
const unsigned char *s = chars;
68+
const unsigned char *e = s + char_len;
6969
zend_string *str;
7070

7171
memset(tmp, 1, sizeof(tmp)-1);
@@ -75,8 +75,8 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const
7575
}
7676

7777
str = zend_string_safe_alloc(Z_STRLEN_P(value), 3, 0, 0);
78-
p = (unsigned char *) ZSTR_VAL(str);
79-
s = (unsigned char *) Z_STRVAL_P(value);
78+
p = (unsigned char*)ZSTR_VAL(str);
79+
s = (const unsigned char*)Z_STRVAL_P(value);
8080
e = s + Z_STRLEN_P(value);
8181

8282
while (s < e) {
@@ -90,14 +90,14 @@ static void php_filter_encode_url(zval *value, const unsigned char* chars, const
9090
s++;
9191
}
9292
*p = '\0';
93-
ZSTR_LEN(str) = p - (unsigned char *)ZSTR_VAL(str);
93+
ZSTR_LEN(str) = p - (const unsigned char *)ZSTR_VAL(str);
9494
zval_ptr_dtor(value);
9595
ZVAL_NEW_STR(value, str);
9696
}
9797

9898
static void php_filter_strip(zval *value, zend_long flags)
9999
{
100-
unsigned char *str;
100+
const unsigned char *str;
101101
size_t c;
102102
zend_string *buf;
103103

@@ -106,7 +106,7 @@ static void php_filter_strip(zval *value, zend_long flags)
106106
return;
107107
}
108108

109-
str = (unsigned char *)Z_STRVAL_P(value);
109+
str = (const unsigned char *)Z_STRVAL_P(value);
110110
buf = zend_string_alloc(Z_STRLEN_P(value), 0);
111111
c = 0;
112112
for (size_t i = 0; i < Z_STRLEN_P(value); i++) {
@@ -142,9 +142,9 @@ static void filter_map_update(filter_map *map, int flag, const unsigned char *al
142142
}
143143
}
144144

145-
static void filter_map_apply(zval *value, filter_map *map)
145+
static void filter_map_apply(zval *value, const filter_map *map)
146146
{
147-
unsigned char *str;
147+
const unsigned char *str;
148148
size_t i, c;
149149
zend_string *buf;
150150

0 commit comments

Comments
 (0)