From 8837ed6d19b3921c41a20413b20f4e52fdf7b183 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Mon, 21 Jul 2025 03:45:48 -0400 Subject: oasm: emit: Don't use TAILQ_FOREACH for processing In order to have more control over the flow at which we grab the next tokens, we should roll our own loop by hand using TAILQ_FIRST() and TAILQ_NEXT() Signed-off-by: Ian Moffett --- usr.bin/oasm/emit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'usr.bin') diff --git a/usr.bin/oasm/emit.c b/usr.bin/oasm/emit.c index 0275d05..e3ee366 100644 --- a/usr.bin/oasm/emit.c +++ b/usr.bin/oasm/emit.c @@ -190,16 +190,17 @@ emit_process(struct oasm_state *oasm, struct emit_state *emit) } emit->out_fd = oasm->out_fd; - TAILQ_FOREACH(curtok, &emit->ir, link) { + curtok = TAILQ_FIRST(&emit->ir); + while (curtok != NULL) { switch (curtok->type) { case TT_MOV: curtok = emit_encode_mov(emit, curtok); break; - } - - if (curtok == NULL) { + default: + curtok = TAILQ_NEXT(curtok, link); break; } + } return 0; -- cgit v1.2.3