After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 732020 - Static analysis fixes
Static analysis fixes
Status: RESOLVED FIXED
Product: ostree
Classification: Infrastructure
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: OSTree maintainer(s)
OSTree maintainer(s)
Depends on:
Blocks:
 
 
Reported: 2014-06-21 22:08 UTC by Colin Walters
Modified: 2014-06-22 00:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[staticanalysis]: Fix two uses of uninitialized variables (1.47 KB, patch)
2014-06-21 22:08 UTC, Colin Walters
committed Details | Review
[staticanalysis]: Add missing va_end() (769 bytes, patch)
2014-06-21 22:08 UTC, Colin Walters
committed Details | Review
[staticanalysis]: Add assertion to pacify analyzer (1.25 KB, patch)
2014-06-21 22:09 UTC, Colin Walters
committed Details | Review
[staticanalysis]: Actually check errors on splice() of objects (1.20 KB, patch)
2014-06-21 22:09 UTC, Colin Walters
committed Details | Review
[staticanalysis]: Fix some dead code (2.60 KB, patch)
2014-06-21 22:09 UTC, Colin Walters
committed Details | Review
[staticanalysis]: Fix in_status_line (1.63 KB, patch)
2014-06-21 22:09 UTC, Colin Walters
committed Details | Review
[staticanalysis]: Delete an unused variable (1.42 KB, patch)
2014-06-21 22:09 UTC, Colin Walters
committed Details | Review

Description Colin Walters 2014-06-21 22:08:48 UTC
Ran the current code through a static analyzer for the first time.
There was only one major bug in WRT error handling of splice() on
writing objects.
Comment 1 Colin Walters 2014-06-21 22:08:50 UTC
Created attachment 278909 [details] [review]
[staticanalysis]: Fix two uses of uninitialized variables
Comment 2 Colin Walters 2014-06-21 22:08:56 UTC
Created attachment 278910 [details] [review]
[staticanalysis]: Add missing va_end()
Comment 3 Colin Walters 2014-06-21 22:09:00 UTC
Created attachment 278911 [details] [review]
[staticanalysis]: Add assertion to pacify analyzer

This condition can't actually be hit, let's hint that's the case.
Comment 4 Colin Walters 2014-06-21 22:09:03 UTC
Created attachment 278912 [details] [review]
[staticanalysis]: Actually check errors on splice() of objects

We were using unsigned size when we should have been using signed,
this means we basically weren't checking for errors on write...ouch.

Luckily if we e.g. hit ENOSPC during a pull, the checksums wouldn't
match and we'd return an error anyways.  However when writing an
object, we'd end up silently ignoring it =/
Comment 5 Colin Walters 2014-06-21 22:09:07 UTC
Created attachment 278913 [details] [review]
[staticanalysis]: Fix some dead code

One was an unused variable, the other is actually dead because we
can't have mfile != NULL.
Comment 6 Colin Walters 2014-06-21 22:09:11 UTC
Created attachment 278914 [details] [review]
[staticanalysis]: Fix in_status_line

We need to end the status line *after* we've done a pull, as ostree
admin upgrade does.  Also add the correct in_status_line assignment.
Comment 7 Colin Walters 2014-06-21 22:09:14 UTC
Created attachment 278915 [details] [review]
[staticanalysis]: Delete an unused variable
Comment 8 Jasper St. Pierre (not reading bugmail) 2014-06-21 22:31:11 UTC
Review of attachment 278909 [details] [review]:

Looks good.
Comment 9 Jasper St. Pierre (not reading bugmail) 2014-06-21 22:44:55 UTC
Review of attachment 278910 [details] [review]:

Yes.
Comment 10 Jasper St. Pierre (not reading bugmail) 2014-06-21 23:02:27 UTC
Review of attachment 278911 [details] [review]:

I did spend 10 minutes or so making sure this was actually the case. The code here can certainly be a lot cleaner.
Comment 11 Jasper St. Pierre (not reading bugmail) 2014-06-21 23:02:52 UTC
Review of attachment 278912 [details] [review]:

Looks good.
Comment 12 Jasper St. Pierre (not reading bugmail) 2014-06-21 23:05:23 UTC
Review of attachment 278913 [details] [review]:

"One, the other" -- there are actually three fixes here. Code looks good.
Comment 13 Jasper St. Pierre (not reading bugmail) 2014-06-21 23:11:13 UTC
Review of attachment 278914 [details] [review]:

OK. It would probably be a bit more convenient to simply have gs_console_end_status_line fizzle out if its in_status_line is FALSE, but that's a separate thing.
Comment 14 Jasper St. Pierre (not reading bugmail) 2014-06-21 23:11:36 UTC
Review of attachment 278915 [details] [review]:

Sure.
Comment 15 Colin Walters 2014-06-22 00:22:10 UTC
Thanks for the review!  Yeah...the commit logic is hairy but hard to
fix without breaking it into separate functions, which I don't think
is worth the cost.

Attachment 278909 [details] pushed as d706797 - [staticanalysis]: Fix two uses of uninitialized variables
Attachment 278910 [details] pushed as dfda6e3 - [staticanalysis]: Add missing va_end()
Attachment 278911 [details] pushed as 2dc0cea - [staticanalysis]: Add assertion to pacify analyzer
Attachment 278912 [details] pushed as 5407998 - [staticanalysis]: Actually check errors on splice() of objects
Attachment 278913 [details] pushed as 5936740 - [staticanalysis]: Fix some dead code
Attachment 278914 [details] pushed as 4d04b14 - [staticanalysis]: Fix in_status_line
Attachment 278915 [details] pushed as 40f99f7 - [staticanalysis]: Delete an unused variable