]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/bus-get-properties: use sizeof instead of hardcoded size in bus_property_get_i... 39407/head
authorMike Yuan <me@yhndnzj.com>
Sun, 5 Oct 2025 01:15:36 +0000 (03:15 +0200)
committerMike Yuan <me@yhndnzj.com>
Wed, 22 Oct 2025 12:44:50 +0000 (14:44 +0200)
Prompted by
https://github.com/systemd/systemd/pull/39210#discussion_r2404225907

src/shared/bus-get-properties.c

index 6d6d52bd4c413c19f6d7e2be97542e9094ff521e..ffbe2b7930b67374231ea51efe28b51b250847c5 100644 (file)
@@ -70,12 +70,12 @@ int bus_property_get_id128(
                 void *userdata,
                 sd_bus_error *reterr_error) {
 
-        sd_id128_t *id = userdata;
+        sd_id128_t *id = ASSERT_PTR(userdata);
 
         if (sd_id128_is_null(*id)) /* Add an empty array if the ID is zero */
                 return sd_bus_message_append(reply, "ay", 0);
-        else
-                return sd_bus_message_append_array(reply, 'y', id->bytes, 16);
+
+        return sd_bus_message_append_array(reply, 'y', id->bytes, sizeof(sd_id128_t));
 }
 
 #if __SIZEOF_SIZE_T__ != 8