agm: Address potential coding issues
Fixed potential NULL pointer dreference.
Initialize the uninitialized variables,
thus preventing the usage of an erroneous value.
Change-Id: I1c4381012a752fa033484309ad9769f635d61e59
diff --git a/plugins/tinyalsa/test/agmcompresscap.c b/plugins/tinyalsa/test/agmcompresscap.c
index 08c7061..aad5287 100644
--- a/plugins/tinyalsa/test/agmcompresscap.c
+++ b/plugins/tinyalsa/test/agmcompresscap.c
@@ -471,13 +471,13 @@
int main(int argc, char **argv)
{
- char *file;
+ char *file = NULL;
unsigned long buffer_size = 0;
unsigned int card = 0, device = 0, frag = 0, length = 0;
unsigned int rate = DEFAULT_RATE, channels = DEFAULT_CHANNELS;
unsigned int bits = 16;
unsigned int format = DEFAULT_FORMAT;
- char* intf_name;
+ char* intf_name = NULL;
int ret = 0;
unsigned int devicepp_kv = DEVICEPP_TX_AUDIO_FLUENCE_SMECNS;
unsigned int stream_kv = 0;
diff --git a/plugins/tinyalsa/test/agmhostless.c b/plugins/tinyalsa/test/agmhostless.c
index d9228a2..4819725 100644
--- a/plugins/tinyalsa/test/agmhostless.c
+++ b/plugins/tinyalsa/test/agmhostless.c
@@ -219,6 +219,11 @@
struct group_config grp_config;
stream_kv = stream_kv ? stream_kv : PCM_RX_LOOPBACK;
+ if (!cap_config || !p_config || !capture_intf || !play_intf) {
+ printf("%s: %d: Invalid arguments.\n", __func__, __LINE__);
+ return;
+ }
+
memset(&config, 0, sizeof(config));
config.channels = channels;
config.rate = rate;