aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-05-27 09:17:43 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-05-27 09:21:28 +1200
commitcb7abfb92d2c1fba40c686f28ab55f8a8fa931eb (patch)
tree5242cc6a3b130872282b7cb2c75dd848bd81805f
parentSimplify types for sort func (diff)
downloadtunics-cb7abfb92d2c1fba40c686f28ab55f8a8fa931eb.tar.gz
tunics-cb7abfb92d2c1fba40c686f28ab55f8a8fa931eb.zip
Use implicit NULL tests
-rw-r--r--ls.c4
-rw-r--r--pwd.c2
-rw-r--r--sort.c4
-rw-r--r--whoami.c2
4 files changed, 6 insertions, 6 deletions
diff --git a/ls.c b/ls.c
index fbd05be..aabb305 100644
--- a/ls.c
+++ b/ls.c
@@ -12,13 +12,13 @@ int main(int argc, char **argv)
dirname = ".";
}
- if ((dir = opendir(dirname)) == NULL) {
+ if (!(dir = opendir(dirname))) {
perror("opendir");
free(dir);
exit(EXIT_FAILURE);
}
- while ((dirent = readdir(dir)) != NULL) {
+ while ((dirent = readdir(dir))) {
fprintf(stdout, "%s\n", dirent->d_name);
}
if (errno) {
diff --git a/pwd.c b/pwd.c
index 13aeb06..3c6af52 100644
--- a/pwd.c
+++ b/pwd.c
@@ -3,7 +3,7 @@
int main(void)
{
char buf[PATH_MAX];
- if (getcwd(buf, sizeof(buf)) == NULL) {
+ if (!getcwd(buf, sizeof(buf))) {
perror("getcwd");
exit(EXIT_FAILURE);
}
diff --git a/sort.c b/sort.c
index a5c09b1..ee4949d 100644
--- a/sort.c
+++ b/sort.c
@@ -7,7 +7,7 @@ int main(void) {
lines = vec_init();
- while ((line = read_line(stdin)) != NULL) {
+ while ((line = read_line(stdin))) {
vec_add(lines, line);
}
free(line);
@@ -34,7 +34,7 @@ char *read_line(FILE* stream) {
buf = malloc(BUF_SIZE);
for (;;) {
- if (fgets(buf, BUF_SIZE, stream) == NULL) {
+ if (!fgets(buf, BUF_SIZE, stream)) {
free(buf);
free(line);
return NULL;
diff --git a/whoami.c b/whoami.c
index 8b3484b..3d1cae9 100644
--- a/whoami.c
+++ b/whoami.c
@@ -3,7 +3,7 @@
int main(void) {
struct passwd *p;
- if ((p = getpwuid(getuid())) == NULL) {
+ if (!(p = getpwuid(getuid()))) {
exit(EXIT_FAILURE);
}