Re: [linux-next:master 5507/6266] ../kselftest_harness.h:1167:9: warning: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result'

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 16, 2024 at 11:44:39AM -0700, Andrew Morton wrote:
> On Tue, 16 Apr 2024 14:35:18 +0800 kernel test robot <yujie.liu@xxxxxxxxx> wrote:
> 
> > tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> > head:   6bd343537461b57f3efe5dfc5fc193a232dfef1e
> > commit: c19377e23d4cb45f69c5d226ae3436f7fa818c8f [5507/6266] selftests/harness: remove use of LINE_MAX
> > compiler: gcc-13 (Ubuntu 13.2.0-4ubuntu3) 13.2.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240416/202404161023.K0EsnDmF-lkp@xxxxxxxxx/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <yujie.liu@xxxxxxxxx>
> > | Closes: https://lore.kernel.org/r/202404161023.K0EsnDmF-lkp@xxxxxxxxx/
> > 
> > All warnings (new ones prefixed by >>):
> > 
> >    In file included from tls.c:24:
> >    ../kselftest_harness.h: In function '__run_test':
> > >> ../kselftest_harness.h:1167:9: warning: ignoring return value of 'asprintf' declared with attribute 'warn_unused_result' [-Wunused-result]
> >     1167 |         asprintf(&test_name, "%s%s%s.%s", f->name,
> >          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >     1168 |                  variant->name[0] ? "." : "", variant->name, t->name);
> >          |                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Thanks.  How does this look?
> 
> --- a/tools/testing/selftests/kselftest_harness.h~selftests-harness-remove-use-of-line_max-fix-fix
> +++ a/tools/testing/selftests/kselftest_harness.h
> @@ -1163,8 +1163,12 @@ void __run_test(struct __fixture_metadat
>  	t->trigger = 0;
>  	memset(t->results->reason, 0, sizeof(t->results->reason));
>  
> -	asprintf(&test_name, "%s%s%s.%s", f->name,
> -	         variant->name[0] ? "." : "", variant->name, t->name);
> +	if (asprintf(&test_name, "%s%s%s.%s", f->name,
> +		variant->name[0] ? "." : "", variant->name, t->name) == -1) {
> +		ksft_print_msg("ERROR ALLOCATING MEMORY\n");
> +		t->exit_code = KSFT_FAIL;
> +		_exit(t->exit_code);
> +	}
>  
>  	ksft_print_msg(" RUN           %s ...\n", test_name);
>  
> _

It fixes the warning for me. Thanks.

Tested-by: Yujie Liu <yujie.liu@xxxxxxxxx>




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux