Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CORE] [Clang]Cleanup clang-analyzer warnings #46259

Merged
merged 3 commits into from
Oct 8, 2024

Conversation

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2024

cms-bot internal usage

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2024

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 4, 2024

A new Pull Request was created by @smuzaffar for master.

It involves the following packages:

  • Utilities/StaticAnalyzers (core)
  • Utilities/StorageFactory (core)

@Dr15Jones, @cmsbuild, @makortel, @smuzaffar can you please review it and eventually sign? Thanks.
@wddgit this is something you requested to watch as well.
@antoniovilela, @mandrenguyen, @rappoccio, @sextonkennedy you are the release manager for this.

cms-bot commands are listed here

@makortel
Copy link
Contributor

makortel commented Oct 4, 2024

FYI @gartung for the static analyzer (changes look good to me)

@gartung
Copy link
Member

gartung commented Oct 4, 2024

Looks OK to me. The asserts should cause the checker to exit with error, but the checker build will continue.

Utilities/StorageFactory/src/LocalFileSystem.cc Outdated Show resolved Hide resolved
@@ -361,6 +361,7 @@ LocalFileSystem::FSInfo *LocalFileSystem::findMount(const char *path,

prev_paths.push_back(path);
LocalFileSystem::FSInfo *new_best = findMount(fullpath, &sfs2, &s2, prev_paths);
free(fullpath);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using a unique_ptr for the fullpath, e.g.

std::unique_ptr<char, decltype(std::free)> fullpath{realpath(best->origin, nullptr), std::free};

if (!fullpath)
  fullpath.reset(strdup(best->origin));

removing the free(fullpath) calls and replacing the accesses with fullpath.get()?

In principle the code could be updated to use std::filesystem, but that sounds a lot more work that would have to be done with care.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@makortel , I have tried std::unique_ptr and after replacing fullpath tofullpath.get() and few other places (lstat, statfs, findMount need const char*) I got build error

In file included from /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/unique_ptr.h:36,
                 from /cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/memory:75,
                 from /cvmfs/cms-ib.cern.ch/sw/x86_64/week0/el8_amd64_gcc12/cms/cmssw/CMSSW_14_2_X_2024-10-06-2300/src/FWCore/MessageLogger/interface/MessageLogger.h:23,
                 from src/Utilities/StorageFactory/src/LocalFileSystem.cc:4:
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple: In instantiation of 'struct std::_Head_base<1, void(void*) noexcept, false>':
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:416:12:   required from 'struct std::_Tuple_impl<1, void(void*) noexcept>'
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:258:12:   required from 'struct std::_Tuple_impl<0, char*, void(void*) noexcept>'
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:981:11:   required from 'class std::tuple<char*, void(void*) noexcept>'
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/unique_ptr.h:224:27:   required from 'class std::__uniq_ptr_impl<char, void(void*) noexcept>'
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/unique_ptr.h:255:12:   required from 'struct std::__uniq_ptr_data<char, void(void*) noexcept, false, false>'
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/bits/unique_ptr.h:275:33:   required from 'class std::unique_ptr<char, void(void*) noexcept>'
src/Utilities/StorageFactory/src/LocalFileSystem.cc:341:48:   required from here
/cvmfs/cms-ib.cern.ch/sw/x86_64/nweek-02858/el8_amd64_gcc12/external/gcc/12.3.1-40d504be6370b5a30e3947a6e575ca28/include/c++/12.3.1/tuple:238:13: error: data member 'std::_Head_base<1, void(void*) noexcept, false>::_M_head_impl' invalidly declared function type
  238 |       _Head _M_head_impl;
      |             ^~~~~~~~~~~~
src/Utilities/StorageFactory/src/LocalFileSystem.cc: In member function 'edm::storage::LocalFileSystem::FSInfo* edm::storage::LocalFileSystem::findMount(const char*, statfs*, stat*, std::vector<std::__cxx11::basic_string<char> >&) const':
src/Utilities/StorageFactory/src/LocalFileSystem.cc:341:100: error: no matching function for call to 'std::unique_ptr<char, void(void*) noexcept>::unique_ptr(<brace-enclosed initializer list>)'
  341 |     std::unique_ptr<char, decltype(std::free)> full_path{realpath(best->origin, nullptr), std::free};

If I change

std::unique_ptr<char, decltype(std::free)> fullpath{realpath(best->origin, nullptr), std::free};

to

std::unique_ptr<char, decltype(std::free) *> fullpath{realpath(best->origin, nullptr), std::free};

then build error go away. So is std::unique_ptr<char, decltype(std::free) *> the correct thing touse in this case?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is std::unique_ptr<char, decltype(std::free) *> the correct thing touse in this case?

Ah, yes, it is the correct type. Sorry for omitting the *.

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 7, 2024

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 7, 2024

Pull request #46259 was updated. @Dr15Jones, @cmsbuild, @makortel, @smuzaffar can you please check and sign again.

@smuzaffar
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 7, 2024

+1

Size: This PR adds an extra 20KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-965b2b/42005/summary.html
COMMIT: 3f2c77c
CMSSW: CMSSW_14_2_X_2024-10-06-2300/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/46259/42005/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

  • You potentially added 2 lines to the logs
  • Reco comparison results: 14 differences found in the comparisons
  • DQMHistoTests: Total files compared: 44
  • DQMHistoTests: Total histograms compared: 3331336
  • DQMHistoTests: Total failures: 8
  • DQMHistoTests: Total nulls: 0
  • DQMHistoTests: Total successes: 3331308
  • DQMHistoTests: Total skipped: 20
  • DQMHistoTests: Total Missing objects: 0
  • DQMHistoSizes: Histogram memory added: 0.0 KiB( 43 files compared)
  • Checked 193 log files, 163 edm output root files, 44 DQM output files
  • TriggerResults: no differences found

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 7, 2024

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 7, 2024

Pull request #46259 was updated. @Dr15Jones, @cmsbuild, @makortel, @smuzaffar can you please check and sign again.

@smuzaffar
Copy link
Contributor Author

please test

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 7, 2024

+1

Size: This PR adds an extra 20KB to repository
Summary: https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/PR-965b2b/42027/summary.html
COMMIT: 49c17d9
CMSSW: CMSSW_14_2_X_2024-10-07-1100/el8_amd64_gcc12
User test area: For local testing, you can use /cvmfs/cms-ci.cern.ch/week0/cms-sw/cmssw/46259/42027/install.sh to create a dev area with all the needed externals and cmssw changes.

Comparison Summary

Summary:

@makortel
Copy link
Contributor

makortel commented Oct 7, 2024

Comparison differences are related to #39803

@makortel
Copy link
Contributor

makortel commented Oct 7, 2024

+core

@cmsbuild
Copy link
Contributor

cmsbuild commented Oct 7, 2024

This pull request is fully signed and it will be integrated in one of the next master IBs (tests are also fine). This pull request will now be reviewed by the release team before it's merged. @mandrenguyen, @antoniovilela, @sextonkennedy, @rappoccio (and backports should be raised in the release meeting by the corresponding L2)

@mandrenguyen
Copy link
Contributor

+1

@cmsbuild cmsbuild merged commit aaf9cc0 into cms-sw:master Oct 8, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants