Skip to content

Commit 188115c

Browse files
committed
Deference the pointer to take effect
1 parent fc5b8ac commit 188115c

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

virtio-snd.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -729,13 +729,13 @@ static void __virtio_snd_frame_enqueue(void *payload,
729729
{
730730
uint32_t prod_head, cons_tail;
731731
uint32_t prod_next, free_entries;
732-
virtio_snd_prop_t props =
733-
vsnd_props[stream_id]; /* XXX: access the address for the ease of data
732+
virtio_snd_prop_t *props =
733+
&vsnd_props[stream_id]; /* XXX: access the address for the ease of data
734734
manipulation */
735-
uint32_t mask = props.pp.buffer_bytes;
735+
uint32_t mask = props->pp.buffer_bytes;
736736

737-
prod_head = props.ring.prod.head;
738-
cons_tail = props.ring.cons.tail;
737+
prod_head = props->ring.prod.head;
738+
cons_tail = props->ring.cons.tail;
739739
/* The subtraction is done between two unsigned 32bits value
740740
* (the result is always modulo 32 bits even if we have
741741
* prod_head > cons_tail). So 'free_entries' is always between 0
@@ -746,22 +746,21 @@ static void __virtio_snd_frame_enqueue(void *payload,
746746
if (n > free_entries)
747747
fprintf(stderr, "payload length larger than free_entries\n");
748748
prod_next = prod_head + n;
749-
props.ring.prod.head = prod_next;
749+
props->ring.prod.head = prod_next;
750750

751751
/* Write payload to ring buffer. */
752-
uint32_t size = props.pp.buffer_bytes;
752+
uint32_t size = props->pp.buffer_bytes;
753753
uint32_t idx = prod_head & mask;
754-
uint32_t i;
755754
if (idx + n < size) {
756-
memcpy(props.ring.buffer + idx, payload, n);
755+
memcpy(props->ring.buffer + idx, payload, n);
757756
} else {
758-
memcpy(props.ring.buffer + idx, payload, size - idx);
759-
memcpy(props.ring.buffer, payload, n - (size - idx));
757+
memcpy(props->ring.buffer + idx, payload, size - idx);
758+
memcpy(props->ring.buffer, payload, n - (size - idx));
760759
}
761760
asm("" ::: "memory");
762761

763762
/* Update prod_tail */
764-
props.ring.prod.tail = prod_next;
763+
props->ring.prod.tail = prod_next;
765764
}
766765

767766
typedef struct {

0 commit comments

Comments
 (0)