HAL: Add forgotten {} after if
My previous fix to close resources on error was buggy.
The if did not have {} around the `then` statement.
Thus sndmonitor was broken.
Test: vts-tradefed run vts --module VtsHalAudioV2_0Target
Test: call/play music/record/video...
Bug: 38186481
Change-Id: I643c38c3bed76c63359348aeaccb774b64bf6f7c
Signed-off-by: Kevin Rocard <krocard@google.com>
diff --git a/hal/audio_extn/sndmonitor.c b/hal/audio_extn/sndmonitor.c
index f4e208c..86a5b93 100644
--- a/hal/audio_extn/sndmonitor.c
+++ b/hal/audio_extn/sndmonitor.c
@@ -190,9 +190,10 @@
}
ret = add_new_sndcard(atoi(ptr), fd);
- if (ret != 0)
- close(fd);
+ if (ret != 0) {
+ close(fd); // card state fd ownership is taken by sndcard on success
continue;
+ }
num_cards++;
@@ -219,9 +220,10 @@
continue;
ret = add_new_sndcard(CPE_MAGIC_NUM+num_cpe, fd);
- if (ret != 0)
- close(fd);
+ if (ret != 0) {
+ close(fd); // card state fd ownership is taken by sndcard on success
continue;
+ }
num_cpe++;
num_cards++;