Commit 0e799878 authored by Hartmut Knaack's avatar Hartmut Knaack Committed by Jonathan Cameron

tools:iio: return values directly

Return directly, if no common cleanup is required.
Signed-off-by: default avatarHartmut Knaack <knaack.h@gmx.de>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 5dc65d79
...@@ -238,8 +238,7 @@ int main(int argc, char **argv) ...@@ -238,8 +238,7 @@ int main(int argc, char **argv)
dev_num = find_type_by_name(device_name, "iio:device"); dev_num = find_type_by_name(device_name, "iio:device");
if (dev_num < 0) { if (dev_num < 0) {
printf("Failed to find the %s\n", device_name); printf("Failed to find the %s\n", device_name);
ret = dev_num; return dev_num;
goto error_ret;
} }
printf("iio device number being used is %d\n", dev_num); printf("iio device number being used is %d\n", dev_num);
...@@ -410,6 +409,6 @@ int main(int argc, char **argv) ...@@ -410,6 +409,6 @@ int main(int argc, char **argv)
free(trigger_name); free(trigger_name);
error_free_dev_dir_name: error_free_dev_dir_name:
free(dev_dir_name); free(dev_dir_name);
error_ret:
return ret; return ret;
} }
...@@ -258,8 +258,7 @@ int main(int argc, char **argv) ...@@ -258,8 +258,7 @@ int main(int argc, char **argv)
device_name, dev_num); device_name, dev_num);
ret = asprintf(&chrdev_name, "/dev/iio:device%d", dev_num); ret = asprintf(&chrdev_name, "/dev/iio:device%d", dev_num);
if (ret < 0) { if (ret < 0) {
ret = -ENOMEM; return -ENOMEM;
goto error_ret;
} }
} else { } else {
/* If we can't find a IIO device by name assume device_name is a /* If we can't find a IIO device by name assume device_name is a
...@@ -312,6 +311,6 @@ int main(int argc, char **argv) ...@@ -312,6 +311,6 @@ int main(int argc, char **argv)
error_free_chrdev_name: error_free_chrdev_name:
free(chrdev_name); free(chrdev_name);
error_ret:
return ret; return ret;
} }
...@@ -107,10 +107,9 @@ int iioutils_get_type(unsigned *is_signed, ...@@ -107,10 +107,9 @@ int iioutils_get_type(unsigned *is_signed,
const struct dirent *ent; const struct dirent *ent;
ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir); ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir);
if (ret < 0) { if (ret < 0)
ret = -ENOMEM; return -ENOMEM;
goto error_ret;
}
ret = asprintf(&builtname, FORMAT_TYPE_FILE, name); ret = asprintf(&builtname, FORMAT_TYPE_FILE, name);
if (ret < 0) { if (ret < 0) {
ret = -ENOMEM; ret = -ENOMEM;
...@@ -202,7 +201,7 @@ int iioutils_get_type(unsigned *is_signed, ...@@ -202,7 +201,7 @@ int iioutils_get_type(unsigned *is_signed,
free(builtname); free(builtname);
error_free_scan_el_dir: error_free_scan_el_dir:
free(scan_el_dir); free(scan_el_dir);
error_ret:
return ret; return ret;
} }
...@@ -230,10 +229,9 @@ int iioutils_get_param_float(float *output, ...@@ -230,10 +229,9 @@ int iioutils_get_param_float(float *output,
const struct dirent *ent; const struct dirent *ent;
ret = asprintf(&builtname, "%s_%s", name, param_name); ret = asprintf(&builtname, "%s_%s", name, param_name);
if (ret < 0) { if (ret < 0)
ret = -ENOMEM; return -ENOMEM;
goto error_ret;
}
ret = asprintf(&builtname_generic, ret = asprintf(&builtname_generic,
"%s_%s", generic_name, param_name); "%s_%s", generic_name, param_name);
if (ret < 0) { if (ret < 0) {
...@@ -277,7 +275,7 @@ int iioutils_get_param_float(float *output, ...@@ -277,7 +275,7 @@ int iioutils_get_param_float(float *output,
free(builtname_generic); free(builtname_generic);
error_free_builtname: error_free_builtname:
free(builtname); free(builtname);
error_ret:
return ret; return ret;
} }
...@@ -326,10 +324,9 @@ int build_channel_array(const char *device_dir, ...@@ -326,10 +324,9 @@ int build_channel_array(const char *device_dir,
*counter = 0; *counter = 0;
ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir); ret = asprintf(&scan_el_dir, FORMAT_SCAN_ELEMENTS_DIR, device_dir);
if (ret < 0) { if (ret < 0)
ret = -ENOMEM; return -ENOMEM;
goto error_ret;
}
dp = opendir(scan_el_dir); dp = opendir(scan_el_dir);
if (dp == NULL) { if (dp == NULL) {
ret = -errno; ret = -errno;
...@@ -526,7 +523,7 @@ int build_channel_array(const char *device_dir, ...@@ -526,7 +523,7 @@ int build_channel_array(const char *device_dir,
error_free_name: error_free_name:
free(scan_el_dir); free(scan_el_dir);
error_ret:
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment