mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-16 21:35:07 +00:00
9865f0a209
Use of macro ARRAY_SIZE to calculate array size minimizes the redundant code and improves code reusability. ./tools/perf/tests/demangle-java-test.c:31:34-35: WARNING: Use ARRAY_SIZE. Reported-by: Abaci Robot <abaci@linux.alibaba.com> Closes: https://bugzilla.openanolis.cn/show_bug.cgi?id=11173 Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com> Link: https://lore.kernel.org/r/20240929093045.10136-1-jiapeng.chong@linux.alibaba.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
46 lines
1.4 KiB
C
46 lines
1.4 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <linux/kernel.h>
|
|
#include "tests.h"
|
|
#include "session.h"
|
|
#include "debug.h"
|
|
#include "demangle-java.h"
|
|
|
|
static int test__demangle_java(struct test_suite *test __maybe_unused, int subtest __maybe_unused)
|
|
{
|
|
int ret = TEST_OK;
|
|
char *buf = NULL;
|
|
size_t i;
|
|
|
|
struct {
|
|
const char *mangled, *demangled;
|
|
} test_cases[] = {
|
|
{ "Ljava/lang/StringLatin1;equals([B[B)Z",
|
|
"boolean java.lang.StringLatin1.equals(byte[], byte[])" },
|
|
{ "Ljava/util/zip/ZipUtils;CENSIZ([BI)J",
|
|
"long java.util.zip.ZipUtils.CENSIZ(byte[], int)" },
|
|
{ "Ljava/util/regex/Pattern$BmpCharProperty;match(Ljava/util/regex/Matcher;ILjava/lang/CharSequence;)Z",
|
|
"boolean java.util.regex.Pattern$BmpCharProperty.match(java.util.regex.Matcher, int, java.lang.CharSequence)" },
|
|
{ "Ljava/lang/AbstractStringBuilder;appendChars(Ljava/lang/String;II)V",
|
|
"void java.lang.AbstractStringBuilder.appendChars(java.lang.String, int, int)" },
|
|
{ "Ljava/lang/Object;<init>()V",
|
|
"void java.lang.Object<init>()" },
|
|
};
|
|
|
|
for (i = 0; i < ARRAY_SIZE(test_cases); i++) {
|
|
buf = java_demangle_sym(test_cases[i].mangled, 0);
|
|
if (strcmp(buf, test_cases[i].demangled)) {
|
|
pr_debug("FAILED: %s: %s != %s\n", test_cases[i].mangled,
|
|
buf, test_cases[i].demangled);
|
|
ret = TEST_FAIL;
|
|
}
|
|
free(buf);
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
|
|
DEFINE_SUITE("Demangle Java", demangle_java);
|