Consistently check the fd value
authorEmil Velikov <emil.l.velikov@gmail.com>
Tue, 14 Jul 2015 13:55:42 +0000 (14:55 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 16 Jul 2015 15:41:53 +0000 (16:41 +0100)
Follow the approach used through the rest of the project.

Suggested-by: Thierry Reding <thierry.reding@gmail.com>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
intel/test_decode.c
tests/name_from_fd.c

index bef86bb..b4eddcd 100644 (file)
@@ -56,7 +56,7 @@ read_file(const char *filename, void **ptr, size_t *size)
        struct stat st;
 
        fd = open(filename, O_RDONLY);
-       if (fd == -1)
+       if (fd < 0)
                errx(1, "couldn't open `%s'", filename);
 
        ret = fstat(fd, &st);
index 24af6e6..5264681 100644 (file)
@@ -45,7 +45,7 @@ int main(int argc, char **argv)
        char *v;
 
        fd = open("/dev/dri/card0", O_RDWR);
-       if (fd == -1)
+       if (fd < 0)
                return 0;
 
        v = drmGetDeviceNameFromFd(fd);