Bug 24550

Summary: Compiler warning for XMLTokenizerLibxml2.cpp
Product: WebKit Reporter: Craig Schlenter <craig.schlenter>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: Linux   
Attachments:
Description Flags
patch to fix compiler warning dglazkov: review+

Description Craig Schlenter 2009-03-12 10:32:23 PDT
gcc 4.3.3 throws out warnings about the return value of vasprintf being unused.

An example of the compilation failure is seen here in chromium where -Werror makes the compilation fail

http://code.google.com/p/chromium/issues/detail?id=7742#c23

I'll attach a patch which I unfortunately can't test as I can't get webkit svn to build at the moment.
Comment 1 Craig Schlenter 2009-03-12 10:34:11 PDT
Created attachment 28532 [details]
patch to fix compiler warning

untested patch to fix compiler warning
Comment 2 Darin Adler 2009-03-12 13:06:17 PDT
Comment on attachment 28532 [details]
patch to fix compiler warning

Is this really the only unused result warning in WebCore? If not, then why are we fixing this one case?
Comment 3 Craig Schlenter 2009-03-12 21:42:25 PDT
I've asked the original reporter for more feedback in the chromium issue tracker to see if there are other warnings/errors. I had originally assumed that one of the webkit merges introduced this problem but the vasprintf seems to have been there for ages according to svn blame so I need to dig a bit more to see why it's only showing up now as the reporter was compiling successfully before.

I unfortunately don't have the same compiler as the reporter btw. but I'll see if I can coax my machine (Fedora 9) into using a newer compiler and investigate this properly.

In this particular case btw., if the vasprintf call fails the invalid buffer returned by vasprintf will be freed a couple of lines further on which will probably result in a crash although arguably if that is failing not much else is likely to work either.

Thank you.
Comment 4 Craig Schlenter 2009-03-13 12:17:12 PDT
I think I know why the chromium reporter sees this and I don't even after upgrading my fedora 9 system to gcc 4.4.0 and glibc-2.9.90 ... it seems as if ubuntu 8.10 has some default compiler flag settings that include FORTIFY_SOURCE that is activated at -O2 and higher: https://wiki.ubuntu.com/CompilerFlags

I'll fiddle with getting my machine into equivalent shape tomorrow and track down the related errors/warnings ....
Comment 5 Craig Schlenter 2009-03-15 07:51:42 PDT
After compiling with -D_FORTIFY_SOURCE=2 this seems to be the only warn_unused_result. GCC-4.4.0 has shown up some other issues (a missing include and possibly some strict aliasing issues) but I'll file separate bugs for those.

Thank you.
Comment 6 Dimitri Glazkov (Google) 2009-03-30 15:24:05 PDT
Comment on attachment 28532 [details]
patch to fix compiler warning

Sounds good.
Comment 7 Dmitry Titov 2009-03-31 13:24:21 PDT
Landed: http://trac.webkit.org/changeset/42139

Please add the link to the bug into ChangeLog description next time.