star-bnl / star-sw

Core software for STAR experiment
26 stars 63 forks source link

Compiler warns about unused and uninitialized variables in StBTofSimMaker/StBTofSimMaker.cxx #149

Closed plexoos closed 1 month ago

plexoos commented 2 years ago

Should be easy to fix

Compilation report (pass 0)
 echo 1 && echo noop && unsetenv NODEBUG && starver gitdev && echo noop && cons
 Success
 .sl73_x8664_gcc485/obj/StRoot/StBTofSimMaker/StBTofSimMaker.cxx: In member function 'int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st*, StBTofCollection*)':
 .sl73_x8664_gcc485/obj/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:824:8: warning: unused variable 'Rawbeta' [-Wunused-variable]
 float Rawbeta=pathL/Rawtof/3e-2;
 ^
 .sl73_x8664_gcc485/obj/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:827:9: warning: unused variable 'calcTof' [-Wunused-variable]
 double calcTof=pathL/(3e-2)/sqrt(1 - mass*mass/(momentum*momentum + mass*mass));
 ^
 .sl73_x8664_gcc485/obj/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:856:8: warning: unused variable 'beta' [-Wunused-variable]
 float beta=pathL/tof/3e-2;
 ^
 echo 2 && echo noop && setenv NODEBUG yes && starver gitdev && echo noop && cons
 Success
 .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx: In member function 'int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st*, StBTofCollection*)':
 .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:824:8: warning: unused variable 'Rawbeta' [-Wunused-variable]
 float Rawbeta=pathL/Rawtof/3e-2;
 ^
 .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:827:9: warning: unused variable 'calcTof' [-Wunused-variable]
 double calcTof=pathL/(3e-2)/sqrt(1 - mass*mass/(momentum*momentum + mass*mass));
 ^
 .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:856:8: warning: unused variable 'beta' [-Wunused-variable]
 float beta=pathL/tof/3e-2;
 ^
 .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx: In member function 'int StBTofSimMaker::CellResponse(g2t_ctf_hit_st*, StBTofSimMaker::TrackVec&)':
 .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:314:44: warning: 'beta' may be used uninitialized in this function [-Wmaybe-uninitialized]
 double clusterDensity = mSimDb->nclus(beta);
 ^
 .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx: In member function 'int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st*, StBTofCollection*)':
 .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:879:44: warning: 'partnerTrkId' may be used uninitialized in this function [-Wmaybe-uninitialized]
 mcBTofHitx->setParentTrackId(partnerTrkId);

Copied from https://www.star.bnl.gov/public/comp/prod/Sanity/AutoBuild-64bits.html

@ZaochenYe @fgeurts @starsdong @jdbrice

Morning-Ye commented 2 years ago

Hi Dmitri,

Please don't worry about these warnings, these variables should not be a problem. I believe they were defined by Daniel or Frank a long time ago, mainly for the simulation part. Now, we are only calling the function defined in this maker to load the resolution table for the nSigmaBTof calculation in data production. If Frank or Daniel may want to comment on this, please go ahead.

Thanks, Zaochen

On Fri, Sep 17, 2021 at 10:06 AM Dmitri Smirnov @.***> wrote:

Should be easy to fix

Compilation report (pass 0) echo 1 && echo noop && unsetenv NODEBUG && starver gitdev && echo noop && cons Success .sl73_x8664_gcc485/obj/StRoot/StBTofSimMaker/StBTofSimMaker.cxx: In member function 'int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st, StBTofCollection)': .sl73_x8664_gcc485/obj/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:824:8: warning: unused variable 'Rawbeta' [-Wunused-variable] float Rawbeta=pathL/Rawtof/3e-2; ^ .sl73_x8664_gcc485/obj/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:827:9: warning: unused variable 'calcTof' [-Wunused-variable] double calcTof=pathL/(3e-2)/sqrt(1 - massmass/(momentummomentum + massmass)); ^ .sl73_x8664_gcc485/obj/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:856:8: warning: unused variable 'beta' [-Wunused-variable] float beta=pathL/tof/3e-2; ^ echo 2 && echo noop && setenv NODEBUG yes && starver gitdev && echo noop && cons Success .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx: In member function 'int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st, StBTofCollection)': .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:824:8: warning: unused variable 'Rawbeta' [-Wunused-variable] float Rawbeta=pathL/Rawtof/3e-2; ^ .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:827:9: warning: unused variable 'calcTof' [-Wunused-variable] double calcTof=pathL/(3e-2)/sqrt(1 - massmass/(momentummomentum + massmass)); ^ .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:856:8: warning: unused variable 'beta' [-Wunused-variable] float beta=pathL/tof/3e-2; ^ .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx: In member function 'int StBTofSimMaker::CellResponse(g2t_ctf_hit_st, StBTofSimMaker::TrackVec&)': .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:314:44: warning: 'beta' may be used uninitialized in this function [-Wmaybe-uninitialized] double clusterDensity = mSimDb->nclus(beta); ^ .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx: In member function 'int StBTofSimMaker::FastCellResponse(g2t_ctf_hit_st, StBTofCollection*)': .sl73_x8664_gcc485/OBJ/StRoot/StBTofSimMaker/StBTofSimMaker.cxx:879:44: warning: 'partnerTrkId' may be used uninitialized in this function [-Wmaybe-uninitialized] mcBTofHitx->setParentTrackId(partnerTrkId);

Copied from https://www.star.bnl.gov/public/comp/prod/Sanity/AutoBuild-64bits.html

@ZaochenYe https://github.com/ZaochenYe @fgeurts https://github.com/fgeurts @starsdong https://github.com/starsdong @jdbrice https://github.com/jdbrice

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/star-bnl/star-sw/issues/149, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSL4IP44FJOLDES752GZO3UCNKPLANCNFSM5EHR3CMQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

plexoos commented 2 years ago

Hi Zaochen, these warnings clutter the build log with useless statements and make it unnecessary longer and harder to parse by human eyes when looking for important warnings or errors. If a variable is not used why do you want to keep it in the code?

Fixing this is a 10-minute job. Don't you want to keep your code clean and neat?

fgeurts commented 2 years ago

Sure. I'll look into fixing these trivial warnings, but this has pretty low priority considering I have a few more urgent tasks at hand but expect to have some more time by the end this month.

-Frank

On Sep 17, 2021, at 11:42 AM, Dmitri Smirnov @.***> wrote:

Hi Zaochen, these warnings clutter the build log with useless statements and make it unnecessary longer and harder to parse by human eyes when looking for important warnings or errors. If a variable is not used why do you want to keep it in the code?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

fgeurts commented 1 month ago

Hi @darkmatterist and @Morning-Ye, can you do a quick PR to solve this outstanding issue. Thanks!

DanielTorres98 commented 1 month ago

This issue was solved.