# Various -Wunused-but-set-variable warnings

**URL:** <https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580>\
**Category:** Development\
**Created:** [January 6, 2022, 3:28pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580 "2022-01-06T15:28:29Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)\
**Post date:** [January 6, 2022, 3:28pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/1 "2022-01-06T15:28:29Z")

</div>

Hi all,

The newest clang gives some new -Wunused-but-set-variable warnings.

Without knowing the code in question, it’s hard for someone like me to decide if the set value is harmlessly unused or if there is missing code that should be using the values.

Could people that know these classes take a look?

The warnings are:

```auto
/Common/Core/Testing/Cxx/TestSparseArrayValidation.cxx:61:9: warning: variable 'status' set but not used
/Filters/Core/Testing/Cxx/TestGlyph3D.cxx:64:7: warning: variable 'status' set but not used
/Filters/HyperTree/Testing/Cxx/TestHyperTreeGridTernary2DFullMaterialBits.cxx:92:13: warning: variable 's' set but not used
/Filters/Sources/vtkHyperTreeGridSource.cxx:1044:13: warning: variable 'nLeaves' set but not used
/IO/Infovis/Testing/Cxx/TestFixedWidthTextReader.cxx:49:7: warning: variable 'status' set but not used
/IO/Parallel/vtkEnSightWriter.cxx:163:7: warning: variable 'blockCount' set but not used
/IO/SQL/Testing/Cxx/TestSQLiteDatabase.cxx:88:7: warning: variable 'status1' set but not used
/Infovis/Layout/vtkAttributeClustering2DLayoutStrategy.cxx:587:7: warning: variable 'totalCollisionOps' set but not used
/Infovis/Layout/vtkClustering2DLayoutStrategy.cxx:542:7: warning: variable 'totalCollisionOps' set but not used
/Infovis/Layout/vtkCommunity2DLayoutStrategy.cxx:531:7: warning: variable 'totalCollisionOps' set but not used
/Infovis/Layout/vtkConstrained2DLayoutStrategy.cxx:497:7: warning: variable 'totalCollisionOps' set but not used
/Infovis/Layout/vtkFast2DLayoutStrategy.cxx:495:7: warning: variable 'totalCollisionOps' set but not used
/Interaction/Widgets/Testing/Cxx/vtkSeedRepresentationTest1.cxx:48:7: warning: variable 'status' set but not used
/Parallel/DIY/vtkDIYGhostUtilities.cxx:4503:13: warning: variable 'numberOfCells' set but not used
/Rendering/Label/vtkLabelHierarchy.cxx:412:13: warning: variable 'R2' set but not used
/Rendering/Label/vtkLabelPlacementMapper.cxx:606:17: warning: variable 'iteratedLabelArea' set but not used
/Rendering/Label/vtkLabelPlacer.cxx:570:17: warning: variable 'iteratedLabelArea' set but not used
/Wrapping/Tools/vtkParseExtras.c:728:7: warning: variable 'm' set but not used

```

From here: [https://open.cdash.org/viewBuildError.php?type=1&buildid=7661978](https://open.cdash.org/viewBuildError.php?type=1&buildid=7661978)

Thanks,

Sean

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [January 6, 2022, 3:33pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/2 "2022-01-06T15:33:13Z")

</div>

Some of them should be removed, other should be used.  
For the one you can’t figure out, I’d suggest using git blame and asking the dev on the related MR directly.

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)\
**Post date:** [January 6, 2022, 6:13pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/3 "2022-01-06T18:13:27Z")

</div>

Yes, but figuring out which should be removed vs used is exactly why I’ve written here 🙂 Me git blaming each one is labourious. Before resorting to that, I’m hoping the code owners of the various classes I listed can do a triage first.

Cheers,

Sean

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [January 6, 2022, 7:05pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/4 "2022-01-06T19:05:08Z")

</div>

Nothing will happen unless somenone does tag personnaly the commiters.

---

<div class="post-metadata">

**Author:** ![cory.quammen](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cory.quammen/32/6751_2.png) [@cory.quammen](https://discourse.vtk.org/u/cory.quammen)\
**Post date:** [January 6, 2022, 11:08pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/5 "2022-01-06T23:08:10Z")

</div>

> [@seanm](#):
>
> ```auto
> /Filters/Sources/vtkHyperTreeGridSource.cxx:1044:13: warning: variable 'nLeaves' set but not used
> /Parallel/DIY/vtkDIYGhostUtilities.cxx:4503:13: warning: variable 'numberOfCells' set but not used
> 
> ```

@Yohann_Bearzi could you address these?

---

<div class="post-metadata">

**Author:** ![Yohann\_Bearzi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/yohann_bearzi/32/671_2.png) [@Yohann\_Bearzi](https://discourse.vtk.org/u/Yohann_Bearzi)\
**Post date:** [January 7, 2022, 1:03pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/6 "2022-01-07T13:03:17Z")

</div>

I just pushed a fix. [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/8794](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8794)

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)\
**Post date:** [January 11, 2022, 2:06am UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/7 "2022-01-11T02:06:35Z")

</div>

OK, I’ve fixed most of the remaining ones. For your review: [https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/8809](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8809)

I’ve git blamed the 4 remaining that I dare not change. git blame gives email, not discourse nor gitlab user names, so I’ve put them below, hopefully some of them are reading here:

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [January 11, 2022, 10:13am UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/8 "2022-01-11T10:13:55Z")

</div>

Emails missing

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)\
**Post date:** [January 11, 2022, 2:11pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/9 "2022-01-11T14:11:05Z")

</div>

Mathieu, what do you mean “email missing”? Does discourse strip out email address as some kind of anti-spam measure? Did you still receive the names and SHAa?

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [January 11, 2022, 2:22pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/10 "2022-01-11T14:22:34Z")

</div>

Here is what I see:

 ![a](https://discourse.vtk.org/uploads/default/original/2X/5/5e737ca9208513a9b95da4f0af235236d2dc6f31.png)

There is no email list in your previous message.

---

<div class="post-metadata">

**Author:** ![seanm](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/a88e4f/32.png) [@seanm](https://discourse.vtk.org/u/seanm)\
**Post date:** [January 11, 2022, 3:43pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/11 "2022-01-11T15:43:57Z")

</div>

I guess it is yet another example of discourse not working well with email. ☹

It seems it dropped half my message, specifically everything after a series of dash characters. I though discourse expected markdown? Several dash characters in markdown are supposed to generate a horizontal divider line. Oh well. Here it is again in just plain text, hopefully this works:

Filters/HyperTree/Testing/Cxx/TestHyperTreeGridTernary2DFullMaterialBits.cxx:92:13: warning: variable ‘s’ set but not used

commit 34d55b7fd7c7e0aa210c7b3f0a54e7edebc1dc45  
Author: Joachim Pouderoux [joachim.pouderoux@kitware.com](mailto:joachim.pouderoux@kitware.com)

Rendering/Label/vtkLabelHierarchy.cxx:412:13: warning: variable ‘R2’ set but not used

commit 6fcb3c2101e35173852afb16b178c5a0af2f97de  
Author: Dave Partyka [dave.partyka@kitware.com](mailto:dave.partyka@kitware.com)

Rendering/Label/vtkLabelPlacementMapper.cxx:606:17: warning: variable ‘iteratedLabelArea’ set but not used

commit b80680603754890977978c2b92313fea109f8b08  
Author: Jeffrey Baumes [jeff.baumes@kitware.com](mailto:jeff.baumes@kitware.com)

Rendering/Label/vtkLabelPlacer.cxx:570:17: warning: variable ‘iteratedLabelArea’ set but not used

commit 6fcb3c2101e35173852afb16b178c5a0af2f97de  
Author: Dave Partyka [dave.partyka@kitware.com](mailto:dave.partyka@kitware.com)

---

<div class="post-metadata">

**Author:** ![mwestphal](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mwestphal/32/19_2.png) [@mwestphal](https://discourse.vtk.org/u/mwestphal)\
**Post date:** [January 11, 2022, 4:36pm UTC](https://discourse.vtk.org/t/various-wunused-but-set-variable-warnings/7580/12 "2022-01-11T16:36:40Z")

</div>

[https://gitlab.kitware.com/vtk/vtk/-/merge\_requests/8811](https://gitlab.kitware.com/vtk/vtk/-/merge_requests/8811)
