From 34e730c8fac6753f03a9c3bbac7629546ecdac1e Mon Sep 17 00:00:00 2001 From: Siarzhuk Zharski Date: Fri, 18 May 2012 21:56:22 +0200 Subject: [PATCH] Fixes for Coverity CIDs 702013,702014,702015,702016,702017. Satisfying Coverity for case of resource leak in case open() returns file descriptor equal to 0. --- src/add-ons/kernel/drivers/audio/ac97/sis7018/Settings.cpp | 4 ++-- src/add-ons/kernel/drivers/network/sis19x/Settings.cpp | 4 ++-- src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp | 4 ++-- src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/add-ons/kernel/drivers/audio/ac97/sis7018/Settings.cpp b/src/add-ons/kernel/drivers/audio/ac97/sis7018/Settings.cpp index 52cfd552c5..06df5c8435 100644 --- a/src/add-ons/kernel/drivers/audio/ac97/sis7018/Settings.cpp +++ b/src/add-ons/kernel/drivers/audio/ac97/sis7018/Settings.cpp @@ -29,7 +29,7 @@ void create_log() int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0); int fd = open(gLogFilePath, flags, 0666); - if (fd > 0) + if (fd >= 0) close(fd); mutex_init(&gLogLock, DRIVER_NAME"-logging"); @@ -108,7 +108,7 @@ void SiS7018_trace(bool force, const char* func, const char *fmt, ...) mutex_lock(&gLogLock); int fd = open(gLogFilePath, O_WRONLY | O_APPEND); - if (fd > 0) { + if (fd >= 0) { write(fd, buffer, strlen(buffer)); close(fd); } diff --git a/src/add-ons/kernel/drivers/network/sis19x/Settings.cpp b/src/add-ons/kernel/drivers/network/sis19x/Settings.cpp index bace1fe07b..007d45f42b 100644 --- a/src/add-ons/kernel/drivers/network/sis19x/Settings.cpp +++ b/src/add-ons/kernel/drivers/network/sis19x/Settings.cpp @@ -36,7 +36,7 @@ void create_log() int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0); int fd = open(gLogFilePath, flags, 0666); - if (fd > 0) + if (fd >= 0) close(fd); mutex_init(&gLogLock, DRIVER_NAME"-logging"); @@ -122,7 +122,7 @@ void SiS19X_trace(bool force, const char* func, const char *fmt, ...) mutex_lock(&gLogLock); int fd = open(gLogFilePath, O_WRONLY | O_APPEND); - if (fd > 0) { + if (fd >= 0) { write(fd, buffer, strlen(buffer)); close(fd); } diff --git a/src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp b/src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp index 467cd5117b..d5f179117e 100644 --- a/src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp +++ b/src/add-ons/kernel/drivers/network/usb_asix/Settings.cpp @@ -36,7 +36,7 @@ void create_log() int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0); int fd = open(gLogFilePath, flags, 0666); - if (fd > 0) + if (fd >= 0) close(fd); mutex_init(&gLogLock, DRIVER_NAME"-logging"); @@ -117,7 +117,7 @@ void usb_asix_trace(bool force, const char* func, const char *fmt, ...) mutex_lock(&gLogLock); int fd = open(gLogFilePath, O_WRONLY | O_APPEND); - if (fd > 0) { + if (fd >= 0) { write(fd, buffer, strlen(buffer)); close(fd); } diff --git a/src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp b/src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp index 6cd24e7947..3aaf213087 100644 --- a/src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp +++ b/src/add-ons/kernel/drivers/network/usb_davicom/Settings.cpp @@ -37,7 +37,7 @@ void create_log() int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0); int fd = open(gLogFilePath, flags, 0666); - if (fd > 0) + if (fd >= 0) close(fd); mutex_init(&gLogLock, DRIVER_NAME"-logging"); @@ -124,7 +124,7 @@ void usb_davicom_trace(bool force, const char* func, const char *fmt, ...) mutex_lock(&gLogLock); int fd = open(gLogFilePath, O_WRONLY | O_APPEND); - if (fd > 0) { + if (fd >= 0) { write(fd, buffer, strlen(buffer)); close(fd); }