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 674876 - Fix some clang warnings (and a potential leak)
Fix some clang warnings (and a potential leak)
Status: RESOLVED FIXED
Product: mutter
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: mutter-maint
mutter-maint
Depends on:
Blocks:
 
 
Reported: 2012-04-26 14:02 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2012-05-02 14:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
texture-tower: Remove potential leak (972 bytes, patch)
2012-04-26 14:02 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
texture-tower: Remove undefined behavior (1.93 KB, patch)
2012-04-26 14:02 UTC, Jasper St. Pierre (not reading bugmail)
needs-work Details | Review
window-group: Remove an unnecessary assignment (924 bytes, patch)
2012-04-26 14:02 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
default plugin: Remove start method that does nothing (2.24 KB, patch)
2012-04-26 14:02 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
boxes: Remove an unnecessary assignment (749 bytes, patch)
2012-04-26 19:18 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
window: Remove setting of an unused variable (1.54 KB, patch)
2012-04-26 19:18 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
window-actor: Another simple clang warning fix (1.22 KB, patch)
2012-05-01 22:25 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2012-04-26 14:02:40 UTC
Clang warns about a lot of things. Most of them aren't fixable,
because some of the things that clang warns about, gcc either warns
when removed (like potentially unset variables that really aren't),
or are there for consistency with other pieces of code.

But of the ones that are, this patch set fixes them!
Comment 1 Jasper St. Pierre (not reading bugmail) 2012-04-26 14:02:42 UTC
Created attachment 212887 [details] [review]
texture-tower: Remove potential leak

The expression in here does not match the one where we malloc the
data.
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-04-26 14:02:45 UTC
Created attachment 212888 [details] [review]
texture-tower: Remove undefined behavior

Petty, but clang's static analysis complains about this happening, where
it could take both the FALSE and TRUE branches of the
dest_texture_height < source_texture_height condition to end up in a place
where we crash.

Since underflow of unsigned integers is specified, rather than undefined,
this should correct possible semantics.
Comment 3 Jasper St. Pierre (not reading bugmail) 2012-04-26 14:02:48 UTC
Created attachment 212889 [details] [review]
window-group: Remove an unnecessary assignment

Clang warns about this.
Comment 4 Jasper St. Pierre (not reading bugmail) 2012-04-26 14:02:50 UTC
Created attachment 212890 [details] [review]
default plugin: Remove start method that does nothing

All animations use the constants directly, so this is just declaring
a bunch of local variables and then doing nothing with it.

Another clang warning.
Comment 5 Owen Taylor 2012-04-26 14:20:59 UTC
Review of attachment 212887 [details] [review]:

Actually, there's no leak, because  dest_height is always <= dest_texture_heigh, so if dest_texture_height < source_texture_height, dest_height < source_height - so what there actually is instead is a potential g_free (NULL), which is harmless. But yes, it's a bug, and sharp eyes for Clang.
Comment 6 Owen Taylor 2012-04-26 14:25:23 UTC
Review of attachment 212888 [details] [review]:

Well, for starters, mixing guint and unsigned int in the same block isn't OK.

But also I dont' understand the commit message.  (Underflow is a floating-point phenomena)
Comment 7 Jasper St. Pierre (not reading bugmail) 2012-04-26 14:39:53 UTC
Review of attachment 212887 [details] [review]:

Well, it wasn't entirely clang-detected. While adding 'unsigned's to the next patch, it warned about a comparison between signed and unsigned integers.
Comment 8 Jasper St. Pierre (not reading bugmail) 2012-04-26 14:55:05 UTC
Review of attachment 212888 [details] [review]:

All in all, this didn't stop the warning.

I wish I knew why clang's static analysis tool is failing. A developer in #llvm seems to think it's an llvm bug.
Comment 9 Owen Taylor 2012-04-26 15:18:41 UTC
Review of attachment 212889 [details] [review]:

Looks good
Comment 10 Owen Taylor 2012-04-26 15:21:26 UTC
Review of attachment 212890 [details] [review]:

OK
Comment 11 Owen Taylor 2012-04-26 15:22:55 UTC
(In reply to comment #7)
> Review of attachment 212887 [details] [review]:
> 
> Well, it wasn't entirely clang-detected. While adding 'unsigned's to the next
> patch, it warned about a comparison between signed and unsigned integers.

What warning was it giving with the original code?
Comment 12 Jasper St. Pierre (not reading bugmail) 2012-04-26 17:56:18 UTC
LLVM reported bug:

http://llvm.org/bugs/show_bug.cgi?id=12675
Comment 13 Jasper St. Pierre (not reading bugmail) 2012-04-26 19:18:33 UTC
Created attachment 212905 [details] [review]
boxes: Remove an unnecessary assignment

Two more easy clang fixes.
Comment 14 Jasper St. Pierre (not reading bugmail) 2012-04-26 19:18:38 UTC
Created attachment 212906 [details] [review]
window: Remove setting of an unused variable

Well, technically it's used, but only in one block, so let's
just make it scoped to that block.
Comment 15 Jasper St. Pierre (not reading bugmail) 2012-04-29 02:37:50 UTC
Attachment 212887 [details] pushed as cd7a74f - texture-tower: Remove potential leak
Attachment 212889 [details] pushed as 25d3432 - window-group: Remove an unnecessary assignment
Attachment 212890 [details] pushed as ebf8c46 - default plugin: Remove start method that does nothing
Comment 16 Owen Taylor 2012-05-01 15:55:58 UTC
Review of attachment 212905 [details] [review]:

Sure
Comment 17 Owen Taylor 2012-05-01 15:57:19 UTC
Review of attachment 212906 [details] [review]:

Sure
Comment 18 Jasper St. Pierre (not reading bugmail) 2012-05-01 22:25:35 UTC
Created attachment 213250 [details] [review]
window-actor: Another simple clang warning fix

If we explicitly check for a NULL pointer, clang will assume
that the pointer may be NULL at some point. We clearly rely
on the pointer being non-NULL earlier, so fix this guy up.
Comment 19 Jasper St. Pierre (not reading bugmail) 2012-05-01 22:28:24 UTC
Attachment 212905 [details] pushed as a24c512 - boxes: Remove an unnecessary assignment
Attachment 212906 [details] pushed as a78fec7 - window: Remove setting of an unused variable
Comment 20 Owen Taylor 2012-05-02 13:40:57 UTC
Review of attachment 213250 [details] [review]:

Yep
Comment 21 Jasper St. Pierre (not reading bugmail) 2012-05-02 14:20:06 UTC
Attachment 213250 [details] pushed as 878b101 - window-actor: Another simple clang warning fix