Bug 151888 - TestNetscapePlugIn: Fix remaining static analyzer warnings
Summary: TestNetscapePlugIn: Fix remaining static analyzer warnings
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-04 15:42 PST by David Kilzer (:ddkilzer)
Modified: 2015-12-04 20:32 PST (History)
3 users (show)

See Also:


Attachments
Patch v1 (3.82 KB, patch)
2015-12-04 15:50 PST, David Kilzer (:ddkilzer)
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2015-12-04 15:42:45 PST
Fix the remaining static analyzer warnings in TestNetscapePlugIn:

Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp:101:9: warning: Called function pointer is null (null dereference)
        CRASH();
        ^~~~~~~
Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp:46:5: note: expanded from macro 'CRASH'
    ((void(*)())0)(); /* More reliable, but doesn't say BBADBEEF */ \
    ^~~~~~~~~~~~~~~~
Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp:375:12: warning: Access to field 'pluginTest' results in a dereference of a null pointer (loaded from variable 'obj')
    return obj->pluginTest->NPP_SetWindow(window);
           ^~~~~~~~~~~~~~~
2 warnings generated.

The first issue requires using __builtin_trap() on clang/gcc builds.

The second is just a matter of adding an early return.
Comment 1 David Kilzer (:ddkilzer) 2015-12-04 15:50:52 PST
Created attachment 266670 [details]
Patch v1
Comment 2 Alexey Proskuryakov 2015-12-04 16:13:24 PST
Comment on attachment 266670 [details]
Patch v1

View in context: https://bugs.webkit.org/attachment.cgi?id=266670&action=review

> Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp:47
> +    *(int *)(uintptr_t)0xbbadbeef = 0; \
> +    __builtin_trap(); /* More reliable, but doesn't say BBADBEEF. */ \

This comment is not relevant any more, __builtin_trap crashes are perfectly identifiable. I don't think that we need the 0xbbadbeef variant at all.

That said, WTF also still does the same, so we should probably be consistent.
Comment 3 David Kilzer (:ddkilzer) 2015-12-04 19:48:41 PST
(In reply to comment #2)
> Comment on attachment 266670 [details]
> Patch v1
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=266670&action=review
> 
> > Tools/DumpRenderTree/TestNetscapePlugIn/main.cpp:47
> > +    *(int *)(uintptr_t)0xbbadbeef = 0; \
> > +    __builtin_trap(); /* More reliable, but doesn't say BBADBEEF. */ \
> 
> This comment is not relevant any more, __builtin_trap crashes are perfectly
> identifiable. I don't think that we need the 0xbbadbeef variant at all.
> 
> That said, WTF also still does the same, so we should probably be consistent.

+1 for consistency.
Comment 4 WebKit Commit Bot 2015-12-04 20:32:06 PST
Comment on attachment 266670 [details]
Patch v1

Clearing flags on attachment: 266670

Committed r193509: <http://trac.webkit.org/changeset/193509>
Comment 5 WebKit Commit Bot 2015-12-04 20:32:09 PST
All reviewed patches have been landed.  Closing bug.