From cee66e4b54e8a9e8098052341f218642a3c2d43c Mon Sep 17 00:00:00 2001 From: Russell King Date: Mon, 22 Oct 2012 15:37:02 +0100 Subject: fd 0 is a valid fd number Do not use 0 to indicate that the fd is uninitialized; use -1 instead. --- bmm_lib.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bmm_lib.c b/bmm_lib.c index 073b213..c4d56f6 100644 --- a/bmm_lib.c +++ b/bmm_lib.c @@ -29,12 +29,12 @@ #define pr_debug(fmt, arg...) do { } while(0) #endif -static int bmm_fd = 0; +static int bmm_fd = -1; int bmm_init() { /* attempt to open the BMM driver */ - if(bmm_fd <= 0) + if(bmm_fd < 0) bmm_fd = open(BMM_DEVICE_FILE, O_RDWR); /* if the open failed, try to mount the driver */ @@ -50,9 +50,9 @@ int bmm_init() void bmm_exit() { - if(bmm_fd > 0) + if(bmm_fd >= 0) close(bmm_fd); - bmm_fd = 0; + bmm_fd = -1; } void *bmm_malloc(unsigned long size, int attr) -- cgit