Skip to content

Commit

Permalink
cdata: Address warning, ensure closing } is always output.
Browse files Browse the repository at this point in the history
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.)
  • Loading branch information
silentbicycle committed Oct 14, 2024
1 parent f2ac082 commit 03033cc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/libfsm/print/cdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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. */
Expand Down

0 comments on commit 03033cc

Please sign in to comment.