]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - tools/iio/iio_utils.c
tools:iio: rework program parameters
[karo-tx-linux.git] / tools / iio / iio_utils.c
index 0524725279bb3d675f33049758fc2c4bf921a917..dfee1a3f3f636a846fff85fefbfe69beae26d5f8 100644 (file)
@@ -168,20 +168,17 @@ int iioutils_get_type(unsigned *is_signed,
                                *mask = ~0;
                        else
                                *mask = (1 << *bits_used) - 1;
-                       if (signchar == 's')
-                               *is_signed = 1;
-                       else
-                               *is_signed = 0;
+                       *is_signed = (signchar == 's');
                        if (fclose(sysfsfp)) {
                                ret = -errno;
                                printf("Failed to close %s\n", filename);
                                goto error_free_filename;
                        }
 
+                       sysfsfp = 0;
                        free(filename);
 
                        filename = 0;
-                       sysfsfp = 0;
                }
 error_close_sysfsfp:
        if (sysfsfp)
@@ -315,7 +312,7 @@ int build_channel_array(const char *device_dir,
 {
        DIR *dp;
        FILE *sysfsfp;
-       int count, i;
+       int count = 0, i;
        struct iio_channel_info *current;
        int ret;
        const struct dirent *ent;
@@ -373,7 +370,6 @@ int build_channel_array(const char *device_dir,
                goto error_close_dir;
        }
        seekdir(dp, 0);
-       count = 0;
        while (ent = readdir(dp), ent != NULL) {
                if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
                           "_en") == 0) {