Closed Bug 1615245 Opened 6 years ago Closed 6 years ago

"fopen-usage" checker should ignore gtest include files

Categories

(Developer Infrastructure :: Source Code Analysis, defect)

defect
Not set
normal

Tracking

(firefox-esr68 unaffected, firefox73 unaffected, firefox74 unaffected, firefox75 fixed)

RESOLVED FIXED
mozilla75
Tracking Status
firefox-esr68 --- unaffected
firefox73 --- unaffected
firefox74 --- unaffected
firefox75 --- fixed

People

(Reporter: emk, Assigned: andi)

References

(Regression)

Details

(Keywords: regression)

Attachments

(1 file)

gtest-port.h spams "fopen-usage" check failure here:
https://searchfox.org/mozilla-central/rev/1db5ef59eba65d32d6a29a494e87b6078453e559/testing/gtest/gtest/include/gtest/internal/gtest-port.h#2517
even though testing/gtest/gtest/ is a third-party path:
https://searchfox.org/mozilla-central/rev/1db5ef59eba65d32d6a29a494e87b6078453e559/tools/rewriting/ThirdPartyPaths.txt#129

A sample warning message:

55:53.93 e:/m/mozilla-unified/obj-x86_64-pc-mingw32/dist/include\gtest/internal/gtest-port.h(2517,10): note: On Windows executed functions: fopen, fopen_s, open, _open, _sopen, _sopen_s, OpenFile, CreateFileA should never be used due to lossy conversion from UTF8 to ANSI.
Assignee: nobody → bpostelnicu

Adding dist/include/gtest/internal/ to ThirdPartyPaths.txt fixed the issue.

Are we sure we want to exclude that from formatting also?

Yes, because they are third-party code. We only import them from upstream.

What I was saying is that we shouldn't include this dist/include/gtest/internal/ into our exclusion, since this is not a path from the tree but a path from the obj directory.

We don't have to care about formatting anyway because we will not edit files under objdir manually and they are not in the repository.

True but we shouldn't add files from build directory to the ThirdPartyPaths.txt.

So how can we exclude them from static analysis?

For start we know that most of the files from the obj/include are in fact symlinks to the appropriate files from the source so we should check if that file is a symlink and if so use real_path.

(In reply to Andi-Bogdan Postelnicu [:andi] from comment #8)

For start we know that most of the files from the obj/include are in fact symlinks

It may not hold on Windows (if objdir is located on FAT32/exFAT voume.) I'm intentionally using this configuration to catch filesystem dependent problems (such as bug 1496050).

I think we can generate a path mapping from <objdir>/install_dist_include.track.

_build_manifests/install/dist_include would be better. python/mozbuild/mozpack/manifests.py is the parser for this file.

How about ignoring gtest namespaces for fopen-usage checker? (like implicit-constructor or explicit-operator-bool) It would be much faster.

Summary: Static analysis checkers should ignore include files from third-party paths → "fopen-usage" checker should ignore gtest namespaces

Or whitelisting "gtest-port.h" is OK (like nan-expr checker.)

Summary: "fopen-usage" checker should ignore gtest namespaces → "fopen-usage" checker should ignore gtest include files

(In reply to Masatoshi Kimura [:emk] from comment #13)

Or whitelisting "gtest-port.h" is OK (like nan-expr checker.)

I think this is the path that we should go, are there any other files that should be added to this exception?

Flags: needinfo?(VYV03354)

:emk Thanks for this, will push a patch shortly.

Attachment #9126894 - Attachment description: Bug 1615245 - checker `fopen-usage` checker should ignore gtest include files. → Bug 1615245 - checker `fopen-usage` checker should ignore gtest include files. r=froydnj
Attachment #9126894 - Attachment description: Bug 1615245 - checker `fopen-usage` checker should ignore gtest include files. r=froydnj → Bug 1615245 - checker `fopen-usage` should ignore some `gtest` include files. r=froydnj
Pushed by bpostelnicu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/e56af64a3199 checker `fopen-usage` should ignore some `gtest` include files. r=froydnj

This will solve it. Thanks!

Flags: needinfo?(bpostelnicu)
Pushed by bpostelnicu@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/5a63e7e8cd4d checker `fopen-usage` should ignore some `gtest` include files. r=froydnj
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla75
Has Regression Range: --- → yes
Product: Firefox Build System → Developer Infrastructure
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: