[fixed] [sketcher] unreferenced local variables

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

[fixed] [sketcher] unreferenced local variables

Post by uwestoehr »

Hi abdullah, while recompiling sketcher I noticed these warnings you might want to have a look at:

Code: Select all

2>D:\FreeCADGit\src\Mod\Sketcher\Gui\TaskSketcherConstrains.cpp(756,48): warning C4101: 'e': unreferenced local variable
2>D:\FreeCADGit\src\Mod\Sketcher\Gui\TaskSketcherConstrains.cpp(1004,44): warning C4101: 'e': unreferenced local variable
2>D:\FreeCADGit\src\Mod\Sketcher\Gui\TaskSketcherConstrains.cpp(1022,44): warning C4101: 'e': unreferenced local variable
abdullah wrote: .
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: [sketcher] unreferenced local variables

Post by openBrain »

Indeed. We can add a

Code: Select all

(void) e
at the beginning of each catch block.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [sketcher] unreferenced local variables

Post by abdullah »

openBrain wrote: Sat Sep 25, 2021 11:37 am Indeed. We can add a

Code: Select all

(void) e
at the beginning of each catch block.
uwestoehr wrote: Sat Sep 25, 2021 1:29 am Hi abdullah, while recompiling sketcher I noticed these warnings you might want to have a look at:
Thanks. I will fix that.

This is because I do not clean before recompiling, so it gets shown only once. If I do not see it that time, I miss it forever. I try to clean and recompile (I use ccache so it is not the end of the world) to catch this things.

If the "e" is not used in the block at all, the best solution is just to delete the "e". That should fix the issue.
abdullah
Veteran
Posts: 4935
Joined: Sun May 04, 2014 3:16 pm
Contact:

Re: [sketcher] unreferenced local variables

Post by abdullah »

Oddly, I have tried to force showing this warning by cleaning the directory and recompiling all and I cannot see the warning in my Kdevelop output. I see other warnings (MPI, progressbar,...), but not the unreferenced local variables one...
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [sketcher] unreferenced local variables

Post by uwestoehr »

abdullah wrote: Sat Sep 25, 2021 7:01 pm Oddly, I have tried to force showing this warning by cleaning the directory and recompiling all and I cannot see the warning in my Kdevelop output.
Many thanks for the fix.
I encountered the same - KDevelop does not show warnings as MSVC does. Meanwhile I am only with MSVC (and Windows) and is the vast majority of the cases, its warnings are sensible.

In case I encounter more MSVC warnings regarding sketcher I will inform you.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: [sketcher] unreferenced local variables

Post by openBrain »

uwestoehr wrote: Sun Sep 26, 2021 2:26 pm Many thanks for the fix.
I encountered the same - KDevelop does not show warnings as MSVC does. Meanwhile I am only with MSVC (and Windows) and is the vast majority of the cases, its warnings are sensible.

In case I encounter more MSVC warnings regarding sketcher I will inform you.
Looks like you too introduced unused variables. :)

Code: Select all

/home/OB/dev/FreeCAD/src/Mod/PartDesign/Gui/TaskPadParameters.cpp: In member function ‘void PartDesignGui::TaskPadParameters::onDirectionCBChanged(int)’:
/home/OB/dev/FreeCAD/src/Mod/PartDesign/Gui/TaskPadParameters.cpp:443:30: warning: unused variable ‘newRefAxis’ [-Wunused-variable]
  443 |         App::DocumentObject* newRefAxis = propReferenceAxis->getValue();
      |                              ^~~~~~~~~~
/home/OB/dev/FreeCAD/src/Mod/PartDesign/Gui/TaskPadParameters.cpp:417:26: warning: unused variable ‘oldRefAxis’ [-Wunused-variable]
  417 |     App::DocumentObject* oldRefAxis = propReferenceAxis->getValue();
      | 
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [sketcher] unreferenced local variables

Post by uwestoehr »

openBrain wrote: Tue Sep 28, 2021 7:48 am Looks like you too introduced unused variables. :)

Code: Select all

/home/OB/dev/FreeCAD/src/Mod/PartDesign/Gui/TaskPadParameters.cpp: 
There are some issues with pad and I already made a PR that should fix this too:
https://github.com/FreeCAD/FreeCAD/pull/5071

(At least with MSVC I don't get any warnings).
Can you please inform me when this PR is in but you still get unreferenced variables? Thanks.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: [sketcher] unreferenced local variables

Post by openBrain »

uwestoehr wrote: Tue Sep 28, 2021 11:14 am There are some issues with pad and I already made a PR that should fix this too:
https://github.com/FreeCAD/FreeCAD/pull/5071

(At least with MSVC I don't get any warnings).
Can you please inform me when this PR is in but you still get unreferenced variables? Thanks.
I compiled your PR and can confirm warning are still present (obviously with some different line numbers) :

Code: Select all

/home/OB/dev/FreeCAD/src/Mod/PartDesign/Gui/TaskPadParameters.cpp: In member function ‘void PartDesignGui::TaskPadParameters::onDirectionCBChanged(int)’:
/home/OB/dev/FreeCAD/src/Mod/PartDesign/Gui/TaskPadParameters.cpp:453:30: warning: unused variable ‘newRefAxis’ [-Wunused-variable]
  453 |         App::DocumentObject* newRefAxis = propReferenceAxis->getValue();
      |                              ^~~~~~~~~~
/home/OB/dev/FreeCAD/src/Mod/PartDesign/Gui/TaskPadParameters.cpp:427:26: warning: unused variable ‘oldRefAxis’ [-Wunused-variable]
  427 |     App::DocumentObject* oldRefAxis = propReferenceAxis->getValue();
EDIT : JFYI, Clang also returns the same warnings (as GCC previously) ;)
User avatar
uwestoehr
Veteran
Posts: 4961
Joined: Sun Jan 27, 2019 3:21 am
Location: Germany
Contact:

Re: [sketcher] unreferenced local variables

Post by uwestoehr »

openBrain wrote: Tue Sep 28, 2021 11:58 am I compiled your PR and can confirm warning are still present (obviously with some different line numbers) :
Weird that I don't see them. However the warning is real and Werner already fixed it today. I rebased my PR now.
Post Reply