VectorCamp / vectorscan

A portable fork of the high-performance regular expression matching library
https://www.vectorcamp.gr/project/vectorscan/
Other
503 stars 54 forks source link

addressing some cppcheck warnings. #255

Closed isildur-g closed 5 months ago

isildur-g commented 5 months ago

yes this will be cleaned up in a following commit. tests pass. some commentary on cppcheck warnings not addressed in this change: src/rose/rose_build_add_mask.cpp:192:18 : error: Out of bounds access in expression 'curr.back()' because 'curr' is empty. [containerOutOfBounds] this one is a false positive

/benchmarks/benchmarks.cpp:243:20: error : Out of bounds access in 'str[char_len+1]', if 'str' size is 6 and 'char_len+1' is 6 [containerOutOfBounds] could actually be a different bug here, the way that code reads it looks like the writer intended to use j there and not char_len. left a comment.

src/scratch.c:85:9: style: Same expression used in consecutive assignments of 'som_store_size' and 'som_attempted_store_size'. [dupl icateAssignExpression] false positive

/var/lib/buildbot/workers/runner-d13-aarch64-01/release-linux-aarch64-gcc-14-cppcheck/source/src/parser/ComponentBoundary.cpp:171:12 : warning: Identical condition and return expression 'at_start', return value is always false [identicalConditionAfterEarlyExit]

false positive, the logic there makes sense as it is.

/var/lib/buildbot/workers/runner-d13-aarch64-01/release-linux-aarch64-gcc-14-cppcheck/source/src/parser/ComponentBoundary.cpp:183 : warning: Identical condition and return expression 'at_end', return value is always false [identicalConditionAfterEarlyExit]

false positive, the logic there makes sense as it is.

/var/lib/buildbot/workers/runner-d13-aarch64-01/release-linux-aarch64-gcc-14-cppcheck/source/src/nfa/goughcompile.cpp:924:24: style: Iterating over container 'eji' that is always empty. [knownEmptyContainer]

false positive, the very line before that is probably going to populate that value.

/var/lib/buildbot/workers/runner-d13-aarch64-01/release-linux-aarch64-gcc-14-cppcheck/source/unit/internal/repeat.cpp:67:1: style: T he class 'RepeatTest' does not declare a constructor although it has private member variables which likely require initialization. [ noConstructor] false positive. it has a setup function which looks like it does everything a constructor would do.

/var/lib/buildbot/workers/runner-d13-aarch64-01/release-linux-aarch64-gcc-14-cppcheck/source/unit/internal/repeat.cpp:730:1: style: The class 'SparseOptimalTest' does not declare a constructor although it has private member variables which likely require initializ ation. [noConstructor] same thing, it has a SetUp finction which does the work of a constructor.

/var/lib/buildbot/workers/runner-d13-aarch64-01/release-linux-aarch64-gcc-14-cppcheck/source/tools/hsbench/huge.cpp:186:20: style: i nt result is assigned to long variable. If the variable is long to avoid loss of information, then you have loss of information. [tr uncLongCastAssignment] false positive. the types are for compatibility with the functions called and the required return value, the actual values which would ever be encountered will never risk an overflow. besides long is the same as int in almost any machine this would ever be compiled on.

/var/lib/buildbot/workers/runner-d13-aarch64-01/release-linux-aarch64-gcc-14-cppcheck/source/src/parser/ucp_table.h:818:1: error: Th ere is an unknown macro here somewhere. Configuration is required. If UCP_FN is a macro then please configure it. [unknownMacro] UCP_FN(C)

false positive. the .h file has a warning that it is autogenerated. the macro is defined in the cpp and the .h is included shortly below. the macro is known at compile time.

/var/lib/buildbot/workers/runner-d13-aarch64-01/release-linux-aarch64-gcc-14-cppcheck/source/unit/gtest/gtest-all.cc:1686:17: error: There is an unknown macro here somewhere. Configuration is required. If GTESTNAME is a macro then please configure it. [unknownMa cro] "True iff " GTESTNAME false positive. it's defined in gtest.h which is included in that file.

isildur-g commented 5 months ago

Closes some: #252