diff options
| author | jvoisin | 2020-07-08 19:08:58 +0200 |
|---|---|---|
| committer | jvoisin | 2020-07-08 19:08:58 +0200 |
| commit | ae96df0cae20ccb1225a0dc305b4779427506608 (patch) | |
| tree | 657e362f61dbb0015d1623bee285feda104b9179 | |
| parent | decf73be5ac430ce7788ab1c86f64ad9d74602f9 (diff) | |
Add a couple of `restrict`
| -rw-r--r-- | src/sp_utils.c | 15 | ||||
| -rw-r--r-- | src/sp_utils.h | 11 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/sp_utils.c b/src/sp_utils.c index ed5123e..8c64b55 100644 --- a/src/sp_utils.c +++ b/src/sp_utils.c | |||
| @@ -22,7 +22,8 @@ const char* get_ipaddr() { | |||
| 22 | return default_ipaddr; | 22 | return default_ipaddr; |
| 23 | } | 23 | } |
| 24 | 24 | ||
| 25 | void sp_log_msg(char const* feature, int type, const char* fmt, ...) { | 25 | void sp_log_msg(char const* restrict feature, int type, |
| 26 | const char* restrict fmt, ...) { | ||
| 26 | char* msg; | 27 | char* msg; |
| 27 | va_list args; | 28 | va_list args; |
| 28 | 29 | ||
| @@ -52,7 +53,8 @@ void sp_log_msg(char const* feature, int type, const char* fmt, ...) { | |||
| 52 | } | 53 | } |
| 53 | } | 54 | } |
| 54 | 55 | ||
| 55 | int compute_hash(const char* const filename, char* file_hash) { | 56 | int compute_hash(const char* const restrict filename, |
| 57 | char* restrict file_hash) { | ||
| 56 | unsigned char buf[1024]; | 58 | unsigned char buf[1024]; |
| 57 | unsigned char digest[SHA256_SIZE]; | 59 | unsigned char digest[SHA256_SIZE]; |
| 58 | PHP_SHA256_CTX context; | 60 | PHP_SHA256_CTX context; |
| @@ -78,8 +80,9 @@ int compute_hash(const char* const filename, char* file_hash) { | |||
| 78 | return SUCCESS; | 80 | return SUCCESS; |
| 79 | } | 81 | } |
| 80 | 82 | ||
| 81 | static int construct_filename(char* filename, const zend_string* folder, | 83 | static int construct_filename(char* filename, |
| 82 | const zend_string* textual) { | 84 | const zend_string* restrict folder, |
| 85 | const zend_string* restrict textual) { | ||
| 83 | PHP_SHA256_CTX context; | 86 | PHP_SHA256_CTX context; |
| 84 | unsigned char digest[SHA256_SIZE] = {0}; | 87 | unsigned char digest[SHA256_SIZE] = {0}; |
| 85 | char strhash[65] = {0}; | 88 | char strhash[65] = {0}; |
| @@ -103,8 +106,8 @@ static int construct_filename(char* filename, const zend_string* folder, | |||
| 103 | return 0; | 106 | return 0; |
| 104 | } | 107 | } |
| 105 | 108 | ||
| 106 | int sp_log_request(const zend_string* folder, const zend_string* text_repr, | 109 | int sp_log_request(const zend_string* restrict folder, |
| 107 | char* from) { | 110 | const zend_string* restrict text_repr, char* from) { |
| 108 | FILE* file; | 111 | FILE* file; |
| 109 | const char* current_filename = zend_get_executed_filename(TSRMLS_C); | 112 | const char* current_filename = zend_get_executed_filename(TSRMLS_C); |
| 110 | const int current_line = zend_get_executed_lineno(TSRMLS_C); | 113 | const int current_line = zend_get_executed_lineno(TSRMLS_C); |
diff --git a/src/sp_utils.h b/src/sp_utils.h index 6fc59e5..8d1d44a 100644 --- a/src/sp_utils.h +++ b/src/sp_utils.h | |||
| @@ -44,9 +44,10 @@ | |||
| 44 | 44 | ||
| 45 | #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") | 45 | #define GET_SUFFIX(x) (x == 1) ? "st" : ((x == 2) ? "nd" : "th") |
| 46 | 46 | ||
| 47 | const char* get_ipaddr(); | 47 | const char *get_ipaddr(); |
| 48 | void sp_log_msg(char const *feature, int type, const char *fmt, ...); | 48 | void sp_log_msg(char const *restrict feature, int type, |
| 49 | int compute_hash(const char *const filename, char *file_hash); | 49 | const char *restrict fmt, ...); |
| 50 | int compute_hash(const char *const restrict filename, char *restrict file_hash); | ||
| 50 | const zend_string *sp_zval_to_zend_string(const zval *); | 51 | const zend_string *sp_zval_to_zend_string(const zval *); |
| 51 | bool sp_match_value(const zend_string *, const zend_string *, const sp_pcre *); | 52 | bool sp_match_value(const zend_string *, const zend_string *, const sp_pcre *); |
| 52 | bool sp_match_array_key(const zval *, const zend_string *, const sp_pcre *); | 53 | bool sp_match_array_key(const zval *, const zend_string *, const sp_pcre *); |
| @@ -58,8 +59,8 @@ void sp_log_disable_ret(const char *restrict, const zend_string *restrict, | |||
| 58 | int hook_function(const char *, HashTable *, zif_handler); | 59 | int hook_function(const char *, HashTable *, zif_handler); |
| 59 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); | 60 | int hook_regexp(const sp_pcre *, HashTable *, zif_handler); |
| 60 | bool check_is_in_eval_whitelist(const zend_string *const function_name); | 61 | bool check_is_in_eval_whitelist(const zend_string *const function_name); |
| 61 | int sp_log_request(const zend_string *folder, const zend_string *text_repr, | 62 | int sp_log_request(const zend_string *restrict folder, |
| 62 | char *from); | 63 | const zend_string *restrict text_repr, char *from); |
| 63 | bool sp_zend_string_equals(const zend_string *s1, const zend_string *s2); | 64 | bool sp_zend_string_equals(const zend_string *s1, const zend_string *s2); |
| 64 | 65 | ||
| 65 | #endif /* SP_UTILS_H */ | 66 | #endif /* SP_UTILS_H */ |
