
alsa-project/alsa-lib issue #456 was edited from shanekirk:
The config function snd_config_imul always produces a zero result. This is because it delegates to snd_func_iops() to perform the iterative multiplication, which always initializes its result value to zero. Then it iteratively multiplies-assigns result against each integer in the params array, which _always_ produces zero.
This breaks any configuration that leans on "`@func imul`".
This can be demonstrated using this snippet of configuration...
``` test_fn { @func imul integers [2 4 6] }
``` ...or this source code... ``` int main(int argc, char **argv) { snd_config_t *pConfig = NULL; snd_config_top(&pConfig);
/** * Setting up... * test_fn * { * @func imul * integers [2 4 6] * } */ snd_config_t *pFnCS = NULL; snd_config_make_compound(&pFnCS, "test_fn", 0); snd_config_add(pConfig, pFnCS);
snd_config_t *pFn = NULL; snd_config_imake_string(&pFn, "@func", "imul"); snd_config_add(pFnCS, pFn);
snd_config_t *pFnParams = NULL; snd_config_make_compound(&pFnParams, "integers", 0); snd_config_add(pFnCS, pFnParams);
snd_config_t *pFnInt = NULL; snd_config_imake_integer(&pFnInt, "0", 2); snd_config_add(pFnParams, pFnInt); snd_config_imake_integer(&pFnInt, "1", 4); snd_config_add(pFnParams, pFnInt); snd_config_imake_integer(&pFnInt, "2", 6); snd_config_add(pFnParams, pFnInt);
/** * Evaluating... */ snd_config_evaluate(pFnCS, pConfig, NULL, NULL); assert(snd_config_get_type(pFnCS) == SND_CONFIG_TYPE_INTEGER); long result = 0; snd_config_get_integer(pFnCS, &result); assert(result == 48); // ** FAILS because result is always zero! **
snd_config_delete(pConfig); return 0; } ```
Note: If you replace "imul" above with "iadd" in either example, you'll get the result from iadd that you'd expect.
Incidentally, from the history, it would appear that "imul" has never worked correctly since it was introduced all those years ago. So if any configuration truly depended on this feature, it would have always been broken too.
Issue URL : https://github.com/alsa-project/alsa-lib/issues/456 Repository URL: https://github.com/alsa-project/alsa-lib
participants (1)
-
GitHub issues - edited