清理codex告警

Signed-off-by:wenlong12 <wenlong12@huawei.com>

Signed-off-by: wenlong12 <wenlong12@huawei.com>
This commit is contained in:
wenlong12 2023-07-20 20:24:39 +08:00
parent 37d2be2a9b
commit ce0395478c

View File

@ -250,13 +250,15 @@ static void* HhreadFuncCpp(void* param)
static void TestMemoryMap()
{
constexpr int smartSize = 4096;
constexpr int bigSize = 8192;
int fd = open("/bin/hiebpf", O_RDWR | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO);
if (fd < 0) {
printf("open %s failed\n", "/bin/hiebpf");
return;
}
void* mapAddr1 = mmap(nullptr, 4096, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0);
void* mapAddr1 = mmap(nullptr, smartSize, PROT_WRITE | PROT_READ, MAP_SHARED | MAP_POPULATE, fd, 0);
if (mapAddr1 == MAP_FAILED) {
printf("named mmap failed\n");
close(fd);
@ -264,11 +266,11 @@ static void TestMemoryMap()
}
printf("named mmap size: 4096, fd: %d\n", fd);
void* mapAddr2 = mmap(nullptr, 8192, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
void* mapAddr2 = mmap(nullptr, bigSize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
if (mapAddr2 == MAP_FAILED) {
printf("anonymous mmap failed\n");
close(fd);
munmap(mapAddr1, 4096);
munmap(mapAddr1, smartSize);
return;
}
printf("anonymous mmap size: 8192\n");
@ -279,8 +281,8 @@ static void TestMemoryMap()
memtrace(reinterpret_cast<void*>(0x123456), 3333, "memtrace_test", false); // 3333 num
printf("memtrace(0x123456, 3333, \"memtrace_test\", false)\n");
close(fd);
munmap(mapAddr1, 4096);
munmap(mapAddr2, 8192);
munmap(mapAddr1, smartSize);
munmap(mapAddr2, bigSize);
}
int main(int argc, char *argv[])