From: Yu Watanabe Date: Sat, 25 Oct 2025 02:41:55 +0000 (+0900) Subject: pcre2-util: drop trivial pattern_free() wrapper X-Git-Tag: v259-rc1~246^2~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=63649394ccd539887d9f455d854c1781f9329f14;p=thirdparty%2Fsystemd.git pcre2-util: drop trivial pattern_free() wrapper --- diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c index 0157665c4a4..9b7eb5d76b5 100644 --- a/src/core/dbus-execute.c +++ b/src/core/dbus-execute.c @@ -2039,7 +2039,7 @@ int bus_exec_context_set_transient_property( return r; while ((r = sd_bus_message_read(message, "(bs)", &is_allowlist, &pattern)) > 0) { - _cleanup_(pattern_freep) pcre2_code *compiled_pattern = NULL; + _cleanup_(pcre2_code_freep) pcre2_code *compiled_pattern = NULL; if (isempty(pattern)) continue; diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 8c5fd2aed25..95b6cf20dae 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -126,7 +126,7 @@ STATIC_DESTRUCTOR_REGISTER(arg_machine, freep); STATIC_DESTRUCTOR_REGISTER(arg_namespace, freep); STATIC_DESTRUCTOR_REGISTER(arg_output_fields, set_freep); STATIC_DESTRUCTOR_REGISTER(arg_pattern, freep); -STATIC_DESTRUCTOR_REGISTER(arg_compiled_pattern, pattern_freep); +STATIC_DESTRUCTOR_REGISTER(arg_compiled_pattern, pcre2_code_freep); STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep); static int parse_id_descriptor(const char *x, sd_id128_t *ret_id, int *ret_offset) { diff --git a/src/journal/journald-client.c b/src/journal/journald-client.c index 6641c09336d..b23f7e3b209 100644 --- a/src/journal/journald-client.c +++ b/src/journal/journald-client.c @@ -33,7 +33,7 @@ static int client_parse_log_filter_nulstr(const char *nulstr, size_t len, Set ** return log_oom_debug(); STRV_FOREACH(pattern, patterns_strv) { - _cleanup_(pattern_freep) pcre2_code *compiled_pattern = NULL; + _cleanup_(pcre2_code_freep) pcre2_code *compiled_pattern = NULL; r = pattern_compile_and_log(*pattern, 0, &compiled_pattern); if (r < 0) diff --git a/src/shared/pcre2-util.c b/src/shared/pcre2-util.c index f2de0f6f0cf..10a767442a4 100644 --- a/src/shared/pcre2-util.c +++ b/src/shared/pcre2-util.c @@ -156,17 +156,3 @@ int pattern_matches_and_log(pcre2_code *compiled_pattern, const char *message, s return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "PCRE2 support is not compiled in."); #endif } - -void *pattern_free(pcre2_code *p) { -#if HAVE_PCRE2 - if (!p) - return NULL; - - assert(pcre2_dl); - sym_pcre2_code_free(p); - return NULL; -#else - assert(p == NULL); - return NULL; -#endif -} diff --git a/src/shared/pcre2-util.h b/src/shared/pcre2-util.h index c1d8ba32752..8c85c619943 100644 --- a/src/shared/pcre2-util.h +++ b/src/shared/pcre2-util.h @@ -19,13 +19,18 @@ extern DLSYM_PROTOTYPE(pcre2_match); extern DLSYM_PROTOTYPE(pcre2_get_ovector_pointer); DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pcre2_match_data*, sym_pcre2_match_data_free, pcre2_match_data_freep, NULL); -DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pcre2_code*, sym_pcre2_code_free, pcre2_code_freep, NULL); #else -typedef struct {} pcre2_code; +typedef struct pcre2_code pcre2_code; + +static inline void sym_pcre2_code_free(pcre2_code *p) { + assert(!p); +} #endif +DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(pcre2_code*, sym_pcre2_code_free, pcre2_code_freep, NULL); + extern const struct hash_ops pcre2_code_hash_ops_free; typedef enum PatternCompileCase { @@ -38,8 +43,5 @@ typedef enum PatternCompileCase { int pattern_compile_and_log(const char *pattern, PatternCompileCase case_, pcre2_code **ret); int pattern_matches_and_log(pcre2_code *compiled_pattern, const char *message, size_t size, size_t *ret_ovec); -void *pattern_free(pcre2_code *p); - -DEFINE_TRIVIAL_CLEANUP_FUNC(pcre2_code*, pattern_free); int dlopen_pcre2(void);