From: acervesato@git
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] Add safe macros for stream testing suite
Date: Fri, 10 Apr 2026 15:00:14 +0000 [thread overview]
Message-ID: <20260410150014.4177-1-ltp-ci@noreply.github.com> (raw)
In-Reply-To: <20260304-stream_refactoring-v2-2-3e48ada8ff1a@suse.com>
Hi Andrea,
our agent completed the review of the patch.
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.
--- Reply to [PATCH 1/6] ---
On 2026-03-04, Andrea Cervesato wrote:
> Add safe macros for stream testing suite
> +size_t safe_fread(const char *file, const int lineno,
> + void *ptr, size_t size, size_t n, FILE *stream)
> +{
> + size_t ret;
> +
> + ret = fread(ptr, size, n, stream);
> + if (ret != n) {
> + tst_brkm_(file, lineno, TBROK, NULL,
> + "fread(%p, %lu, %lu, %p) read %lu bytes",
> + ptr, size, n, stream, ret);
%lu is wrong for size_t on ILP32; use %zu. Also, ret is an item count,
not bytes — the message is misleading. Same issue in safe_fwrite.
Use TBROK | TERRNO here and in safe_fwrite; errno is set on actual I/O
errors, not just EOF.
> +FILE *safe_freopen(const char *file, const int lineno,
> + const char *path, const char *mode, FILE *stream)
Continuation-line alignment is inconsistent with the declaration in
safe_stdio_fn.h. Same applies to safe_fseek, safe_ftell. Align to the
opening parenthesis using tabs+spaces as in the header.
--- Reply to [PATCH 2/6] ---
On 2026-03-04, Andrea Cervesato wrote:
> fs: rewrite stream01 test using new API
Commit body is missing. Explain why the conversion is done (e.g. "Old
API is deprecated; convert to new tst_test.h-based API."). Same applies
to patches 3/6–6/6.
> +static void read_file(const char *file, const char *str, size_t n)
> +{
> + char buf[n];
> + ...
> + len = SAFE_FREAD(buf, n, n, stream);
fread(buf, n, n) attempts to read n*n bytes into a n-byte VLA — buffer
overflow. Change to SAFE_FREAD(buf, 1, n, stream).
> + SAFE_FWRITE(buff_file1, strlen(buff_file1), 3, stream);
fwrite("abc", 3, 3) reads 9 bytes from a 3-byte literal — out-of-bounds
read. Change to SAFE_FWRITE(buff_file1, 1, strlen(buff_file1), stream).
--- Reply to [PATCH 3/6] ---
On 2026-03-04, Andrea Cervesato wrote:
> fs: rewrite stream02 test using new API
> + stream = SAFE_FOPEN(FILENAME, modes[i]);
> + if (!stream) {
> + tst_res(TFAIL, "fopen(%s) returned NULL pointer", modes[i]);
> + return;
> + }
SAFE_FOPEN never returns NULL — it calls tst_brk(TBROK) on failure.
Remove the dead null check.
--- Reply to [PATCH 4/6] ---
On 2026-03-04, Andrea Cervesato wrote:
> fs: rewrite stream03 test using new API
> + rewind(stream);
> + TST_EXP_EQ_LI(SAFE_FTELL(stream), SEEK_SET);
SEEK_SET is a seek-direction constant (value 0), not a file position.
Use 0 as the expected value to avoid confusion.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
next prev parent reply other threads:[~2026-04-10 15:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-04 13:25 [LTP] [PATCH v2 0/6] Rewrite fs stream testing suite Andrea Cervesato
2026-03-04 13:25 ` [LTP] [PATCH v2 1/6] Add safe macros for " Andrea Cervesato
2026-03-04 13:25 ` [LTP] [PATCH v2 2/6] fs: rewrite stream01 test using new API Andrea Cervesato
2026-04-07 14:57 ` Cyril Hrubis
2026-04-10 15:00 ` acervesato [this message]
2026-03-04 13:25 ` [LTP] [PATCH v2 3/6] fs: rewrite stream02 " Andrea Cervesato
2026-04-07 14:59 ` Cyril Hrubis
2026-03-04 13:25 ` [LTP] [PATCH v2 4/6] fs: rewrite stream03 " Andrea Cervesato
2026-03-04 13:25 ` [LTP] [PATCH v2 5/6] fs: rewrite stream04 " Andrea Cervesato
2026-03-04 13:25 ` [LTP] [PATCH v2 6/6] fs: rewrite stream05 " Andrea Cervesato
2026-04-07 15:30 ` Cyril Hrubis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260410150014.4177-1-ltp-ci@noreply.github.com \
--to=acervesato@git \
--cc=andrea.cervesato@suse.de \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox