]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
pcre2-util: drop trivial pattern_free() wrapper
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 25 Oct 2025 02:41:55 +0000 (11:41 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 25 Oct 2025 02:43:00 +0000 (11:43 +0900)
src/core/dbus-execute.c
src/journal/journalctl.c
src/journal/journald-client.c
src/shared/pcre2-util.c
src/shared/pcre2-util.h

index 0157665c4a4fa775d0e505be2d8cb7af8ddc1d5b..9b7eb5d76b59b03f3ef66fabed8e373a00199af1 100644 (file)
@@ -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;
index 8c5fd2aed256d1286a6802faeeb6323274842205..95b6cf20dae1c7aa8ff0f65527fa5b6ef9e6c19f 100644 (file)
@@ -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) {
index 6641c09336d37879d2f0e6779d9a914d42def017..b23f7e3b2096eda99f004d7fc085dec7391bf876 100644 (file)
@@ -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)
index f2de0f6f0cf0a5137dec4c2b92fa40d613e4381a..10a767442a4e4064f4c9797c0b9ebbb9ec81fb4d 100644 (file)
@@ -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
-}
index c1d8ba32752d7d3698e24bb7f94ceab08c135629..8c85c6199430aa1241d0d0dbd6a6645e2b60ced5 100644 (file)
@@ -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);