diff --git a/samples/enumdevdir.c b/samples/enumdevdir.c index 97d69d8a6..bf1ff3bbb 100644 --- a/samples/enumdevdir.c +++ b/samples/enumdevdir.c @@ -11,12 +11,14 @@ #include #include #include +#include #include #include #include -int printdir (char *newdir) +/* returns true for error, false for OK */ +bool printdir (char *newdir) { char *olddir; char *curdir; @@ -27,10 +29,9 @@ int printdir (char *newdir) unsigned num; olddir = malloc (FILENAME_MAX); - if (olddir != NULL) { - + if (olddir == NULL) { perror ("cannot allocate memory"); - return 1; + return true; } getcwd (olddir, FILENAME_MAX); @@ -41,14 +42,13 @@ int printdir (char *newdir) */ printf (" Dir %s\n", newdir); free (olddir); - return 0; + return false; } curdir = malloc (FILENAME_MAX); - if (curdir != NULL) { - + if (curdir == NULL) { perror ("cannot allocate memory"); - return 1; + return true; } /* We call getcwd() in order to print the @@ -88,7 +88,7 @@ int printdir (char *newdir) chdir (olddir); free (olddir); - return 0; + return false; } @@ -98,8 +98,7 @@ void main (void) char *devicedir; devicedir = malloc (FILENAME_MAX); - if (devicedir != NULL) { - + if (devicedir == NULL) { perror ("cannot allocate memory"); return; }