Skip to content

Commit 8a7fb67

Browse files
committed
Avoid scanBuild error
1 parent 317f1f8 commit 8a7fb67

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

ddprof-lib/src/main/cpp/vmStructs.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ void VMStructs::ready() {
122122
initThreadBridge();
123123
}
124124

125-
bool matchAny(const char* target_name, const char** names) {
126-
for (const char** name = names; *name != nullptr; name++) {
127-
if (strcmp(target_name, *name) == 0) {
125+
bool matchAny(const char* target_name, std::initializer_list<const char*> names) {
126+
for (const char* name : names) {
127+
if (strcmp(target_name, name) == 0) {
128128
return true;
129129
}
130130
}

ddprof-lib/src/main/cpp/vmStructs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef _VMSTRUCTS_H
88
#define _VMSTRUCTS_H
99

10+
#include <initializer_list>
1011
#include <jvmti.h>
1112
#include <stdint.h>
1213
#include <string.h>
@@ -46,7 +47,7 @@ inline T* cast_to(const void* ptr) {
4647

4748
// MATCH_SYMBOLS macro expands into an nullptr terminated char string array,
4849
// that is consumed by matchAny() method
49-
#define MATCH_SYMBOLS(...) (const char*[]) { __VA_ARGS__, nullptr }
50+
#define MATCH_SYMBOLS(...) std::initializer_list<const char*>{ __VA_ARGS__ }
5051

5152
/**
5253
* This macro defines a counterpart of a JVM class, e.g. VMKlass -> Klass.

0 commit comments

Comments
 (0)