mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-06 14:48:06 +00:00
tools: iio: Remove explicit NULL comparison
Remove explicit NULL comparison and write it in its simpler form as recommended by checkpatch.pl. Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com> Reviewed-by: Hartmut Knaack <knaack.h@gmx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
8ab6abfca0
commit
ff1ac639b3
3 changed files with 35 additions and 35 deletions
|
@ -270,7 +270,7 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_name == NULL) {
|
if (!device_name) {
|
||||||
printf("Device name not set\n");
|
printf("Device name not set\n");
|
||||||
print_usage();
|
print_usage();
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -290,7 +290,7 @@ int main(int argc, char **argv)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
if (!notrigger) {
|
if (!notrigger) {
|
||||||
if (trigger_name == NULL) {
|
if (!trigger_name) {
|
||||||
/*
|
/*
|
||||||
* Build the trigger name. If it is device associated
|
* Build the trigger name. If it is device associated
|
||||||
* its name is <device_name>_dev[n] where n matches
|
* its name is <device_name>_dev[n] where n matches
|
||||||
|
|
|
@ -117,13 +117,13 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
|
||||||
}
|
}
|
||||||
|
|
||||||
dp = opendir(scan_el_dir);
|
dp = opendir(scan_el_dir);
|
||||||
if (dp == NULL) {
|
if (!dp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
goto error_free_builtname_generic;
|
goto error_free_builtname_generic;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
while (ent = readdir(dp), ent != NULL)
|
while (ent = readdir(dp), ent)
|
||||||
/*
|
/*
|
||||||
* Do we allow devices to override a generic name with
|
* Do we allow devices to override a generic name with
|
||||||
* a specific one?
|
* a specific one?
|
||||||
|
@ -138,7 +138,7 @@ int iioutils_get_type(unsigned *is_signed, unsigned *bytes, unsigned *bits_used,
|
||||||
}
|
}
|
||||||
|
|
||||||
sysfsfp = fopen(filename, "r");
|
sysfsfp = fopen(filename, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
printf("failed to open %s\n", filename);
|
printf("failed to open %s\n", filename);
|
||||||
goto error_free_filename;
|
goto error_free_filename;
|
||||||
|
@ -235,13 +235,13 @@ int iioutils_get_param_float(float *output, const char *param_name,
|
||||||
}
|
}
|
||||||
|
|
||||||
dp = opendir(device_dir);
|
dp = opendir(device_dir);
|
||||||
if (dp == NULL) {
|
if (!dp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
goto error_free_builtname_generic;
|
goto error_free_builtname_generic;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = -ENOENT;
|
ret = -ENOENT;
|
||||||
while (ent = readdir(dp), ent != NULL)
|
while (ent = readdir(dp), ent)
|
||||||
if ((strcmp(builtname, ent->d_name) == 0) ||
|
if ((strcmp(builtname, ent->d_name) == 0) ||
|
||||||
(strcmp(builtname_generic, ent->d_name) == 0)) {
|
(strcmp(builtname_generic, ent->d_name) == 0)) {
|
||||||
ret = asprintf(&filename,
|
ret = asprintf(&filename,
|
||||||
|
@ -325,12 +325,12 @@ int build_channel_array(const char *device_dir,
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
dp = opendir(scan_el_dir);
|
dp = opendir(scan_el_dir);
|
||||||
if (dp == NULL) {
|
if (!dp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
goto error_free_name;
|
goto error_free_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ent = readdir(dp), ent != NULL)
|
while (ent = readdir(dp), ent)
|
||||||
if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
|
if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
|
||||||
"_en") == 0) {
|
"_en") == 0) {
|
||||||
ret = asprintf(&filename,
|
ret = asprintf(&filename,
|
||||||
|
@ -341,7 +341,7 @@ int build_channel_array(const char *device_dir,
|
||||||
}
|
}
|
||||||
|
|
||||||
sysfsfp = fopen(filename, "r");
|
sysfsfp = fopen(filename, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
free(filename);
|
free(filename);
|
||||||
goto error_close_dir;
|
goto error_close_dir;
|
||||||
|
@ -369,13 +369,13 @@ int build_channel_array(const char *device_dir,
|
||||||
}
|
}
|
||||||
|
|
||||||
*ci_array = malloc(sizeof(**ci_array) * (*counter));
|
*ci_array = malloc(sizeof(**ci_array) * (*counter));
|
||||||
if (*ci_array == NULL) {
|
if (!*ci_array) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto error_close_dir;
|
goto error_close_dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
seekdir(dp, 0);
|
seekdir(dp, 0);
|
||||||
while (ent = readdir(dp), ent != NULL) {
|
while (ent = readdir(dp), ent) {
|
||||||
if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
|
if (strcmp(ent->d_name + strlen(ent->d_name) - strlen("_en"),
|
||||||
"_en") == 0) {
|
"_en") == 0) {
|
||||||
int current_enabled = 0;
|
int current_enabled = 0;
|
||||||
|
@ -391,7 +391,7 @@ int build_channel_array(const char *device_dir,
|
||||||
}
|
}
|
||||||
|
|
||||||
sysfsfp = fopen(filename, "r");
|
sysfsfp = fopen(filename, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
free(filename);
|
free(filename);
|
||||||
count--;
|
count--;
|
||||||
|
@ -424,7 +424,7 @@ int build_channel_array(const char *device_dir,
|
||||||
current->name = strndup(ent->d_name,
|
current->name = strndup(ent->d_name,
|
||||||
strlen(ent->d_name) -
|
strlen(ent->d_name) -
|
||||||
strlen("_en"));
|
strlen("_en"));
|
||||||
if (current->name == NULL) {
|
if (!current->name) {
|
||||||
free(filename);
|
free(filename);
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
count--;
|
count--;
|
||||||
|
@ -452,7 +452,7 @@ int build_channel_array(const char *device_dir,
|
||||||
}
|
}
|
||||||
|
|
||||||
sysfsfp = fopen(filename, "r");
|
sysfsfp = fopen(filename, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
printf("failed to open %s\n", filename);
|
printf("failed to open %s\n", filename);
|
||||||
free(filename);
|
free(filename);
|
||||||
|
@ -567,12 +567,12 @@ int find_type_by_name(const char *name, const char *type)
|
||||||
char *filename;
|
char *filename;
|
||||||
|
|
||||||
dp = opendir(iio_dir);
|
dp = opendir(iio_dir);
|
||||||
if (dp == NULL) {
|
if (!dp) {
|
||||||
printf("No industrialio devices available\n");
|
printf("No industrialio devices available\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ent = readdir(dp), ent != NULL) {
|
while (ent = readdir(dp), ent) {
|
||||||
if (strcmp(ent->d_name, ".") != 0 &&
|
if (strcmp(ent->d_name, ".") != 0 &&
|
||||||
strcmp(ent->d_name, "..") != 0 &&
|
strcmp(ent->d_name, "..") != 0 &&
|
||||||
strlen(ent->d_name) > strlen(type) &&
|
strlen(ent->d_name) > strlen(type) &&
|
||||||
|
@ -595,7 +595,7 @@ int find_type_by_name(const char *name, const char *type)
|
||||||
":", 1) != 0) {
|
":", 1) != 0) {
|
||||||
filename = malloc(strlen(iio_dir) + strlen(type)
|
filename = malloc(strlen(iio_dir) + strlen(type)
|
||||||
+ numstrlen + 6);
|
+ numstrlen + 6);
|
||||||
if (filename == NULL) {
|
if (!filename) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
goto error_close_dir;
|
goto error_close_dir;
|
||||||
}
|
}
|
||||||
|
@ -654,7 +654,7 @@ static int _write_sysfs_int(const char *filename, const char *basedir, int val,
|
||||||
int test;
|
int test;
|
||||||
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
||||||
|
|
||||||
if (temp == NULL)
|
if (!temp)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ret = sprintf(temp, "%s/%s", basedir, filename);
|
ret = sprintf(temp, "%s/%s", basedir, filename);
|
||||||
|
@ -662,7 +662,7 @@ static int _write_sysfs_int(const char *filename, const char *basedir, int val,
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
|
||||||
sysfsfp = fopen(temp, "w");
|
sysfsfp = fopen(temp, "w");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
printf("failed to open %s\n", temp);
|
printf("failed to open %s\n", temp);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
@ -683,7 +683,7 @@ static int _write_sysfs_int(const char *filename, const char *basedir, int val,
|
||||||
|
|
||||||
if (verify) {
|
if (verify) {
|
||||||
sysfsfp = fopen(temp, "r");
|
sysfsfp = fopen(temp, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
printf("failed to open %s\n", temp);
|
printf("failed to open %s\n", temp);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
@ -749,7 +749,7 @@ static int _write_sysfs_string(const char *filename, const char *basedir,
|
||||||
FILE *sysfsfp;
|
FILE *sysfsfp;
|
||||||
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
||||||
|
|
||||||
if (temp == NULL) {
|
if (!temp) {
|
||||||
printf("Memory allocation failed\n");
|
printf("Memory allocation failed\n");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -759,7 +759,7 @@ static int _write_sysfs_string(const char *filename, const char *basedir,
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
|
||||||
sysfsfp = fopen(temp, "w");
|
sysfsfp = fopen(temp, "w");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
printf("Could not open %s\n", temp);
|
printf("Could not open %s\n", temp);
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
@ -780,7 +780,7 @@ static int _write_sysfs_string(const char *filename, const char *basedir,
|
||||||
|
|
||||||
if (verify) {
|
if (verify) {
|
||||||
sysfsfp = fopen(temp, "r");
|
sysfsfp = fopen(temp, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
printf("Could not open file to verify\n");
|
printf("Could not open file to verify\n");
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
@ -855,7 +855,7 @@ int read_sysfs_posint(const char *filename, const char *basedir)
|
||||||
FILE *sysfsfp;
|
FILE *sysfsfp;
|
||||||
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
||||||
|
|
||||||
if (temp == NULL) {
|
if (!temp) {
|
||||||
printf("Memory allocation failed");
|
printf("Memory allocation failed");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,7 @@ int read_sysfs_posint(const char *filename, const char *basedir)
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
|
||||||
sysfsfp = fopen(temp, "r");
|
sysfsfp = fopen(temp, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
@ -902,7 +902,7 @@ int read_sysfs_float(const char *filename, const char *basedir, float *val)
|
||||||
FILE *sysfsfp;
|
FILE *sysfsfp;
|
||||||
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
||||||
|
|
||||||
if (temp == NULL) {
|
if (!temp) {
|
||||||
printf("Memory allocation failed");
|
printf("Memory allocation failed");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -912,7 +912,7 @@ int read_sysfs_float(const char *filename, const char *basedir, float *val)
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
|
||||||
sysfsfp = fopen(temp, "r");
|
sysfsfp = fopen(temp, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
@ -949,7 +949,7 @@ int read_sysfs_string(const char *filename, const char *basedir, char *str)
|
||||||
FILE *sysfsfp;
|
FILE *sysfsfp;
|
||||||
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
char *temp = malloc(strlen(basedir) + strlen(filename) + 2);
|
||||||
|
|
||||||
if (temp == NULL) {
|
if (!temp) {
|
||||||
printf("Memory allocation failed");
|
printf("Memory allocation failed");
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
@ -959,7 +959,7 @@ int read_sysfs_string(const char *filename, const char *basedir, char *str)
|
||||||
goto error_free;
|
goto error_free;
|
||||||
|
|
||||||
sysfsfp = fopen(temp, "r");
|
sysfsfp = fopen(temp, "r");
|
||||||
if (sysfsfp == NULL) {
|
if (!sysfsfp) {
|
||||||
ret = -errno;
|
ret = -errno;
|
||||||
goto error_free;
|
goto error_free;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,10 +46,10 @@ static int dump_channels(const char *dev_dir_name)
|
||||||
const struct dirent *ent;
|
const struct dirent *ent;
|
||||||
|
|
||||||
dp = opendir(dev_dir_name);
|
dp = opendir(dev_dir_name);
|
||||||
if (dp == NULL)
|
if (!dp)
|
||||||
return -errno;
|
return -errno;
|
||||||
|
|
||||||
while (ent = readdir(dp), ent != NULL)
|
while (ent = readdir(dp), ent)
|
||||||
if (check_prefix(ent->d_name, "in_") &&
|
if (check_prefix(ent->d_name, "in_") &&
|
||||||
check_postfix(ent->d_name, "_raw"))
|
check_postfix(ent->d_name, "_raw"))
|
||||||
printf(" %-10s\n", ent->d_name);
|
printf(" %-10s\n", ent->d_name);
|
||||||
|
@ -107,12 +107,12 @@ static int dump_devices(void)
|
||||||
DIR *dp;
|
DIR *dp;
|
||||||
|
|
||||||
dp = opendir(iio_dir);
|
dp = opendir(iio_dir);
|
||||||
if (dp == NULL) {
|
if (!dp) {
|
||||||
printf("No industrial I/O devices available\n");
|
printf("No industrial I/O devices available\n");
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (ent = readdir(dp), ent != NULL) {
|
while (ent = readdir(dp), ent) {
|
||||||
if (check_prefix(ent->d_name, type_device)) {
|
if (check_prefix(ent->d_name, type_device)) {
|
||||||
char *dev_dir_name;
|
char *dev_dir_name;
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ static int dump_devices(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rewinddir(dp);
|
rewinddir(dp);
|
||||||
while (ent = readdir(dp), ent != NULL) {
|
while (ent = readdir(dp), ent) {
|
||||||
if (check_prefix(ent->d_name, type_trigger)) {
|
if (check_prefix(ent->d_name, type_trigger)) {
|
||||||
char *dev_dir_name;
|
char *dev_dir_name;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue