-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Conversation
cms-bot internal usage |
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46259/42082 |
A new Pull Request was created by @smuzaffar for master. It involves the following packages:
@Dr15Jones, @cmsbuild, @makortel, @smuzaffar can you please review it and eventually sign? Thanks. cms-bot commands are listed here |
FYI @gartung for the static analyzer (changes look good to me) |
Looks OK to me. The asserts should cause the checker to exit with error, but the checker build will continue. |
@@ -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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 *
.
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46259/42100 |
Pull request #46259 was updated. @Dr15Jones, @cmsbuild, @makortel, @smuzaffar can you please check and sign again. |
please test |
+1 Size: This PR adds an extra 20KB to repository Comparison SummarySummary:
|
Co-authored-by: Matti Kortelainen <[email protected]>
+code-checks Logs: https://cmssdt.cern.ch/SDT/code-checks/cms-sw-PR-46259/42112 |
Pull request #46259 was updated. @Dr15Jones, @cmsbuild, @makortel, @smuzaffar can you please check and sign again. |
please test |
+1 Size: This PR adds an extra 20KB to repository Comparison SummarySummary:
|
Comparison differences are related to #39803 |
+core |
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) |
+1 |
This PR fixes clang-analyzer warnings