diff options
| author | jvoisin | 2022-05-03 21:48:35 +0200 |
|---|---|---|
| committer | jvoisin | 2022-05-03 21:48:35 +0200 |
| commit | 7c2d1d7d2713c0fa6bda63c376baf25d9f3d712c (patch) | |
| tree | c894f344fc8e7d8a0d199d96cd8d2083e66a44c7 | |
| parent | af93172be680bb75ebdf23ff6533c53f587da18c (diff) | |
More const frenzy
| -rw-r--r-- | src/sp_config.c | 11 | ||||
| -rw-r--r-- | src/sp_config.h | 6 |
2 files changed, 8 insertions, 9 deletions
diff --git a/src/sp_config.c b/src/sp_config.c index 5431eca..d29247b 100644 --- a/src/sp_config.c +++ b/src/sp_config.c | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | 7 | ||
| 8 | static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) { | 8 | static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) { |
| 9 | sp_config_keyword sp_func[] = { | 9 | static const sp_config_keyword sp_func[] = { |
| 10 | {parse_unserialize, SP_TOKEN_UNSERIALIZE_HMAC, &(SPCFG(unserialize))}, | 10 | {parse_unserialize, SP_TOKEN_UNSERIALIZE_HMAC, &(SPCFG(unserialize))}, |
| 11 | {parse_enable, SP_TOKEN_HARDEN_RANDOM, &(SPCFG(random).enable)}, | 11 | {parse_enable, SP_TOKEN_HARDEN_RANDOM, &(SPCFG(random).enable)}, |
| 12 | {parse_log_media, SP_TOKEN_LOG_MEDIA, &(SPCFG(log_media))}, | 12 | {parse_log_media, SP_TOKEN_LOG_MEDIA, &(SPCFG(log_media))}, |
| @@ -29,7 +29,7 @@ static zend_result sp_process_config_root(sp_parsed_keyword *parsed_rule) { | |||
| 29 | return sp_process_rule(parsed_rule, sp_func); | 29 | return sp_process_rule(parsed_rule, sp_func); |
| 30 | } | 30 | } |
| 31 | 31 | ||
| 32 | zend_result sp_parse_config(const char *filename) { | 32 | zend_result sp_parse_config(const char *const filename) { |
| 33 | FILE *fd = fopen(filename, "rb"); | 33 | FILE *fd = fopen(filename, "rb"); |
| 34 | if (fd == NULL) { | 34 | if (fd == NULL) { |
| 35 | sp_log_err("config", "Could not open configuration file %s : %s", filename, strerror(errno)); | 35 | sp_log_err("config", "Could not open configuration file %s : %s", filename, strerror(errno)); |
| @@ -65,7 +65,7 @@ zend_result sp_parse_config(const char *filename) { | |||
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | 67 | ||
| 68 | zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *config_keywords) { | 68 | zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *const config_keywords) { |
| 69 | for (sp_parsed_keyword *kw = parsed_rule; kw->kw; kw++) { | 69 | for (sp_parsed_keyword *kw = parsed_rule; kw->kw; kw++) { |
| 70 | bool found_kw = false; | 70 | bool found_kw = false; |
| 71 | for (const sp_config_keyword *ckw = config_keywords; ckw->func; ckw++) { | 71 | for (const sp_config_keyword *ckw = config_keywords; ckw->func; ckw++) { |
| @@ -119,13 +119,12 @@ SP_PARSEKW_FN(parse_list) { | |||
| 119 | CHECK_DUPLICATE_KEYWORD(retval); | 119 | CHECK_DUPLICATE_KEYWORD(retval); |
| 120 | 120 | ||
| 121 | sp_list_node **list = retval; | 121 | sp_list_node **list = retval; |
| 122 | char *tok, *tmp; | ||
| 123 | 122 | ||
| 124 | SP_PARSE_ARG(value); | 123 | SP_PARSE_ARG(value); |
| 125 | 124 | ||
| 126 | tmp = ZSTR_VAL(value); | 125 | char* tmp = ZSTR_VAL(value); |
| 127 | while (1) { | 126 | while (1) { |
| 128 | tok = strsep(&tmp, ","); | 127 | const char* const tok = strsep(&tmp, ","); |
| 129 | if (tok == NULL) { | 128 | if (tok == NULL) { |
| 130 | break; | 129 | break; |
| 131 | } | 130 | } |
diff --git a/src/sp_config.h b/src/sp_config.h index 87710a0..3d92f2f 100644 --- a/src/sp_config.h +++ b/src/sp_config.h | |||
| @@ -176,7 +176,7 @@ typedef struct { | |||
| 176 | HashTable *entries; // ht of sp_ini_entry | 176 | HashTable *entries; // ht of sp_ini_entry |
| 177 | } sp_config_ini; | 177 | } sp_config_ini; |
| 178 | 178 | ||
| 179 | #define SP_PARSE_FN_(fname, kwvar) int fname(char *token, sp_parsed_keyword *kwvar, void *retval) | 179 | #define SP_PARSE_FN_(fname, kwvar) int fname(char const *const token, sp_parsed_keyword *kwvar, void *retval) |
| 180 | #define SP_PARSE_FN(fname) SP_PARSE_FN_(fname, parsed_rule) | 180 | #define SP_PARSE_FN(fname) SP_PARSE_FN_(fname, parsed_rule) |
| 181 | #define SP_PARSEKW_FN(fname) SP_PARSE_FN_(fname, kw) | 181 | #define SP_PARSEKW_FN(fname) SP_PARSE_FN_(fname, kw) |
| 182 | 182 | ||
| @@ -269,9 +269,9 @@ typedef struct { | |||
| 269 | 269 | ||
| 270 | #define SP_TOKEN_LIST "list" | 270 | #define SP_TOKEN_LIST "list" |
| 271 | 271 | ||
| 272 | zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *config_keywords); | 272 | zend_result sp_process_rule(sp_parsed_keyword *parsed_rule, const sp_config_keyword *const config_keywords); |
| 273 | 273 | ||
| 274 | zend_result sp_parse_config(const char *filename); | 274 | zend_result sp_parse_config(const char *const filename); |
| 275 | 275 | ||
| 276 | #define SP_PARSE_CHECK_ARG_EXISTS(value) \ | 276 | #define SP_PARSE_CHECK_ARG_EXISTS(value) \ |
| 277 | if (!value) { \ | 277 | if (!value) { \ |
