Re: [LTP] [PATCH v12 1/3] lib/tst_uid: Remove spurious TERRNO from tst_get_free_gid success path
Wei Gao via ltp <[email protected]> Thu, 23 Jul 2026 23:28:32 +0000
| Newsgroups | it.linux.lists.ltp |
|---|---|
| Message-ID | <[email protected]> |
On Thu, Jul 23, 2026 at 12:39:17PM +0000, Andrea Cervesato wrote: > Hi Wei, > > > tst_get_free_gid_() prints the found GID when it succeeds, but it > > incorrectly includes TERRNO in tst_res_(). This prints whatever value > > happens to be in errno (often 0 or a stale value) which is confusing in > > a success path. > > > > Remove the spurious TERRNO flag from the tst_res_() success message. > > > > Signed-off-by: Wei Gao <[email protected]> > > --- > > lib/tst_uid.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/tst_uid.c b/lib/tst_uid.c > > index af4ef8cf7..b0b087362 100644 > > --- a/lib/tst_uid.c > > +++ b/lib/tst_uid.c > > @@ -24,7 +24,7 @@ gid_t tst_get_free_gid_(const char *file, const int lineno, gid_t skip) > > continue; > > > > if (errno == 0 || errno == ENOENT || errno == ESRCH) { > > - tst_res_(file, lineno, TINFO | TERRNO, > > + tst_res_(file, lineno, TINFO, > > "Found unused GID %d", (int)ret); > > uhm? technically it should print 0, ENOENT or ESRCH. That's what the > statement is all about. Do you have a log showing what's the issue with it? AI feedback error is misleading need remove in patch10 , so do you want add new AI rule fix it? Following is AI feedback: https://patchwork.ozlabs.org/project/ltp/patch/[email protected]/ > + if (errno == 0 || errno == ENOENT || errno == ESRCH) { > + tst_res_(file, lineno, TINFO | TERRNO, > + "Found unused UID %d", (int)ret); > + return ret; When getpwuid() returns NULL with errno set to ENOENT or ESRCH, TERRNO appends the errno string to the message, producing output like: "Found unused UID 5: No such file or directory". The function succeeded, so the error string is misleading. Should TERRNO be dropped here, or should it be conditionally omitted when errno indicates "not found"? > > -- > Andrea Cervesato > SUSE QE Automation Engineer Linux > [email protected] -- Mailing list info: https://lists.linux.it/listinfo/ltp