=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/sndiod/midi.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- src/usr.bin/sndiod/midi.c 2021/01/28 11:17:58 1.27 +++ src/usr.bin/sndiod/midi.c 2021/03/08 09:42:50 1.28 @@ -1,4 +1,4 @@ -/* $OpenBSD: midi.c,v 1.27 2021/01/28 11:17:58 ratchov Exp $ */ +/* $OpenBSD: midi.c,v 1.28 2021/03/08 09:42:50 ratchov Exp $ */ /* * Copyright (c) 2008-2012 Alexandre Ratchov * @@ -482,7 +482,7 @@ struct port * port_new(char *path, unsigned int mode, int hold) { - struct port *c; + struct port *c, **pc; c = xmalloc(sizeof(struct port)); c->path_list = NULL; @@ -491,8 +491,10 @@ c->hold = hold; c->midi = midi_new(&port_midiops, c, mode); c->num = midi_portnum++; - c->next = port_list; - port_list = c; + for (pc = &port_list; *pc != NULL; pc = &(*pc)->next) + ; + c->next = *pc; + *pc = c; return c; }