Consistently check the fd value

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>
main
Emil Velikov 2015-07-14 14:55:42 +01:00
parent c1cd3d9388
commit c08655271a
2 changed files with 2 additions and 2 deletions

View 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);

View 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);