[LTP] [PATCH] syscalls: newuname01: Convert to the new library.

Li Wang liwang@redhat.com
Fri Mar 6 03:58:29 CET 2026


On Thu, Mar 05, 2026 at 03:25:44PM +0100, Cyril Hrubis wrote:
> Hi!1
> > > +	SAFE_FILE_SCANF("/proc/sys/kernel/hostname", "%1023[^\n]", proc_val);
> > > +	TST_EXP_EQ_STR(name->nodename, proc_val);
> > >  
> > > -	tst_parse_opts(ac, av, NULL, NULL);
> > > +	SAFE_FILE_SCANF("/proc/sys/kernel/osrelease", "%1023[^\n]", proc_val);
> > > +	TST_EXP_EQ_STR(name->release, proc_val);
> > >  
> > > -	setup();
> > > +	SAFE_FILE_SCANF("/proc/sys/kernel/version", "%1023[^\n]", proc_val);
> > > +	TST_EXP_EQ_STR(name->version, proc_val);
> > 
> > We'd better clear proc_val between reads:
> > 
> >   proc_val[0] = '\0';
> 
> I'm looking at safe_file_scanf() code and it calls tst_brkm_() in any
> case that no conversion was done. So the buffer should be either be
> filled with new data or the test should exit with an error. Do I miss
> something?

You're right, I somehow overlooked the SAFE_ macro, which will cause an
error if the read fails. Please ignore this comment.

-- 
Regards,
Li Wang



More information about the ltp mailing list