]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cgroup-util: rename cg_get_xattr_malloc -> cg_get_xattr
authorMike Yuan <me@yhndnzj.com>
Tue, 27 May 2025 12:15:11 +0000 (14:15 +0200)
committerMike Yuan <me@yhndnzj.com>
Tue, 27 May 2025 12:28:08 +0000 (14:28 +0200)
This is not a trivial wrapper around user-created-buffer-based
syscall, so do not use _malloc suffix. Most of our functions
return an internally allocated buffer and this one's not special.

src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/core/cgroup.c
src/journal/journald-client.c
src/oom/oomd-util.c
src/oom/test-oomd-util.c

index 4ceec690ab61dd260ab526bca5beb833f8617638..0c39660a9ae188ed90a19ca94afc4fcba07695dd 100644 (file)
@@ -592,7 +592,7 @@ int cg_set_xattr(const char *path, const char *name, const void *value, size_t s
         return RET_NERRNO(setxattr(fs, name, value, size, flags));
 }
 
-int cg_get_xattr_malloc(const char *path, const char *name, char **ret, size_t *ret_size) {
+int cg_get_xattr(const char *path, const char *name, char **ret, size_t *ret_size) {
         _cleanup_free_ char *fs = NULL;
         int r;
 
index 27778dabedbb178792f17320dc81089c02d7d622..6a5f92a177293d258a240b5ba386d011a8c09338 100644 (file)
@@ -226,7 +226,7 @@ int cg_get_attribute_as_bool(const char *controller, const char *path, const cha
 int cg_get_owner(const char *path, uid_t *ret_uid);
 
 int cg_set_xattr(const char *path, const char *name, const void *value, size_t size, int flags);
-int cg_get_xattr_malloc(const char *path, const char *name, char **ret, size_t *ret_size);
+int cg_get_xattr(const char *path, const char *name, char **ret, size_t *ret_size);
 /* Returns negative on error, and 0 or 1 on success for the bool value */
 int cg_get_xattr_bool(const char *path, const char *name);
 int cg_remove_xattr(const char *path, const char *name);
index abaffb22cde4bc949d90cef3835ae00bc8aa149e..d7d5983c8d83472f31860655065e0af4806d11bc 100644 (file)
@@ -3020,7 +3020,7 @@ int unit_check_oomd_kill(Unit *u) {
         if (!crt || !crt->cgroup_path)
                 return 0;
 
-        r = cg_get_xattr_malloc(crt->cgroup_path, "user.oomd_ooms", &value, /* ret_size= */ NULL);
+        r = cg_get_xattr(crt->cgroup_path, "user.oomd_ooms", &value, /* ret_size= */ NULL);
         if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r))
                 return r;
 
@@ -3038,7 +3038,7 @@ int unit_check_oomd_kill(Unit *u) {
 
         n = 0;
         value = mfree(value);
-        r = cg_get_xattr_malloc(crt->cgroup_path, "user.oomd_kill", &value, /* ret_size= */ NULL);
+        r = cg_get_xattr(crt->cgroup_path, "user.oomd_kill", &value, /* ret_size= */ NULL);
         if (r >= 0 && !isempty(value))
                 (void) safe_atou64(value, &n);
 
index 1611395e947c778d6933ae8f8b3350971e1d8c8a..659b9c5e88ff4892a23546092da090969edbdea2 100644 (file)
@@ -61,7 +61,7 @@ int client_context_read_log_filter_patterns(ClientContext *c, const char *cgroup
 
         _cleanup_free_ char *xattr = NULL;
         size_t xattr_size = 0;
-        r = cg_get_xattr_malloc(unit_cgroup, "user.journald_log_filter_patterns", &xattr, &xattr_size);
+        r = cg_get_xattr(unit_cgroup, "user.journald_log_filter_patterns", &xattr, &xattr_size);
         if (ERRNO_IS_NEG_XATTR_ABSENT(r)) {
                 client_set_filtering_patterns(c, /* allow_list= */ NULL, /* deny_list= */ NULL);
                 return 0;
index de0f2e685409db142cbfa212db55f871e6122926..4b0e4a54aab17e4eeb9e9b23b562e72004b99423 100644 (file)
@@ -41,7 +41,7 @@ static int increment_oomd_xattr(const char *path, const char *xattr, uint64_t nu
         assert(path);
         assert(xattr);
 
-        r = cg_get_xattr_malloc(path, xattr, &value, /* ret_size= */ NULL);
+        r = cg_get_xattr(path, xattr, &value, /* ret_size= */ NULL);
         if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r))
                 return r;
 
index 3c5159129f73dd91a9c42364c535084e3ca71a97..6ab6f101ff3bddc6355f2ee9f096315a9d1c67a5 100644 (file)
@@ -74,7 +74,7 @@ static void test_oomd_cgroup_kill(void) {
                         abort();
                 }
 
-                ASSERT_OK(cg_get_xattr_malloc(cgroup, "user.oomd_ooms", &v, /* ret_size= */ NULL));
+                ASSERT_OK(cg_get_xattr(cgroup, "user.oomd_ooms", &v, /* ret_size= */ NULL));
                 assert_se(streq(v, i == 0 ? "1" : "2"));
                 v = mfree(v);
 
@@ -82,7 +82,7 @@ static void test_oomd_cgroup_kill(void) {
                 sleep(2);
                 assert_se(cg_is_empty(SYSTEMD_CGROUP_CONTROLLER, cgroup) == true);
 
-                ASSERT_OK(cg_get_xattr_malloc(cgroup, "user.oomd_kill", &v, /* ret_size= */ NULL));
+                ASSERT_OK(cg_get_xattr(cgroup, "user.oomd_kill", &v, /* ret_size= */ NULL));
                 assert_se(streq(v, i == 0 ? "2" : "4"));
         }
 }