From ea67e77e8182c08df13ca9f35402fb98448ab34a Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 8 Feb 2021 15:46:18 -0600 Subject: [PATCH] [PD] Add missing ctor variable init (Coverity) The "angle" variable was not being initialized in any of the constructors for the CutDimensionSet, and nothing was being initialized by the default constructor. This commit adds angle as an optional final argument to the parameterized constructors, defaulting to 0.0, and adds default values to the default constructor using the first of each enum and 0.0 for the angle. The default constructor is required elsewhere in the code so cannot be trivially removed. Issue identified by Coverity. --- src/Mod/PartDesign/App/FeatureHole.cpp | 8 ++++---- src/Mod/PartDesign/App/FeatureHole.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureHole.cpp b/src/Mod/PartDesign/App/FeatureHole.cpp index af43e512bf..508753a156 100644 --- a/src/Mod/PartDesign/App/FeatureHole.cpp +++ b/src/Mod/PartDesign/App/FeatureHole.cpp @@ -1832,14 +1832,14 @@ const Hole::CutDimensionSet& Hole::find_cutDimensionSet(const CutDimensionKey &k } Hole::CutDimensionSet::CutDimensionSet(const std::string &nme, - std::vector &&d, CutType cut, ThreadType thread) : - bore_data{ std::move(d) }, cut_type{ cut }, thread_type{thread}, name{nme} + std::vector &&d, CutType cut, ThreadType thread, double a) : + bore_data{ std::move(d) }, cut_type{ cut }, thread_type{thread}, name{nme}, angle{a} { } Hole::CutDimensionSet::CutDimensionSet(const std::string &nme, - std::vector &&d, CutType cut, ThreadType thread) : - sink_data{ std::move(d) }, cut_type{ cut }, thread_type{thread}, name{nme} + std::vector &&d, CutType cut, ThreadType thread, double a) : + sink_data{ std::move(d) }, cut_type{ cut }, thread_type{thread}, name{nme}, angle{a} { } diff --git a/src/Mod/PartDesign/App/FeatureHole.h b/src/Mod/PartDesign/App/FeatureHole.h index c28ef80465..8fe3457c4f 100644 --- a/src/Mod/PartDesign/App/FeatureHole.h +++ b/src/Mod/PartDesign/App/FeatureHole.h @@ -165,11 +165,11 @@ private: enum CutType { Counterbore, Countersink }; enum ThreadType { Metric, MetricFine }; - CutDimensionSet() {} + CutDimensionSet():cut_type(Counterbore),thread_type(Metric),angle(0.0) {} CutDimensionSet(const std::string &nme, - std::vector &&d, CutType cut, ThreadType thread); + std::vector &&d, CutType cut, ThreadType thread, double angle = 0.0); CutDimensionSet(const std::string &nme, - std::vector &&d, CutType cut, ThreadType thread); + std::vector &&d, CutType cut, ThreadType thread, double angle = 0.0); const CounterBoreDimension &get_bore(const std::string &t) const; const CounterSinkDimension &get_sink(const std::string &t) const;