abrt / satyr

Automatic problem management with anonymous reports
GNU General Public License v2.0
19 stars 22 forks source link

tests: Don't pass va_list as function argument #317

Closed michalfabik closed 3 years ago

michalfabik commented 3 years ago

The metrics test was relying on a peculiar behaviour of va_list: A variadic function A would pass a va_list of args passed to it to another function B. B would iterate over a part of the va_list, then return. A would call B again, passing the same va_list and B would continue iterating over the rest of it, picking up where it left off after the last call. This seems to work fine on x86_64 but on some architectures (e.g. ppc64le and i686), the second call to B restarts the iteration from the beginning of the va_list, using the same data twice. (Tested with gcc 10.2.1 20201016 on both x86_64 and ppc64le.)

This commit replaces the passing of va_list as arg with string array, removing the need of the callee to remember where to restart a previous iteration.

Signed-off-by: Michal Fabik mfabik@redhat.com

mzidek-gh commented 3 years ago

The old code seems to be equivalent to the new one. I am not sure if the different behaviour on different architectures is a bug or if we relied on undefined behaviour. In general I prefer the non variable version so ACK from me and if it solves the issue even better.

If you tried to run this on one of the "problematic" architectures and the tests passed with this code, then feel free to merge the patch.