Skip to content

Commit 263b22f

Browse files
Make lots of string pointers const (#10646)
This allows using string literals without implicitly casting away the `const`.
1 parent 373809c commit 263b22f

22 files changed

+39
-40
lines changed

ext/curl/curl_file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ PHP_FUNCTION(curl_file_create)
6565
}
6666
/* }}} */
6767

68-
static void curlfile_get_property(char *name, size_t name_len, INTERNAL_FUNCTION_PARAMETERS)
68+
static void curlfile_get_property(const char *name, size_t name_len, INTERNAL_FUNCTION_PARAMETERS)
6969
{
7070
zval *res, rv;
7171

@@ -74,7 +74,7 @@ static void curlfile_get_property(char *name, size_t name_len, INTERNAL_FUNCTION
7474
RETURN_COPY_DEREF(res);
7575
}
7676

77-
static void curlfile_set_property(char *name, size_t name_len, INTERNAL_FUNCTION_PARAMETERS)
77+
static void curlfile_set_property(const char *name, size_t name_len, INTERNAL_FUNCTION_PARAMETERS)
7878
{
7979
zend_string *arg;
8080

ext/curl/interface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ static zend_result _php_curl_setopt(php_curl *ch, zend_long option, zval *zvalue
20732073
struct curl_slist *slist = NULL;
20742074

20752075
if (Z_TYPE_P(zvalue) != IS_ARRAY) {
2076-
char *name = NULL;
2076+
const char *name = NULL;
20772077
switch (option) {
20782078
case CURLOPT_HTTPHEADER:
20792079
name = "CURLOPT_HTTPHEADER";

ext/date/php_date.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ PHPAPI time_t php_time(void)
235235

236236
#include "php_date_arginfo.h"
237237

238-
static char* guess_timezone(const timelib_tzdb *tzdb);
238+
static const char* guess_timezone(const timelib_tzdb *tzdb);
239239
static void date_register_classes(void);
240240
/* }}} */
241241

@@ -549,7 +549,7 @@ static PHP_INI_MH(OnUpdate_date_timezone)
549549
/* }}} */
550550

551551
/* {{{ Helper functions */
552-
static char* guess_timezone(const timelib_tzdb *tzdb)
552+
static const char* guess_timezone(const timelib_tzdb *tzdb)
553553
{
554554
/* Checking whether timezone has been set with date_default_timezone_set() */
555555
if (DATEG(timezone) && (strlen(DATEG(timezone))) > 0) {
@@ -573,10 +573,9 @@ static char* guess_timezone(const timelib_tzdb *tzdb)
573573

574574
PHPAPI timelib_tzinfo *get_timezone_info(void)
575575
{
576-
char *tz;
577576
timelib_tzinfo *tzi;
578577

579-
tz = guess_timezone(DATE_TIMEZONEDB);
578+
const char *tz = guess_timezone(DATE_TIMEZONEDB);
580579
tzi = php_date_parse_tzfile(tz, DATE_TIMEZONEDB);
581580
if (! tzi) {
582581
zend_throw_error(date_ce_date_error, "Timezone database is corrupt. Please file a bug report as this should never happen");
@@ -607,7 +606,7 @@ static const char * const day_short_names[] = {
607606
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
608607
};
609608

610-
static char *english_suffix(timelib_sll number)
609+
static const char *english_suffix(timelib_sll number)
611610
{
612611
if (number >= 10 && number <= 19) {
613612
return "th";
@@ -1667,7 +1666,7 @@ static const zend_object_iterator_funcs date_period_it_funcs = {
16671666
NULL, /* get_gc */
16681667
};
16691668

1670-
zend_object_iterator *date_object_period_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */
1669+
static zend_object_iterator *date_object_period_get_iterator(zend_class_entry *ce, zval *object, int by_ref) /* {{{ */
16711670
{
16721671
date_period_it *iterator;
16731672

@@ -2043,7 +2042,7 @@ static void php_timezone_to_string(php_timezone_obj *tzobj, zval *zv)
20432042
}
20442043
}
20452044

2046-
void date_timezone_object_to_hash(php_timezone_obj *tzobj, HashTable *props)
2045+
static void date_timezone_object_to_hash(php_timezone_obj *tzobj, HashTable *props)
20472046
{
20482047
zval zv;
20492048

ext/dba/dba.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -462,10 +462,10 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, bool persistent)
462462
dba_mode_t modenr;
463463
dba_info *info, *other;
464464
const dba_handler *hptr;
465-
char *error = NULL;
465+
const char *error = NULL;
466466
int lock_mode, lock_flag = 0;
467-
char *file_mode;
468-
char *lock_file_mode = NULL;
467+
const char *file_mode;
468+
const char *lock_file_mode = NULL;
469469
int persistent_flag = persistent ? STREAM_OPEN_PERSISTENT : 0;
470470
zend_string *opened_path = NULL;
471471
char *lock_name;

ext/dba/libcdb/cdb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ int cdb_find(struct cdb *c, char *key, unsigned int len)
185185
/* }}} */
186186

187187
/* {{{ cdb_version */
188-
char *cdb_version()
188+
const char *cdb_version()
189189
{
190190
return "0.75, $Id$";
191191
}

ext/dba/libcdb/cdb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ int cdb_find(struct cdb *, char *, unsigned int);
4848
#define cdb_datapos(c) ((c)->dpos)
4949
#define cdb_datalen(c) ((c)->dlen)
5050

51-
char *cdb_version(void);
51+
const char *cdb_version(void);
5252

5353
#endif

ext/dba/libcdb/cdb_make.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ int cdb_make_finish(struct cdb_make *c)
236236
/* }}} */
237237

238238
/* {{{ cdb_make_version */
239-
char *cdb_make_version()
239+
const char *cdb_make_version()
240240
{
241241
return "0.75, $Id$";
242242
}

ext/dba/libcdb/cdb_make.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,6 @@ int cdb_make_addbegin(struct cdb_make *, unsigned int, unsigned int);
5555
int cdb_make_addend(struct cdb_make *, unsigned int, unsigned int, uint32);
5656
int cdb_make_add(struct cdb_make *, char *, unsigned int, char *, unsigned int);
5757
int cdb_make_finish(struct cdb_make *);
58-
char *cdb_make_version(void);
58+
const char *cdb_make_version(void);
5959

6060
#endif

ext/dba/libflatfile/flatfile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ datum flatfile_nextkey(flatfile *dba) {
276276
/* }}} */
277277

278278
/* {{{ flatfile_version */
279-
char *flatfile_version()
279+
const char *flatfile_version()
280280
{
281281
return "1.0, $Id$";
282282
}

ext/dba/libflatfile/flatfile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ int flatfile_delete(flatfile *dba, datum key_datum);
3939
int flatfile_findkey(flatfile *dba, datum key_datum);
4040
datum flatfile_firstkey(flatfile *dba);
4141
datum flatfile_nextkey(flatfile *dba);
42-
char *flatfile_version(void);
42+
const char *flatfile_version(void);
4343

4444
#endif

0 commit comments

Comments
 (0)