From 35f25a251b8b34dae11b39db45a47e79de898145 Mon Sep 17 00:00:00 2001 From: Georgia Garcia Date: Wed, 13 Sep 2023 10:24:35 -0300 Subject: [PATCH] parser: fix coverity issues found in snapshot 70858 This commit add fixes for issues found in coverity's snapshot 70858. - CID 323127: Performance inefficiencies (COPY_INSTEAD_OF_MOVE) - CID 323125: Uninitialized members (UNINIT_CTOR) I'm also removing Novell, Inc. from the copyright notice added by a copy-paste error, and an unused variable left over from debugging. Signed-off-by: Georgia Garcia --- parser/bignum.h | 6 ++---- parser/parser_regex.c | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/parser/bignum.h b/parser/bignum.h index 757da4964..e472de844 100644 --- a/parser/bignum.h +++ b/parser/bignum.h @@ -12,8 +12,7 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, contact Novell, Inc. or Canonical - * Ltd. + * along with this program; if not, contact Canonical Ltd. */ #ifndef __AA_BIGNUM_H @@ -29,10 +28,9 @@ class bignum { public: std::vector data; - uint64_t sad = 543; uint8_t base; bool negative = false; - bignum () {} + bignum () : base(0) {} bignum (unsigned long val) { if (val == 0) diff --git a/parser/parser_regex.c b/parser/parser_regex.c index 7d1847692..ef5c2c1f4 100644 --- a/parser/parser_regex.c +++ b/parser/parser_regex.c @@ -882,7 +882,7 @@ static std::string generate_regex_range(bignum start, bignum end) std::ostringstream result; std::vector> regex_range; int j; - regex_range = regex_range_generator(start, end); + regex_range = regex_range_generator(std::move(start), std::move(end)); for (auto &i: regex_range) { bignum sstart = i.first; bignum send = i.second; @@ -942,7 +942,7 @@ int convert_range(std::string& buffer, bignum start, bignum end) pattern_t ptype; int pos; - std::string regex_range = generate_regex_range(start, end); + std::string regex_range = generate_regex_range(std::move(start), std::move(end)); if (!regex_range.empty()) { ptype = convert_aaregex_to_pcre(regex_range.c_str(), 0, glob_default, buffer, &pos);