mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Fix clang-tidy bugprone-suspicious-string-compare warnings
This commit is contained in:
parent
975f24bde6
commit
4d60d4833e
7 changed files with 8 additions and 7 deletions
|
@ -11,4 +11,5 @@ Checks: [-*,
|
|||
bugprone-parent-virtual-call,
|
||||
bugprone-string-literal-with-embedded-nul,
|
||||
bugprone-suspicious-stringview-data-usage,
|
||||
bugprone-suspicious-string-compare,
|
||||
]
|
||||
|
|
|
@ -147,7 +147,7 @@ int find_all_matching_cmds(const string& prefix, const char* array_of_matches[])
|
|||
|
||||
for ( int j = 0; j < g_DebugCmdInfos[i]->NumNames(); ++j ) {
|
||||
const char* curr_name = g_DebugCmdInfos[i]->Names()[j];
|
||||
if ( strncmp(curr_name, prefix.c_str(), arglen) )
|
||||
if ( strncmp(curr_name, prefix.c_str(), arglen) != 0 )
|
||||
continue;
|
||||
|
||||
// If exact match, then only return that one.
|
||||
|
|
|
@ -158,7 +158,7 @@ void FragReassembler::Weird(const char* name) const {
|
|||
}
|
||||
|
||||
void FragReassembler::Overlap(const u_char* b1, const u_char* b2, uint64_t n) {
|
||||
if ( memcmp((const void*)b1, (const void*)b2, n) )
|
||||
if ( memcmp((const void*)b1, (const void*)b2, n) != 0 )
|
||||
Weird("fragment_inconsistency");
|
||||
else
|
||||
Weird("fragment_overlap");
|
||||
|
|
|
@ -38,7 +38,7 @@ flow BitTorrent_Flow(is_orig: bool) {
|
|||
function validate_handshake(pstrlen: uint8, pstr: const_bytestring): bool
|
||||
%{
|
||||
if ( pstrlen != 19 ||
|
||||
memcmp("BitTorrent protocol", pstr.begin(), 19) )
|
||||
memcmp("BitTorrent protocol", pstr.begin(), 19) != 0 )
|
||||
{
|
||||
throw Exception("invalid handshake");
|
||||
}
|
||||
|
|
|
@ -117,11 +117,11 @@ bool Gnutella_Analyzer::IsHTTP(std::string header) {
|
|||
}
|
||||
|
||||
bool Gnutella_Analyzer::GnutellaOK(std::string header) {
|
||||
if ( strncmp("GNUTELLA", header.data(), 8) )
|
||||
if ( strncmp("GNUTELLA", header.data(), 8) != 0 )
|
||||
return false;
|
||||
|
||||
int codepos = header.find(' ') + 1;
|
||||
if ( ! strncmp("200", header.data() + codepos, 3) )
|
||||
if ( strncmp("200", header.data() + codepos, 3) == 0 )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -396,7 +396,7 @@ void TCP_Reassembler::Overlap(const u_char* b1, const u_char* b2, uint64_t n) {
|
|||
if ( DEBUG_tcp_contents )
|
||||
DEBUG_MSG("%.6f TCP contents overlap: %" PRIu64 " IsOrig()=%d\n", run_state::network_time, n, IsOrig());
|
||||
|
||||
if ( rexmit_inconsistency && memcmp((const void*)b1, (const void*)b2, n) &&
|
||||
if ( rexmit_inconsistency && (memcmp((const void*)b1, (const void*)b2, n) != 0) &&
|
||||
// The following weeds out keep-alives for which that's all
|
||||
// we've ever seen for the connection.
|
||||
(n > 1 || endp->peer->HasDoneSomething()) ) {
|
||||
|
|
|
@ -346,7 +346,7 @@ void PackageTarget::DoFindDependencies(const vector<Info*>& infos) {
|
|||
continue;
|
||||
|
||||
for ( size_t j = 0; j < pkg_deps.size(); ++j ) {
|
||||
if ( strncmp(script->Name().c_str(), pkg_deps[j]->Name().c_str(), pkg_deps[j]->Name().size()) )
|
||||
if ( strncmp(script->Name().c_str(), pkg_deps[j]->Name().c_str(), pkg_deps[j]->Name().size()) != 0 )
|
||||
continue;
|
||||
|
||||
DBG_LOG(DBG_ZEEKYGEN, "Script %s associated with package %s", script->Name().c_str(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue