mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Fix a few compiler warnings from MSVC
This commit is contained in:
parent
6bf469b7a8
commit
2e457eb3ea
6 changed files with 20 additions and 21 deletions
|
@ -102,7 +102,7 @@ ScriptProfileMgr::~ScriptProfileMgr()
|
||||||
auto& fp = fs.second;
|
auto& fp = fs.second;
|
||||||
auto n = func->GetBodies().size();
|
auto n = func->GetBodies().size();
|
||||||
if ( n > 1 )
|
if ( n > 1 )
|
||||||
fprintf(f, "%s\t%lu-locations\t%s\t%d\t%.06f\t%0.6f\t%" PRIu64 "\t%lld\n",
|
fprintf(f, "%s\t%zu-locations\t%s\t%d\t%.06f\t%0.6f\t%" PRIu64 "\t%lld\n",
|
||||||
fp.Name().c_str(), n, func->GetType()->FlavorString().c_str(), fp.NumCalls(),
|
fp.Name().c_str(), n, func->GetType()->FlavorString().c_str(), fp.NumCalls(),
|
||||||
fp.CPUTime(), 0.0, fp.Memory(), 0LL);
|
fp.CPUTime(), 0.0, fp.Memory(), 0LL);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ bool IPAnalyzer::AnalyzePacket(size_t len, const uint8_t* data, Packet* packet)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
ip_hdr = std::make_shared<IP_Hdr>((const struct ip6_hdr*)data, false, len);
|
ip_hdr = std::make_shared<IP_Hdr>((const struct ip6_hdr*)data, false, static_cast<int>(len));
|
||||||
packet->l3_proto = L3_IPV6;
|
packet->l3_proto = L3_IPV6;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -1249,7 +1249,7 @@ Supervisor::NodeConfig Supervisor::NodeConfig::FromRecord(const RecordVal* node)
|
||||||
const auto& affinity_val = node->GetField("cpu_affinity");
|
const auto& affinity_val = node->GetField("cpu_affinity");
|
||||||
|
|
||||||
if ( affinity_val )
|
if ( affinity_val )
|
||||||
rval.cpu_affinity = affinity_val->AsInt();
|
rval.cpu_affinity = static_cast<int>(affinity_val->AsInt());
|
||||||
|
|
||||||
const auto& bare_mode_val = node->GetField("bare_mode");
|
const auto& bare_mode_val = node->GetField("bare_mode");
|
||||||
|
|
||||||
|
|
10
src/util.cc
10
src/util.cc
|
@ -1128,9 +1128,9 @@ TEST_CASE("util streq")
|
||||||
CHECK(streq("abcd", "efgh") == false);
|
CHECK(streq("abcd", "efgh") == false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int streq(const char* s1, const char* s2)
|
bool streq(const char* s1, const char* s2)
|
||||||
{
|
{
|
||||||
return ! strcmp(s1, s2);
|
return strcmp(s1, s2) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool starts_with(std::string_view s, std::string_view beginning)
|
bool starts_with(std::string_view s, std::string_view beginning)
|
||||||
|
@ -2282,8 +2282,8 @@ const void* memory_align(const void* ptr, size_t size)
|
||||||
|
|
||||||
const char* buf = reinterpret_cast<const char*>(ptr);
|
const char* buf = reinterpret_cast<const char*>(ptr);
|
||||||
size_t mask = size - 1; // Assume size is a power of 2.
|
size_t mask = size - 1; // Assume size is a power of 2.
|
||||||
unsigned long l_ptr = reinterpret_cast<unsigned long>(ptr);
|
intptr_t l_ptr = reinterpret_cast<intptr_t>(ptr);
|
||||||
unsigned long offset = l_ptr & mask;
|
ptrdiff_t offset = l_ptr & mask;
|
||||||
|
|
||||||
if ( offset > 0 )
|
if ( offset > 0 )
|
||||||
return reinterpret_cast<const void*>(buf - offset + size);
|
return reinterpret_cast<const void*>(buf - offset + size);
|
||||||
|
@ -2322,7 +2322,7 @@ void* memory_align_and_pad(void* ptr, size_t size)
|
||||||
|
|
||||||
char* buf = reinterpret_cast<char*>(ptr);
|
char* buf = reinterpret_cast<char*>(ptr);
|
||||||
size_t mask = size - 1;
|
size_t mask = size - 1;
|
||||||
while ( (reinterpret_cast<unsigned long>(buf) & mask) != 0 )
|
while ( (reinterpret_cast<intptr_t>(buf) & mask) != 0 )
|
||||||
// Not aligned - zero pad.
|
// Not aligned - zero pad.
|
||||||
*buf++ = '\0';
|
*buf++ = '\0';
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ std::vector<std::string>* tokenize_string(std::string_view input, std::string_vi
|
||||||
std::vector<std::string_view> tokenize_string(std::string_view input, const char delim) noexcept;
|
std::vector<std::string_view> tokenize_string(std::string_view input, const char delim) noexcept;
|
||||||
|
|
||||||
extern char* copy_string(const char* s);
|
extern char* copy_string(const char* s);
|
||||||
extern int streq(const char* s1, const char* s2);
|
extern bool streq(const char* s1, const char* s2);
|
||||||
extern bool starts_with(std::string_view s, std::string_view beginning);
|
extern bool starts_with(std::string_view s, std::string_view beginning);
|
||||||
extern bool ends_with(std::string_view s, std::string_view ending);
|
extern bool ends_with(std::string_view s, std::string_view ending);
|
||||||
|
|
||||||
|
|
|
@ -271,20 +271,19 @@ extern const char* ZEEK_VERSION_FUNCTION();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// FreeBSD doesn't support LeakSanitizer
|
|
||||||
#if defined(ZEEK_ASAN) && !defined(__FreeBSD__)
|
#if defined(ZEEK_ASAN) && !defined(__FreeBSD__)
|
||||||
#include <sanitizer/lsan_interface.h>
|
#include <sanitizer/lsan_interface.h>
|
||||||
#define ZEEK_LSAN_CHECK(x) __lsan_do_leak_check(x)
|
#define ZEEK_LSAN_CHECK(...) __lsan_do_leak_check(__VA_ARGS__)
|
||||||
#define ZEEK_LSAN_ENABLE(x) __lsan_enable(x)
|
#define ZEEK_LSAN_ENABLE(...) __lsan_enable(__VA_ARGS__)
|
||||||
#define ZEEK_LSAN_IGNORE(x) __lsan_ignore_object(x)
|
#define ZEEK_LSAN_IGNORE(...) __lsan_ignore_object(__VA_ARGS__)
|
||||||
#define ZEEK_LSAN_DISABLE(x) __lsan_disable(x)
|
#define ZEEK_LSAN_DISABLE(...) __lsan_disable(__VA_ARGS__)
|
||||||
#define ZEEK_LSAN_DISABLE_SCOPE(x) __lsan::ScopedDisabler x
|
#define ZEEK_LSAN_DISABLE_SCOPE(...) __lsan::ScopedDisabler __VA_ARGS__
|
||||||
#else
|
#else
|
||||||
#define ZEEK_LSAN_CHECK(x)
|
#define ZEEK_LSAN_CHECK(...)
|
||||||
#define ZEEK_LSAN_ENABLE(x)
|
#define ZEEK_LSAN_ENABLE(...)
|
||||||
#define ZEEK_LSAN_IGNORE(x)
|
#define ZEEK_LSAN_IGNORE(...)
|
||||||
#define ZEEK_LSAN_DISABLE(x)
|
#define ZEEK_LSAN_DISABLE(...)
|
||||||
#define ZEEK_LSAN_DISABLE_SCOPE(x)
|
#define ZEEK_LSAN_DISABLE_SCOPE(...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This part is dependent on calling configure with '--sanitizers=thread'
|
// This part is dependent on calling configure with '--sanitizers=thread'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue