From ed87e551efd0160f1944a5e97158ab258db65eaf Mon Sep 17 00:00:00 2001 From: jvoisin Date: Wed, 13 Jul 2022 21:25:04 +0200 Subject: Even more const! --- src/sp_utils.c | 10 +++++----- src/sp_utils.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/sp_utils.c b/src/sp_utils.c index 3436328..42f7871 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c @@ -1,6 +1,6 @@ #include "php_snuffleupagus.h" -static const char* default_ipaddr = "0.0.0.0"; +static char const* const default_ipaddr = "0.0.0.0"; const char* get_ipaddr() { const char* client_ip = getenv("REMOTE_ADDR"); if (client_ip) { @@ -15,8 +15,8 @@ const char* get_ipaddr() { return default_ipaddr; } -void sp_log_msgf(char const* restrict feature, int level, int type, - const char* restrict fmt, ...) { +void sp_log_msgf(char const* const restrict feature, int level, int type, + char const* const restrict fmt, ...) { char* msg; va_list args; @@ -63,7 +63,7 @@ void sp_log_msgf(char const* restrict feature, int level, int type, } } -int compute_hash(const char* const restrict filename, +int compute_hash(char const* const restrict filename, char* restrict file_hash) { unsigned char buf[1024] = {0}; unsigned char digest[SHA256_SIZE] = {0}; @@ -90,7 +90,7 @@ int compute_hash(const char* const restrict filename, return SUCCESS; } -int sp_log_request(const zend_string* restrict folder, const zend_string* restrict text_repr) { +int sp_log_request(zend_string const* const restrict folder, zend_string const* const restrict text_repr) { FILE* file; char const* const current_filename = zend_get_executed_filename(TSRMLS_C); const int current_line = zend_get_executed_lineno(TSRMLS_C); diff --git a/src/sp_utils.h b/src/sp_utils.h index 0e595d8..7bab4ba 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h @@ -71,8 +71,8 @@ extern int sp_debug_stderr; #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") const char *get_ipaddr(void); -void sp_log_msgf(char const *restrict feature, int level, int type, const char *restrict fmt, ...); -int compute_hash(const char *const restrict filename, char *restrict file_hash); +void sp_log_msgf(char const* const restrict feature, int level, int type, char const* const restrict fmt, ...); +int compute_hash(char const* const restrict filename, char *restrict file_hash); const zend_string *sp_zval_to_zend_string(const zval *); bool sp_match_value(const zend_string* value, const zend_string* to_match, const sp_regexp* rx); bool sp_match_array_key(const zval *, const zend_string *, const sp_regexp *); @@ -83,7 +83,7 @@ bool hook_function(const char *, HashTable *, zif_handler); void unhook_functions(HashTable *ht); int hook_regexp(const sp_pcre *, HashTable *, zif_handler); bool check_is_in_eval_whitelist(const char* function_name); -int sp_log_request(const zend_string *restrict folder, const zend_string *restrict text_repr); +int sp_log_request(zend_string const* const restrict folder, zend_string const* const restrict text_repr); #define sp_zend_string_equals(s1, s2) zend_string_equals((zend_string*)s1, (zend_string*)s2) static inline bool sp_zend_string_equals_str(const zend_string* s1, const char *str, size_t len) { return (ZSTR_LEN(s1) == len && !memcmp(ZSTR_VAL(s1), str, len)); -- cgit v1.3