In the current API, we have some set operations: join, intersect and
subtract. Both join and subtract receives two DRM format arrays and save
the result in the first one.
For the intersection we have a slightly different approach, what makes
the API weird. We don't save the result in the arguments, instead we
return a new array with the result.
Modify weston_drm_format_array_intersect() in order to make it similar
to the other two set operations.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
Reviewed-by: Alexandros Frantzis <alexandros.frantzis@collabora.com>
Leak found running drm-formats-test with ASan:
==59454==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7f5302ff2459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
#1 0x7f5302e75e3a in zalloc ../include/libweston/zalloc.h:38
#2 0x7f5302e75e4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
#3 0x7f5302e76e33 in weston_drm_format_array_intersect ../libweston/drm-formats.c:340
#4 0x559dc2d3c69f in intersect_arrays_same_content ../tests/drm-formats-test.c:391
#5 0x559dc2d3c317 in wrapintersect_arrays_same_content ../tests/drm-formats-test.c:376
#6 0x559dc2d409ec in run_test ../tests/weston-test-runner.c:162
#7 0x559dc2d410f2 in run_case ../tests/weston-test-runner.c:277
#8 0x559dc2d40e8b in for_each_test_case ../tests/weston-test-runner.c:235
#9 0x559dc2d4139b in testsuite_run ../tests/weston-test-runner.c:311
#10 0x559dc2d423c4 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
#11 0x559dc2d423f4 in fixture_setup_run_ ../tests/weston-test-runner.c:610
#12 0x559dc2d42887 in main ../tests/weston-test-runner.c:661
#13 0x7f5302c5eb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
#14 0x559dc2d3642d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7f5302ff2459 in __interceptor_calloc /build/gcc/src/gcc/libsanitizer/asan/asan_malloc_linux.cpp:154
#1 0x7f5302e75e3a in zalloc ../include/libweston/zalloc.h:38
#2 0x7f5302e75e4e in weston_drm_format_array_create ../libweston/drm-formats.c:44
#3 0x559dc2d3bc7b in intersect_arrays ../tests/drm-formats-test.c:352
#4 0x559dc2d3b678 in wrapintersect_arrays ../tests/drm-formats-test.c:339
#5 0x559dc2d409ec in run_test ../tests/weston-test-runner.c:162
#6 0x559dc2d410f2 in run_case ../tests/weston-test-runner.c:277
#7 0x559dc2d40e8b in for_each_test_case ../tests/weston-test-runner.c:235
#8 0x559dc2d4139b in testsuite_run ../tests/weston-test-runner.c:311
#9 0x559dc2d423c4 in weston_test_harness_execute_standalone ../tests/weston-test-runner.c:572
#10 0x559dc2d423f4 in fixture_setup_run_ ../tests/weston-test-runner.c:610
#11 0x559dc2d42887 in main ../tests/weston-test-runner.c:661
#12 0x7f5302c5eb24 in __libc_start_main (/usr/lib/libc.so.6+0x27b24)
#13 0x559dc2d3642d in _start (/home/lele/weston/build/tests/test-drm-formats+0x642d)
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>
In commit "libweston: add struct weston_drm_format" we've added an API
to store and manage DRM formats and modifiers. As it has a couple of set
operations that are not so obvious, this adds unit tests to ensure
correctness. In the future we may expand this API and also improve
performance, so it is important to have this.
Signed-off-by: Leandro Ribeiro <leandro.ribeiro@collabora.com>