[alsa-devel] [PATCH] pcm_native: Remove VLA usage

kbuild test robot lkp at intel.com
Fri Mar 30 03:16:07 CEST 2018


Hi Kyle,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on v4.16-rc7]
[cannot apply to sound/for-next next-20180329]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Kyle-Spiers/pcm_native-Remove-VLA-usage/20180330-073734
config: x86_64-randconfig-x019-201812 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   In file included from include/asm-generic/bug.h:5:0,
                    from arch/x86/include/asm/bug.h:83,
                    from include/linux/bug.h:5,
                    from include/linux/mmdebug.h:5,
                    from include/linux/mm.h:9,
                    from sound/core/pcm_native.c:22:
   sound/core/pcm_native.c: In function 'constrain_params_by_rules':
   include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
     ^
   include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
>> sound/core/pcm_native.c:401:3: note: in expansion of macro 'if'
      if (changed < 0)
      ^~
   sound/core/pcm_native.c:403:4: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
       return changed;
       ^~~~~~

vim +/if +401 sound/core/pcm_native.c

^1da177e4 Linus Torvalds   2005-04-16  319  
9cc07f55d Takashi Sakamoto 2017-06-09  320  static int constrain_params_by_rules(struct snd_pcm_substream *substream,
877211f5e Takashi Iwai     2005-11-17  321  				     struct snd_pcm_hw_params *params)
^1da177e4 Linus Torvalds   2005-04-16  322  {
9cc07f55d Takashi Sakamoto 2017-06-09  323  	struct snd_pcm_hw_constraints *constrs =
9cc07f55d Takashi Sakamoto 2017-06-09  324  					&substream->runtime->hw_constraints;
^1da177e4 Linus Torvalds   2005-04-16  325  	unsigned int k;
16c438ade Kyle Spiers      2018-03-28  326  	unsigned int *rstamps;
^1da177e4 Linus Torvalds   2005-04-16  327  	unsigned int vstamps[SNDRV_PCM_HW_PARAM_LAST_INTERVAL + 1];
d81052f92 Takashi Sakamoto 2017-06-09  328  	unsigned int stamp;
a1c06e39a Takashi Sakamoto 2017-06-09  329  	struct snd_pcm_hw_rule *r;
a1c06e39a Takashi Sakamoto 2017-06-09  330  	unsigned int d;
9cc07f55d Takashi Sakamoto 2017-06-09  331  	struct snd_mask old_mask;
9cc07f55d Takashi Sakamoto 2017-06-09  332  	struct snd_interval old_interval;
a1c06e39a Takashi Sakamoto 2017-06-09  333  	bool again;
9cc07f55d Takashi Sakamoto 2017-06-09  334  	int changed;
^1da177e4 Linus Torvalds   2005-04-16  335  
d81052f92 Takashi Sakamoto 2017-06-09  336  	/*
d81052f92 Takashi Sakamoto 2017-06-09  337  	 * Each application of rule has own sequence number.
d81052f92 Takashi Sakamoto 2017-06-09  338  	 *
d81052f92 Takashi Sakamoto 2017-06-09  339  	 * Each member of 'rstamps' array represents the sequence number of
d81052f92 Takashi Sakamoto 2017-06-09  340  	 * recent application of corresponding rule.
d81052f92 Takashi Sakamoto 2017-06-09  341  	 */
16c438ade Kyle Spiers      2018-03-28  342  
16c438ade Kyle Spiers      2018-03-28  343  	rstamps = kcalloc(constrs->rules_num, sizeof(*rstamps), GFP_KERNEL);
d81052f92 Takashi Sakamoto 2017-06-09  344  
d81052f92 Takashi Sakamoto 2017-06-09  345  	/*
d81052f92 Takashi Sakamoto 2017-06-09  346  	 * Each member of 'vstamps' array represents the sequence number of
d81052f92 Takashi Sakamoto 2017-06-09  347  	 * recent application of rule in which corresponding parameters were
d81052f92 Takashi Sakamoto 2017-06-09  348  	 * changed.
d81052f92 Takashi Sakamoto 2017-06-09  349  	 *
d81052f92 Takashi Sakamoto 2017-06-09  350  	 * In initial state, elements corresponding to parameters requested by
d81052f92 Takashi Sakamoto 2017-06-09  351  	 * a caller is 1. For unrequested parameters, corresponding members
d81052f92 Takashi Sakamoto 2017-06-09  352  	 * have 0 so that the parameters are never changed anymore.
d81052f92 Takashi Sakamoto 2017-06-09  353  	 */
^1da177e4 Linus Torvalds   2005-04-16  354  	for (k = 0; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++)
^1da177e4 Linus Torvalds   2005-04-16  355  		vstamps[k] = (params->rmask & (1 << k)) ? 1 : 0;
d81052f92 Takashi Sakamoto 2017-06-09  356  
d81052f92 Takashi Sakamoto 2017-06-09  357  	/* Due to the above design, actual sequence number starts at 2. */
d81052f92 Takashi Sakamoto 2017-06-09  358  	stamp = 2;
0d4e39996 Takashi Sakamoto 2017-06-09  359  retry:
d81052f92 Takashi Sakamoto 2017-06-09  360  	/* Apply all rules in order. */
a1c06e39a Takashi Sakamoto 2017-06-09  361  	again = false;
^1da177e4 Linus Torvalds   2005-04-16  362  	for (k = 0; k < constrs->rules_num; k++) {
a1c06e39a Takashi Sakamoto 2017-06-09  363  		r = &constrs->rules[k];
d81052f92 Takashi Sakamoto 2017-06-09  364  
d81052f92 Takashi Sakamoto 2017-06-09  365  		/*
d81052f92 Takashi Sakamoto 2017-06-09  366  		 * Check condition bits of this rule. When the rule has
d81052f92 Takashi Sakamoto 2017-06-09  367  		 * some condition bits, parameter without the bits is
d81052f92 Takashi Sakamoto 2017-06-09  368  		 * never processed. SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP
d81052f92 Takashi Sakamoto 2017-06-09  369  		 * is an example of the condition bits.
d81052f92 Takashi Sakamoto 2017-06-09  370  		 */
^1da177e4 Linus Torvalds   2005-04-16  371  		if (r->cond && !(r->cond & params->flags))
^1da177e4 Linus Torvalds   2005-04-16  372  			continue;
d81052f92 Takashi Sakamoto 2017-06-09  373  
d81052f92 Takashi Sakamoto 2017-06-09  374  		/*
d81052f92 Takashi Sakamoto 2017-06-09  375  		 * The 'deps' array includes maximum three dependencies
d81052f92 Takashi Sakamoto 2017-06-09  376  		 * to SNDRV_PCM_HW_PARAM_XXXs for this rule. The fourth
d81052f92 Takashi Sakamoto 2017-06-09  377  		 * member of this array is a sentinel and should be
d81052f92 Takashi Sakamoto 2017-06-09  378  		 * negative value.
d81052f92 Takashi Sakamoto 2017-06-09  379  		 *
d81052f92 Takashi Sakamoto 2017-06-09  380  		 * This rule should be processed in this time when dependent
d81052f92 Takashi Sakamoto 2017-06-09  381  		 * parameters were changed at former applications of the other
d81052f92 Takashi Sakamoto 2017-06-09  382  		 * rules.
d81052f92 Takashi Sakamoto 2017-06-09  383  		 */
^1da177e4 Linus Torvalds   2005-04-16  384  		for (d = 0; r->deps[d] >= 0; d++) {
d656b4a65 Takashi Sakamoto 2017-06-09  385  			if (vstamps[r->deps[d]] > rstamps[k])
^1da177e4 Linus Torvalds   2005-04-16  386  				break;
^1da177e4 Linus Torvalds   2005-04-16  387  		}
d656b4a65 Takashi Sakamoto 2017-06-09  388  		if (r->deps[d] < 0)
^1da177e4 Linus Torvalds   2005-04-16  389  			continue;
be4e31dab Takashi Sakamoto 2017-06-07  390  
be4e31dab Takashi Sakamoto 2017-06-07  391  		if (trace_hw_mask_param_enabled()) {
be4e31dab Takashi Sakamoto 2017-06-07  392  			if (hw_is_mask(r->var))
be4e31dab Takashi Sakamoto 2017-06-07  393  				old_mask = *hw_param_mask(params, r->var);
^1da177e4 Linus Torvalds   2005-04-16  394  		}
be4e31dab Takashi Sakamoto 2017-06-07  395  		if (trace_hw_interval_param_enabled()) {
be4e31dab Takashi Sakamoto 2017-06-07  396  			if (hw_is_interval(r->var))
be4e31dab Takashi Sakamoto 2017-06-07  397  				old_interval = *hw_param_interval(params, r->var);
^1da177e4 Linus Torvalds   2005-04-16  398  		}
c6706de0c Takashi Sakamoto 2017-06-07  399  
^1da177e4 Linus Torvalds   2005-04-16  400  		changed = r->func(params, r);
f74ae15fe Takashi Sakamoto 2017-06-11 @401  		if (changed < 0)
16c438ade Kyle Spiers      2018-03-28  402  			kfree(rstamps);
f74ae15fe Takashi Sakamoto 2017-06-11  403  			return changed;
c6706de0c Takashi Sakamoto 2017-06-07  404  
d81052f92 Takashi Sakamoto 2017-06-09  405  		/*
82e7d5012 Takashi Sakamoto 2017-06-11  406  		 * When the parameter is changed, notify it to the caller
d81052f92 Takashi Sakamoto 2017-06-09  407  		 * by corresponding returned bit, then preparing for next
d81052f92 Takashi Sakamoto 2017-06-09  408  		 * iteration.
d81052f92 Takashi Sakamoto 2017-06-09  409  		 */
^1da177e4 Linus Torvalds   2005-04-16  410  		if (changed && r->var >= 0) {
82e7d5012 Takashi Sakamoto 2017-06-11  411  			if (hw_is_mask(r->var)) {
82e7d5012 Takashi Sakamoto 2017-06-11  412  				trace_hw_mask_param(substream, r->var,
82e7d5012 Takashi Sakamoto 2017-06-11  413  					k + 1, &old_mask,
82e7d5012 Takashi Sakamoto 2017-06-11  414  					hw_param_mask(params, r->var));
^1da177e4 Linus Torvalds   2005-04-16  415  			}
82e7d5012 Takashi Sakamoto 2017-06-11  416  			if (hw_is_interval(r->var)) {
82e7d5012 Takashi Sakamoto 2017-06-11  417  				trace_hw_interval_param(substream, r->var,
82e7d5012 Takashi Sakamoto 2017-06-11  418  					k + 1, &old_interval,
82e7d5012 Takashi Sakamoto 2017-06-11  419  					hw_param_interval(params, r->var));
^1da177e4 Linus Torvalds   2005-04-16  420  			}
82e7d5012 Takashi Sakamoto 2017-06-11  421  
^1da177e4 Linus Torvalds   2005-04-16  422  			params->cmask |= (1 << r->var);
^1da177e4 Linus Torvalds   2005-04-16  423  			vstamps[r->var] = stamp;
a1c06e39a Takashi Sakamoto 2017-06-09  424  			again = true;
^1da177e4 Linus Torvalds   2005-04-16  425  		}
f74ae15fe Takashi Sakamoto 2017-06-11  426  
82e7d5012 Takashi Sakamoto 2017-06-11  427  		rstamps[k] = stamp++;
^1da177e4 Linus Torvalds   2005-04-16  428  	}
0d4e39996 Takashi Sakamoto 2017-06-09  429  
d81052f92 Takashi Sakamoto 2017-06-09  430  	/* Iterate to evaluate all rules till no parameters are changed. */
0d4e39996 Takashi Sakamoto 2017-06-09  431  	if (again)
0d4e39996 Takashi Sakamoto 2017-06-09  432  		goto retry;
9cc07f55d Takashi Sakamoto 2017-06-09  433  
16c438ade Kyle Spiers      2018-03-28  434  	kfree(rstamps);
9cc07f55d Takashi Sakamoto 2017-06-09  435  	return 0;
^1da177e4 Linus Torvalds   2005-04-16  436  }
9cc07f55d Takashi Sakamoto 2017-06-09  437  

:::::: The code at line 401 was first introduced by commit
:::::: f74ae15fe3da7905b78e986ad906a333587cf160 ALSA: pcm: return error immediately for parameters handling

:::::: TO: Takashi Sakamoto <o-takashi at sakamocchi.jp>
:::::: CC: Takashi Iwai <tiwai at suse.de>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/gzip
Size: 30042 bytes
Desc: not available
URL: <http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20180330/071e03e0/attachment-0001.bin>


More information about the Alsa-devel mailing list