Preventive fixes for possible Coverity complaints in the future.
This commit is contained in:
@@ -1302,7 +1302,7 @@ AudioControlInterface::_ListFeatureUnitOption(uint32 controlType,
|
|||||||
Controls[index].parent = parentIndex;
|
Controls[index].parent = parentIndex;
|
||||||
Controls[index].string = string;
|
Controls[index].string = string;
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
strncpy(Controls[index].name, name, sizeof(Controls[index].name));
|
strlcpy(Controls[index].name, name, sizeof(Controls[index].name));
|
||||||
if (initGainLimits)
|
if (initGainLimits)
|
||||||
_InitGainLimits(Controls[index]);
|
_InitGainLimits(Controls[index]);
|
||||||
|
|
||||||
@@ -1316,7 +1316,7 @@ AudioControlInterface::_ListFeatureUnitOption(uint32 controlType,
|
|||||||
Controls[index].master = masterIndex;
|
Controls[index].master = masterIndex;
|
||||||
Controls[index].string = string;
|
Controls[index].string = string;
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
strncpy(Controls[index].name, name,
|
strlcpy(Controls[index].name, name,
|
||||||
sizeof(Controls[index].name));
|
sizeof(Controls[index].name));
|
||||||
if (initGainLimits)
|
if (initGainLimits)
|
||||||
_InitGainLimits(Controls[index]);
|
_InitGainLimits(Controls[index]);
|
||||||
@@ -1465,7 +1465,7 @@ AudioControlInterface::_ListSelectorUnitControl(int32& index, int32 parentGroup,
|
|||||||
Controls[index].flags = B_MULTI_MIX_MUX;
|
Controls[index].flags = B_MULTI_MIX_MUX;
|
||||||
Controls[index].parent = parentGroup;
|
Controls[index].parent = parentGroup;
|
||||||
Controls[index].string = S_null;
|
Controls[index].string = S_null;
|
||||||
strncpy(Controls[index].name, "Source", sizeof(Controls[index].name));
|
strlcpy(Controls[index].name, "Source", sizeof(Controls[index].name));
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
for (int i = 0; i < selector->fInputPins.Count(); i++) {
|
for (int i = 0; i < selector->fInputPins.Count(); i++) {
|
||||||
@@ -1476,7 +1476,7 @@ AudioControlInterface::_ListSelectorUnitControl(int32& index, int32 parentGroup,
|
|||||||
Controls[index].parent = recordMUX;
|
Controls[index].parent = recordMUX;
|
||||||
_AudioControl* control = Find(selector->fInputPins[i]);
|
_AudioControl* control = Find(selector->fInputPins[i]);
|
||||||
if (control != NULL) {
|
if (control != NULL) {
|
||||||
strncpy(Controls[index].name,
|
strlcpy(Controls[index].name,
|
||||||
control->Name(), sizeof(Controls[index].name));
|
control->Name(), sizeof(Controls[index].name));
|
||||||
} else {
|
} else {
|
||||||
snprintf(Controls[index].name,
|
snprintf(Controls[index].name,
|
||||||
@@ -1498,7 +1498,7 @@ AudioControlInterface::_ListMixControlsPage(int32& index,
|
|||||||
= Controls[index].id = index | 0x10000;
|
= Controls[index].id = index | 0x10000;
|
||||||
Controls[index].flags = B_MULTI_MIX_GROUP;
|
Controls[index].flags = B_MULTI_MIX_GROUP;
|
||||||
Controls[index].parent = 0;
|
Controls[index].parent = 0;
|
||||||
strncpy(Controls[index].name, Name, sizeof(Controls[index].name));
|
strlcpy(Controls[index].name, Name, sizeof(Controls[index].name));
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
int32 group = groupIndex;
|
int32 group = groupIndex;
|
||||||
|
|||||||
@@ -361,10 +361,10 @@ Device::_MultiGetDescription(multi_description *multiDescription)
|
|||||||
Description.interface_version = B_CURRENT_INTERFACE_VERSION;
|
Description.interface_version = B_CURRENT_INTERFACE_VERSION;
|
||||||
Description.interface_minimum = B_CURRENT_INTERFACE_VERSION;
|
Description.interface_minimum = B_CURRENT_INTERFACE_VERSION;
|
||||||
|
|
||||||
strncpy(Description.friendly_name, "USB Audio", // TODO: ????
|
strlcpy(Description.friendly_name, "USB Audio", // TODO: ????
|
||||||
sizeof(Description.friendly_name));
|
sizeof(Description.friendly_name));
|
||||||
|
|
||||||
strncpy(Description.vendor_info, "S.Zharski",
|
strlcpy(Description.vendor_info, "S.Zharski",
|
||||||
sizeof(Description.vendor_info));
|
sizeof(Description.vendor_info));
|
||||||
|
|
||||||
Description.output_channel_count = 0;
|
Description.output_channel_count = 0;
|
||||||
|
|||||||
@@ -26,7 +26,9 @@ void create_log()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
int flags = O_WRONLY | O_CREAT | ((gTruncateLogFile) ? O_TRUNC : 0);
|
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");
|
mutex_init(&gLogLock, DRIVER_NAME"-logging");
|
||||||
}
|
}
|
||||||
@@ -77,7 +79,7 @@ void usb_audio_trace(bool force, const char* func, const char *fmt, ...)
|
|||||||
static char buffer[1024];
|
static char buffer[1024];
|
||||||
char *buf_ptr = buffer;
|
char *buf_ptr = buffer;
|
||||||
if (gLogFilePath == NULL) {
|
if (gLogFilePath == NULL) {
|
||||||
strcpy(buffer, prefix);
|
strlcpy(buffer, prefix, sizeof(buffer));
|
||||||
buf_ptr += strlen(prefix);
|
buf_ptr += strlen(prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,8 +108,10 @@ void usb_audio_trace(bool force, const char* func, const char *fmt, ...)
|
|||||||
|
|
||||||
mutex_lock(&gLogLock);
|
mutex_lock(&gLogLock);
|
||||||
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
int fd = open(gLogFilePath, O_WRONLY | O_APPEND);
|
||||||
write(fd, buffer, strlen(buffer));
|
if (fd >= 0) {
|
||||||
close(fd);
|
write(fd, buffer, strlen(buffer));
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
mutex_unlock(&gLogLock);
|
mutex_unlock(&gLogLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user