Removed compiler warning - ignoring return value 30/32730/1
authorAnkur <ankur29.garg@samsung.com>
Tue, 23 Dec 2014 07:08:48 +0000 (12:38 +0530)
committerAnkur <ankur29.garg@samsung.com>
Tue, 23 Dec 2014 07:08:54 +0000 (12:38 +0530)
-Warning related to return value of asprintf() being ignored.
- asprintf returns -1 if failed. Added an if statement to check if the asprintf has failed or not.

Change-Id: I35a80554dd730e1722b975e488335910fd330d56

src/shared/iio_common.cpp

index a127ca0..7cfcba5 100644 (file)
@@ -103,7 +103,9 @@ int add_channel_to_array(const char *device_dir, const char *ch_name, struct cha
        if (i == 0)
                return -1;
 
-       asprintf(&(channel->prefix_str), "%s", ch_name);
+       if (asprintf(&(channel->prefix_str), "%s", ch_name) == -1)
+               return -1;
+
        channel->is_en = 1;
        channel->scale = 1.0;
        channel->offset = 0.0;