GNOME Bugzilla – Bug 679094
code review: gsd-updates-firmware.c
Last modified: 2012-07-02 08:56:14 UTC
Some observations while reading through this code: --- request_new has a: if (device == NULL) goto out; but then out: g_object_unref (device); thats not going to go well if device is ever actually NULL. Also, all these early exists can lead to req->id being NULL in the returned request. From what I can see, the struct gets stuffed into priv->array_requested anyway, and then later you run remove_ignored over it, which does ret = g_pattern_match_simple (ignored[j], req->id); which is not going to end well if req->id is NULL. Remember, every gsd crash is a fail whale waiting to happen... --- device_rebind: I also notice that you do: command = g_strdup_printf ("pkexec %s %s", GSD_UPDATES_FIRMWARE_DEVICE_REBIND_PROGRAM, string->str); Thats convenient, but should generally be avoided. Just stuff your arguments into an argv[], no need to convert the string array you already have into a commandline only to have it be parsed again, with the risk of that parsing going wrong... --- I think all the NotifyNotification objects that are created in various places are leaked ? From my reading of the libnotify code, you have to connect to ::closed and unref the notification there - unfortunately, libnotify doesn't keep a ref of its own... --- syspath = g_strjoin (NULL, "/sys", symlink_path, NULL); is a little weird. Why not just g_strconcat ("/sys", symlink_path, NULL); ? The entire code around it is odd, you first concatenate this path, only to split it into segments, and then concatenate it again, multiple times... Anyway, for (i=len; i>1; i--) { split[i] = NULL; Makes it so that split[i] is leaked when you later do g_strfreev (split);
commit 7bc37d12f37081623d6ce6f30de5dd361b80a769 Author: Richard Hughes <richard@hughsie.com> Date: Mon Jul 2 09:54:15 2012 +0100 updates: Refactor some odd code for device searching after a review Fixes: https://bugzilla.gnome.org/show_bug.cgi?id=679094 :100644 100644 47987dd... d3d82e7... M plugins/updates/gsd-updates-firmware.c commit eeea53142c30c467d8a1bff8190c50e8cfdfb678 Author: Richard Hughes <richard@hughsie.com> Date: Mon Jul 2 09:53:19 2012 +0100 updates: Use g_spawn_sync() rather than parsing a constructed command line :100644 100644 52715e6... 47987dd... M plugins/updates/gsd-updates-firmware.c commit abba65433b7f637a18736033e39bdec1666642ce Author: Richard Hughes <richard@hughsie.com> Date: Mon Jul 2 09:52:29 2012 +0100 updates: Prevent a crash if an inserted device requires firmware but is removed before the search completes :100644 100644 140a86d... 52715e6... M plugins/updates/gsd-updates-firmware.c