Skip to contentSkip to conversation

Fix snd_seq_queue_find_name()

PATCH New Ben Collins 1 participant 1 message May 25, 2003

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix snd_seq_queue_find_name()

While going through sound/ for strncpy replacing, I came across this routine:

/* return the (first) queue matching with the specified name */ queue_t *snd_seq_queue_find_name(char *name)

{
        int i;
        queue_t *q;

        for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) {
                if ((q = queueptr(i)) != NULL) {
                        if (strncpy(q->name, name, sizeof(q->name)) == 0)
                                return q;
                        queuefree(q);
                }
        }
        return NULL;
}

I'm _really_ sure that they meant to use strncmp() here instead. Patch below fixes it.

core/seq/seq_queue.c +1 -1
Index: sound/core/seq/seq_queue.c
===================================================================
@@ -241,7 +241,7 @@
 
 	for (i = 0; i < SNDRV_SEQ_MAX_QUEUES; i++) {
 		if ((q = queueptr(i)) != NULL) {
-			if (strncpy(q->name, name, sizeof(q->name)) == 0)
+			if (strncmp(q->name, name, sizeof(q->name)) == 0)
 				return q;
 			queuefree(q);
 		}