Both humans and the clang static analyzer find libadf's error handling
confusing.
Now that the platform has better C++ support, we can clean up things up
by switching to C++ and using STL + RAII in targeted parts of the code.
This isn't a complete rewrite in idiomatic C++, but it's enough to get
rid of all the "goto" statements (and the false-positive memory leaks
found by clang's static analyzer).
Bug: 27125399
Test: WITH_STATIC_ANALYZER=1 mmm system/core/adf/libadf
Test: /data/nativetest/adf-unit-tests/adf-unit-tests (on Nexus 9)
Test: /data/nativetest64/adf-unit-tests/adf-unit-tests (on Nexus 9)
Change-Id: Ie9dd5d5dc424d1a3ddcc3cba836fce04190f46fd
Signed-off-by: Greg Hackmann <ghackmann@google.com>
If devs is uninitialized and adf_devices() fails, we'll end up passing
the uninitialized pointer to free().
Test: /data/nativetest64/adf-unit-tests/adf-unit-tests (on Nexus 9 w/o root)
Change-Id: Ifc6038c1da14d32ee564675bac54fc7df2623c1d
Signed-off-by: Greg Hackmann <ghackmann@google.com>
adf_{device,interface_simple}_post_v2 let the client choose what kind of
fence is returned from the kernel:
* ADF_COMPLETE_FENCE_NONE: no fence is returned
* ADF_COMPLETE_FENCE_PRESENT: the returned fence fires when the
specified configuration appears on the screen
* ADF_COMPLETE_FENCE_RELEASE: the returned fence fires when the
specified configuration is removed from the screen
The "V2" calls with fence type ADF_COMPLETE_FENCE_RELEASE are functionally
equivalent to "V1" calls.
Test: included gtest (on Nexus 9)
Change-Id: I36190d1b6cea0fbaed2af3ad64fa4729200c5520
Signed-off-by: Greg Hackmann <ghackmann@google.com>
ADF isn't a candidate for upstreaming and isn't (directly) usable from
unprivileged NDK code, so it makes more sense to keep video/adf.h as a
private header inside libadf, where it'll still be usable by HWC
implementations without shipping in the NDK.
libadf exports its entire include/ directory, so this shouldn't have
any impact on HWC implementations that already link against libadf.
Test: mmm system/core/adf/libadf
Test: /data/nativetest64/adf-unit-tests/adf-unit-tests (on Nexus 9)
Change-Id: I14532d59005196e002f7465474ac3c7cc9e59bd3
Signed-off-by: Greg Hackmann <ghackmann@google.com>
kati needs us to add "tests" as a subdir of the libadf Android.bp.
clang also requires an explicit definition of AdfTest::dev_id where
g++ does not.
Test: mmm system/core/adf/libadf
Test: /data/nativetest64/adf-unit-tests/adf-unit-tests (on Nexus 9)
Change-Id: I1fc371af1b5b115f088edd963a87e6647a52882b
Signed-off-by: Greg Hackmann <ghackmann@google.com>
Some versions of gcc warn that intfs may be used uninitialized
Change-Id: I3b8d7e919e9c2902ac56adeabd09a45ececfb3c4
Signed-off-by: Greg Hackmann <ghackmann@google.com>