From 03033cc7196b2663d9953055d1a432fc7b6433dc Mon Sep 17 00:00:00 2001 From: Scott Vokes Date: Mon, 14 Oct 2024 11:12:32 -0400 Subject: [PATCH] cdata: Address warning, ensure closing `}` is always output. Previously `AMBIG_NONE` was missing the closing curly brace but the other variants added it. All three need it, so it's cleaner to move it outside the switch case. Also, make AMBIG_NONE output `(void)endid_base;`, because otherwise it leads to a warning about the unused variable. (It's probably not worth complicating the output template further to avoid using it in the first place here.) --- src/libfsm/print/cdata.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/libfsm/print/cdata.c b/src/libfsm/print/cdata.c index b8ec31234..16c59d6cd 100644 --- a/src/libfsm/print/cdata.c +++ b/src/libfsm/print/cdata.c @@ -604,21 +604,21 @@ generate_interpreter(FILE *f, const struct cdata_config *config, const struct fs switch (opt->ambig) { case AMBIG_NONE: + fprintf(f, + "\t\t(void)endid_base;\n"); break; case AMBIG_ERROR: case AMBIG_EARLIEST: fprintf(f, "\t\t*id = *endid_base;\n" - "\t\t(void)endid_count;\n" - "\t}\n"); + "\t\t(void)endid_count;\n"); break; case AMBIG_MULTIPLE: fprintf(f, "\t\t*%s = endid_base;\n" - "\t\t*%s = endid_count;\n" - "\t}\n", + "\t\t*%s = endid_count;\n", /* TODO: rename these to endid_ids and endid_count? * That will be an interface change. */ "ids", "count"); @@ -628,6 +628,9 @@ generate_interpreter(FILE *f, const struct cdata_config *config, const struct fs assert(!"unreached"); abort(); } + + fprintf(f, + "\t}\n"); } /* If the end state has eager_outputs, set their flags. */