Hi Cyril,
On Tue, 9 Jun 2026 16:32:37 +0200, Cyril Hrubis wrote:
> tst_test: Add needs_cpu_vendor to struct tst_test
> This adds a generic implementaiton of needs_cpu_vendor to the tst_test
Typo: "implementaiton" -> "implementation".
> +const char *tst_cpu_vendor(void)
> +{
> + static char cpu_vendor[16];
> ...
> + ret = FILE_LINES_SCANF(NULL, "/proc/cpuinfo", "vendor_id : %16s[^\n]", cpu_vendor);
Two issues with the scanf format:
1) The width specifier %16s allows writing up to 16 characters plus
a NUL terminator into a 16-byte buffer, which is a one-byte overflow.
Should be %15s.
2) The [^\n] after %16s is treated as literal text to match, not as a
scanset. It is effectively dead and does not do what it looks like it
should. Either drop it, or if the intent was to match characters
including spaces use %15[^\n] as the conversion specifier (but vendor_id
values are single words so %15s should be fine).
> + if (tst_test->needs_cpu_vendor && strcmp(tst_test->needs_cpu_vendor, tst_cpu_vendor())) {
> + tst_brk(TCONF, "Tests needs '%s' CPU to continue have '%s'",
> + tst_test->needs_cpu_vendor, tst_cpu_vendor());
> + }
The message has a grammar issue. Something like
"Test needs '%s' CPU, have '%s'" would read better.
> diff --git a/include/tst_cpu.h b/include/tst_cpu.h
> ...
> +
> +
> +
> #endif /* TST_CPU_H__ */
Two extra blank lines were added before #endif.
Verdict: Needs revision
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.