GNOME Bugzilla – Bug 780587
Various Coverity code fixes
Last modified: 2017-03-29 13:00:37 UTC
Various minor fixes, mostly on errors paths. Includes one more important fix for sunrise calculations for non-integer timezones.
Created attachment 348788 [details] [review] power: Fix signed/unsigned assignment and comparison The value retrieved from GSettings is a gint, so don’t implicitly cast to to a guint before clamping it to a non-negative value. Coverity ID: 1418248
Created attachment 348789 [details] [review] rfkill: Refactor error handling for cc_rfkill_glib_open() Returning the FD is a bad idea, since ownership of it is already transferred to the GUnixInputStream inside rfkill-glib.c. The only caller (in gsd-rfkill-manager.c) doesn’t use the return value anyway. Tidy this up a bit by using a GError instead. This changes how warning messages are printed, but otherwise introduces no functional changes. Coverity ID: 1418249
Created attachment 348790 [details] [review] housekeeping: Ignore return value from mkdir() calls We don’t care whether they succeed, since there’s nothing we can do if they fail. Notifying the user is fairly pointless, since not having the directories around doesn’t result in a major loss of functionality. Coverity ID: 1418240
Created attachment 348791 [details] [review] clipboard: Fix potential divisions by zero If handling an unknown format of X data, the bytes_per_item will be calculated as zero, which will cause a division by zero. Return early in those cases. Coverity IDs: 1418241, 1418244
Created attachment 348792 [details] [review] color: Potentially fix sunrise calcs for fractional timezone offsets If a timezone is offset by a non-integer number of hours, the value of tz_offset would be truncated. Fix that by casting to double first. Coverity ID: 1418246
Review of attachment 348788 [details] [review]: ::: plugins/power/gsd-power-manager.c @@ +1709,3 @@ timeout_sleep = 0; if (!is_action_inhibited (manager, action_type)) { + gint timeout_sleep_; I prefer _timeout_sleep though.
Review of attachment 348789 [details] [review]: ::: plugins/rfkill/rfkill-glib.c @@ +359,3 @@ } +void Please return a gboolean rather than void, so you can check cc_rfkill_glib_open()'s retval rather than for whether GError is set.
Review of attachment 348790 [details] [review]: Certainly.
Review of attachment 348791 [details] [review]: Sure.
Review of attachment 348792 [details] [review]: There's a test program in gcm-self-test.c, can you please amend it to check for this error? Looks good to commit now though.
Comment on attachment 348791 [details] [review] clipboard: Fix potential divisions by zero Attachment 348791 [details] pushed as 694f27a - clipboard: Fix potential divisions by zero
Attachment 348788 [details] pushed as 74a57e1 - power: Fix signed/unsigned assignment and comparison Attachment 348790 [details] pushed as 968523c - housekeeping: Ignore return value from mkdir() calls
Comment on attachment 348789 [details] [review] rfkill: Refactor error handling for cc_rfkill_glib_open() Pushed to master with a change to return a gboolean. Attachment 348789 [details] pushed as d0bc039 - rfkill: Refactor error handling for cc_rfkill_glib_open()
Comment on attachment 348792 [details] [review] color: Potentially fix sunrise calcs for fractional timezone offsets Pushed the sunrise/sunset fix to master with a change to add a unit test for it (yay for unit tests!). Verified that the fix unbreaks the new test case. Attachment 348792 [details] pushed as e861325 - color: Potentially fix sunrise calcs for fractional timezone offsets
Pushed the potential crasher/incorrectness fixes to gnome-3-24 too: 8bfac91 color: Potentially fix sunrise calcs for fractional timezone offsets 9c5fd32 clipboard: Fix potential divisions by zero