[LTP] [PATCH 3/3] stack_clash: make use of tst_kcmdline_parse

Petr Vorel pvorel@suse.cz
Fri Mar 8 09:56:28 CET 2024


Hi Li,

>  void setup(void)
>  {
> -	char buf[4096], *p;
> +	char *p;
stack_clash.c:276:15: warning: unused variable ‘p’ [-Wunused-variable]
  276 |         char *p;
      |               ^

>  	page_size = sysconf(_SC_PAGESIZE);
>  	page_mask = ~(page_size - 1);

> -	buf[4095] = '\0';
> -	SAFE_FILE_SCANF("/proc/cmdline", "%4095[^\n]", buf);
> +	struct tst_kcmdline_param params = TST_KCMDLINE_INIT("stack_guard_gap");
> +	tst_kcmdline_parse(&params, 1);

> -	if ((p = strstr(buf, "stack_guard_gap=")) != NULL) {
> -		if (sscanf(p, "stack_guard_gap=%ld", &GAP_PAGES) != 1) {
> -			tst_brk(TBROK | TERRNO, "sscanf");
> -			return;
> -		}
> +	if (params.value[0] != '\0') {
> +		GAP_PAGES= atol(params.value);
>  		tst_res(TINFO, "stack_guard_gap = %ld", GAP_PAGES);
>  	}

Otherwise LGTM.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr


More information about the ltp mailing list