Fixing Coverity issues. No functional changes
CID 3490 CID 3491 CID 8928 CID 10630 CID 10631 CID 10664 CID 10731 CID 10754 CID 11049 CID 11141 CID 11147 CID 11148
This commit is contained in:
@@ -338,7 +338,7 @@ Device::_MultiGetDescription(multi_description *multiDescription)
|
||||
Description.interface_minimum = B_CURRENT_INTERFACE_VERSION;
|
||||
|
||||
strncpy(Description.friendly_name, fInfo.Name(),
|
||||
sizeof(Description.friendly_name));
|
||||
sizeof(Description.friendly_name) - 1);
|
||||
|
||||
strncpy(Description.vendor_info, "Haiku.Inc.",
|
||||
sizeof(Description.vendor_info));
|
||||
|
||||
@@ -477,7 +477,8 @@ Mixer::_CreateMIXControlGroup(multi_mix_control_info* MultiInfo, int32& index,
|
||||
Controls[index].parent = parentIndex;
|
||||
Controls[index].string = Info.fNameId;
|
||||
if (Info.fName != NULL)
|
||||
strlcpy(Controls[index].name, Info.fName, sizeof(Controls[index].name));
|
||||
strlcpy(Controls[index].name, Info.fName,
|
||||
sizeof(Controls[index].name) - 1);
|
||||
index++;
|
||||
|
||||
if (Info.fType & MIX_Mute) {
|
||||
|
||||
@@ -28,7 +28,9 @@ void create_log()
|
||||
return;
|
||||
|
||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
||||
close(open(gLogFilePath, flags, 0666));
|
||||
int fd = open(gLogFilePath, flags, 0666);
|
||||
if (fd > 0)
|
||||
close(fd);
|
||||
|
||||
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||
}
|
||||
@@ -77,7 +79,7 @@ void SiS7018_trace(bool force, const char* func, const char *fmt, ...)
|
||||
static char buffer[1024];
|
||||
char *buf_ptr = buffer;
|
||||
if (gLogFilePath == NULL) {
|
||||
strcpy(buffer, prefix);
|
||||
strncpy(buffer, prefix, sizeof(buffer) - 1);
|
||||
buf_ptr += strlen(prefix);
|
||||
}
|
||||
|
||||
@@ -106,8 +108,10 @@ void SiS7018_trace(bool force, const char* func, const char *fmt, ...)
|
||||
|
||||
mutex_lock(&gLogLock);
|
||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||
write(fd, buffer, strlen(buffer));
|
||||
close(fd);
|
||||
if (fd > 0) {
|
||||
write(fd, buffer, strlen(buffer));
|
||||
close(fd);
|
||||
}
|
||||
mutex_unlock(&gLogLock);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
#include "Stream.h"
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
#include "Device.h"
|
||||
#include "Registers.h"
|
||||
#include "Settings.h"
|
||||
@@ -34,6 +36,7 @@ Stream::Stream(Device *device, bool isInput)
|
||||
fFormat.format = B_FMT_16BIT;
|
||||
fFormat.rate = B_SR_48000;
|
||||
fFormat.cvsr = _DecodeRate(fFormat.rate);
|
||||
memset(fFormat._reserved_, 0, sizeof(fFormat._reserved_));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ ASIXDevice::ASIXDevice(usb_device device, DeviceInfo& deviceInfo)
|
||||
fIPG[1] = 0x0c;
|
||||
fIPG[2] = 0x12;
|
||||
|
||||
memset(&fMACAddress, 0, sizeof(fMACAddress));
|
||||
|
||||
fNotifyReadSem = create_sem(0, DRIVER_NAME"_notify_read");
|
||||
if (fNotifyReadSem < B_OK) {
|
||||
TRACE_ALWAYS("Error of creating read notify semaphore:%#010x\n",
|
||||
|
||||
@@ -35,7 +35,9 @@ void create_log()
|
||||
return;
|
||||
|
||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
||||
close(open(gLogFilePath, flags, 0666));
|
||||
int fd = open(gLogFilePath, flags, 0666);
|
||||
if (fd > 0)
|
||||
close(fd);
|
||||
|
||||
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||
}
|
||||
@@ -86,7 +88,7 @@ void usb_asix_trace(bool force, const char* func, const char *fmt, ...)
|
||||
static char buffer[1024];
|
||||
char *buf_ptr = buffer;
|
||||
if (gLogFilePath == NULL) {
|
||||
strcpy(buffer, prefix);
|
||||
strncpy(buffer, prefix, sizeof(buffer) - 1);
|
||||
buf_ptr += strlen(prefix);
|
||||
}
|
||||
|
||||
@@ -115,8 +117,10 @@ void usb_asix_trace(bool force, const char* func, const char *fmt, ...)
|
||||
|
||||
mutex_lock(&gLogLock);
|
||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||
write(fd, buffer, strlen(buffer));
|
||||
close(fd);
|
||||
if (fd > 0) {
|
||||
write(fd, buffer, strlen(buffer));
|
||||
close(fd);
|
||||
}
|
||||
mutex_unlock(&gLogLock);
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,8 @@ DavicomDevice::DavicomDevice(usb_device device, DeviceInfo& deviceInfo)
|
||||
{
|
||||
fDeviceInfo = deviceInfo;
|
||||
|
||||
memset(&fMACAddress, 0, sizeof(fMACAddress));
|
||||
|
||||
fNotifyReadSem = create_sem(0, DRIVER_NAME"_notify_read");
|
||||
if (fNotifyReadSem < B_OK) {
|
||||
TRACE_ALWAYS("Error of creating read notify semaphore:%#010x\n",
|
||||
|
||||
@@ -36,7 +36,9 @@ void create_log()
|
||||
return;
|
||||
|
||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
||||
close(open(gLogFilePath, flags, 0666));
|
||||
int fd = open(gLogFilePath, flags, 0666);
|
||||
if (fd > 0)
|
||||
close(fd);
|
||||
|
||||
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||
}
|
||||
@@ -93,7 +95,7 @@ void usb_davicom_trace(bool force, const char* func, const char *fmt, ...)
|
||||
static char buffer[1024];
|
||||
char *buf_ptr = buffer;
|
||||
if (gLogFilePath == NULL) {
|
||||
strcpy(buffer, prefix);
|
||||
strncpy(buffer, prefix, sizeof(buffer) - 1);
|
||||
buf_ptr += strlen(prefix);
|
||||
}
|
||||
|
||||
@@ -122,8 +124,10 @@ void usb_davicom_trace(bool force, const char* func, const char *fmt, ...)
|
||||
|
||||
mutex_lock(&gLogLock);
|
||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||
write(fd, buffer, strlen(buffer));
|
||||
close(fd);
|
||||
if (fd > 0) {
|
||||
write(fd, buffer, strlen(buffer));
|
||||
close(fd);
|
||||
}
|
||||
mutex_unlock(&gLogLock);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user