echo driver: replace strncpy by strlcpy

using strncpy could possibly lead to a non null terminated string.
also some coding style fix.

CID 2216.
This commit is contained in:
Philippe Saint-Pierre
2012-01-01 19:42:16 -05:00
parent 12892428fc
commit e480c1b658
+10 -4
View File
@@ -110,6 +110,7 @@ echo_mem_new(echo_dev *card, size_t size)
return mem;
}
void
echo_mem_delete(echo_mem *mem)
{
@@ -118,6 +119,7 @@ echo_mem_delete(echo_mem *mem)
free(mem);
}
echo_mem *
echo_mem_alloc(echo_dev *card, size_t size)
{
@@ -132,6 +134,7 @@ echo_mem_alloc(echo_dev *card, size_t size)
return mem;
}
void
echo_mem_free(echo_dev *card, void *ptr)
{
@@ -248,7 +251,8 @@ echo_stream_set_audioparms(echo_stream *stream, uint8 channels,
sample_size = stream->bitsPerSample / 8;
frame_size = sample_size * stream->channels;
stream->buffer = echo_mem_alloc(stream->card, stream->bufframes * frame_size * stream->bufcount);
stream->buffer = echo_mem_alloc(stream->card,
stream->bufframes * frame_size * stream->bufcount);
stream->trigblk = 1;
stream->blkmod = stream->bufcount;
@@ -322,6 +326,7 @@ echo_stream_start(echo_stream *stream, void (*inth) (void *), void *inthparam)
}
}
void
echo_stream_halt(echo_stream *stream)
{
@@ -336,6 +341,7 @@ echo_stream_halt(echo_stream *stream)
}
}
echo_stream *
echo_stream_new(echo_dev *card, uint8 use, uint32 bufframes, uint8 bufcount)
{
@@ -375,6 +381,7 @@ echo_stream_new(echo_dev *card, uint8 use, uint32 bufframes, uint8 bufcount)
return stream;
}
void
echo_stream_delete(echo_stream *stream)
{
@@ -626,8 +633,7 @@ init_driver(void)
#ifndef CARDBUS
static void
make_device_names(
echo_dev * card)
make_device_names(echo_dev * card)
{
#ifdef MIDI_SUPPORT
sprintf(card->midi.name, "midi/"DRIVER_NAME"/%ld", card-cards + 1);
@@ -851,7 +857,7 @@ echo_setup(echo_dev * card)
#ifdef ECHO3G_FAMILY
if (card->type == ECHO3G) {
strncpy(card->caps.szName, ((C3g*)card->pEG)->Get3gBoxName(),
strlcpy(card->caps.szName, ((C3g*)card->pEG)->Get3gBoxName(),
ECHO_MAXNAMELEN);
}
#endif