neil / rpms / udisks2

Forked from rpms/udisks2 a year ago
Clone
Blob Blame History Raw
From 0353b5f2f9c586d872750423259b6ef6cc375625 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Fri, 16 Apr 2021 18:22:46 +0200
Subject: [PATCH 6/8] udiskslinuxmdraidobject: Optimize unused data out from
 the g_io_channel_read_to_end() call

Looking into glib sources the g_io_channel_read_to_end() function
can handle NULL output pointers just fine and since the data is thrown
right away it's pointless to have them assigned.
---
 src/udiskslinuxmdraidobject.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/src/udiskslinuxmdraidobject.c b/src/udiskslinuxmdraidobject.c
index 759ff5f4..20ca89c5 100644
--- a/src/udiskslinuxmdraidobject.c
+++ b/src/udiskslinuxmdraidobject.c
@@ -503,8 +503,6 @@ attr_changed (GIOChannel   *channel,
   UDisksLinuxMDRaidObject *object = UDISKS_LINUX_MDRAID_OBJECT (user_data);
   gboolean bail = FALSE;
   GError *error = NULL;
-  gchar *str = NULL;
-  gsize len = 0;
 
   if (cond & ~G_IO_ERR)
     goto out;
@@ -518,7 +516,7 @@ attr_changed (GIOChannel   *channel,
       goto out;
     }
 
-  if (g_io_channel_read_to_end (channel, &str, &len, &error) != G_IO_STATUS_NORMAL)
+  if (g_io_channel_read_to_end (channel, NULL, NULL, &error) != G_IO_STATUS_NORMAL)
     {
       udisks_debug ("Error reading (uuid %s): %s (%s, %d)",
                     object->uuid, error->message, g_quark_to_string (error->domain), error->code);
@@ -527,8 +525,6 @@ attr_changed (GIOChannel   *channel,
       goto out;
     }
 
-  g_free (str);
-
   /* synthesize uevent */
   if (object->raid_device != NULL)
     udisks_linux_mdraid_object_uevent (object, "change", object->raid_device, FALSE);
-- 
2.30.2