public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: linuxtestproject.agent@gmail.com
Cc: ltp@lists.linux.it
Subject: Re: [LTP] safe_stdio: More checks for invalid function return values
Date: Fri, 17 Apr 2026 11:42:31 +0200	[thread overview]
Message-ID: <20260417094231.GB386785@pevik> (raw)
In-Reply-To: <20260417092427.3643-1-linuxtestproject.agent@gmail.com>

> Hi Petr,

> --- [PATCH 1/2] ---

> On 2026-04-17, Petr Vorel wrote:
> > safe_stdio: More checks for invalid function return values

> > -	if (ret == EOF)
> > -		tst_brkm_(file, lineno, TBROK | TERRNO, NULL, "fflush(%p)", f);
> > +	if (ret == EOF) {
> > +		tst_brkm_(file, lineno, TBROK | TERRNO, NULL, "fflush(%p) failed", f);
> > +	} else if (!ret) {
> > +		tst_brkm_(file, lineno, TBROK | TERRNO, NULL,
> > +				  "Invalid fflush(%p) return value %d", f, ret);
> > +	}

> !ret is ret == 0, which is fflush()'s success return — this breaks every
> caller on success. fflush() only returns 0 or EOF per POSIX; there is no
> invalid return value to guard against, so drop the else if branch entirely.

Yeah, this one is really invalid, thanks agent :).
I'll wait little longer for others feedback before sending v2.

> > +	} else if (ret < 0) {
> > +		tst_brkm_(file, lineno, TBROK | TERRNO, NULL,
> > +				  "Invalid ftell(%p) return value %ld", f, ret);

> > +	} else if (ret < 0) {
> > +		tst_brkm_(file, lineno, TBROK | TERRNO, NULL,
> > +				  "Invalid fileno(%p) return value %d", f, ret);

> Use ret < -1 here to be consistent with safe_fseek() in the same file and
> with the policy established by patch 2/2; also fix the continuation-line
> indentation (tabs only, no mixed spaces).

I frankly expect second patch being refused. If not, I'd swap commits in v2.

> --- [PATCH 2/2] ---

> On 2026-04-17, Petr Vorel wrote:
> > lib: Be pedantic on invalid comparison check

> > diff --git a/lib/safe_stdio.c b/lib/safe_stdio.c
> > @@ -67,7 +67,7 @@ int safe_asprintf(...)
> > -	} else if (ret < 0) {
> > +	} else if (ret < -1) {
> > ...
> > @@ -154,7 +154,7 @@ int safe_fseek(...)
> > -	} else if (ret < 0) {
> > +	} else if (ret < -1) {

> This fixes asprintf and fseek but misses safe_ftell() and safe_fileno()
> from patch 1/2, which are left with ret < 0. Either fix them here or
> swap the patch order so new checks are written with ret < -1 from the start.

Good catch. I was sure I would not forget, but obviously I did.

Kind regards,
Petr

> ---
> Note:

> Our agent completed the review of the patch. The full review can be found
> in the conversation context above.

> 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

      reply	other threads:[~2026-04-17  9:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-17  8:47 [LTP] [PATCH 1/2] safe_stdio: More checks for invalid function return values Petr Vorel
2026-04-17  8:47 ` [LTP] [PATCH 2/2] lib: Be pedantic on invalid comparison check Petr Vorel
2026-04-17  9:24 ` [LTP] safe_stdio: More checks for invalid function return values linuxtestproject.agent
2026-04-17  9:42   ` Petr Vorel [this message]

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=20260417094231.GB386785@pevik \
    --to=pvorel@suse.cz \
    --cc=linuxtestproject.agent@gmail.com \
    --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