summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Ettl <ettl.martin@gmx.de>2009-10-08 13:27:30 +1100
committerDaniel Stone <daniel@fooishbar.org>2009-10-08 13:27:30 +1100
commit4df3e8c8053d9d4b3043f339a73d0de97020d884 (patch)
treef7444e06c461491996bf146f4320ccfbd523ee53
parent4151a13c80f3afa43f88afcf19a7aeb16dace93a (diff)
Resource leakage: 0 is a valid file descriptor
When testing if an fd is valid, the required construct is >= 0, not > 0. [Daniel: Fixed up the Linux MTRR case as well.] Signed-off-by: Martin Ettl <ettl.martin@gmx.de> Signed-off-by: Daniel Stone <daniel@fooishbar.org>
-rw-r--r--hw/kdrive/linux/bus.c6
-rw-r--r--hw/xfree86/common/xf86Configure.c2
-rw-r--r--hw/xfree86/os-support/linux/lnx_video.c2
3 files changed, 5 insertions, 5 deletions
diff --git a/hw/kdrive/linux/bus.c b/hw/kdrive/linux/bus.c
index ba8a6cd43..93c3ea5f3 100644
--- a/hw/kdrive/linux/bus.c
+++ b/hw/kdrive/linux/bus.c
@@ -72,7 +72,7 @@ BusInit (KdPointerInfo *pi)
{
for (i = 0; i < NUM_BUS_NAMES; i++)
{
- if ((fd = open (BusNames[i], 0)) > 0)
+ if ((fd = open (BusNames[i], 0)) >= 0)
{
close(fd);
if (pi->path)
@@ -84,7 +84,7 @@ BusInit (KdPointerInfo *pi)
}
else
{
- if ((fd = open(pi->path, 0)) > 0)
+ if ((fd = open(pi->path, 0)) >= 0)
{
close(fd);
return Success;
@@ -99,7 +99,7 @@ BusEnable (KdPointerInfo *pi)
{
int fd = open(pi->path, 0);
- if (fd > 0)
+ if (fd >= 0)
{
KdRegisterFd(fd, BusRead, pi);
pi->driverPrivate = (void *)fd;
diff --git a/hw/xfree86/common/xf86Configure.c b/hw/xfree86/common/xf86Configure.c
index bce5aae58..3b7828a3f 100644
--- a/hw/xfree86/common/xf86Configure.c
+++ b/hw/xfree86/common/xf86Configure.c
@@ -253,7 +253,7 @@ configureInputSection (void)
int fd;
#ifdef WSCONS_SUPPORT
fd = open("/dev/wsmouse", 0);
- if (fd > 0) {
+ if (fd >= 0) {
DFLT_MOUSE_DEV = "/dev/wsmouse";
DFLT_MOUSE_PROTO = "wsmouse";
close(fd);
diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 73409dfba..09d178797 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -336,7 +336,7 @@ mtrr_undo_wc_region(int screenNum, struct mtrr_wc_region *wcr)
{
struct mtrr_wc_region *p, *prev;
- if (mtrr_fd > 0) {
+ if (mtrr_fd >= 0) {
p = wcr;
while (p) {
if (p->added)