[Rpm-maint] [rpm-software-management/rpm] Extend dbus-announce plugin (PR #3532)

Panu Matilainen notifications at github.com
Mon Feb 24 11:42:08 UTC 2025


@pmatilai commented on this pull request.



> @@ -103,9 +119,77 @@ static rpmRC send_ts_message(rpmPlugin plugin,
 
     dbcookie = rpmdbCookie(rpmtsGetRdb(ts));
     rpm_tid_t tid = rpmtsGetTid(ts);
+
+    if (!dbus_message_append_args(msg,
+				  DBUS_TYPE_STRING, &dbcookie,
+				  DBUS_TYPE_UINT32, &tid,
+				  DBUS_TYPE_INVALID))
+	goto err;
+
+    if (!dbus_connection_send(state->bus, msg, NULL))
+	goto err;
+
+    if (snprintf(detail_name, sizeof(detail_name), "%sDetails", name) >= sizeof(detail_name)) {

> My intention here was to avoid unnecessary memory allocation, for a well-known string, controlled in the code, not passed from the outside. It's concatenating one static string with another here.

This is a bad "optimization" because it replaces what is a trivial operation for the computer in a non-hotspot code with size checks that *humans* now need to reason about. What could possibly go wrong?

Just use rasprintf() and never mind the mallocs.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/rpm-software-management/rpm/pull/3532#discussion_r1967482223
You are receiving this because you are subscribed to this thread.

Message ID: <rpm-software-management/rpm/pull/3532/review/2636809764 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rpm.org/pipermail/rpm-maint/attachments/20250224/20b65c43/attachment-0001.htm>


More information about the Rpm-maint mailing list