cleanup: use auto_FILE and handle fopen failure in command_docgen

This commit is contained in:
Michael Vetter
2026-02-26 21:44:09 +01:00
parent 156b78adfa
commit ba5614fb0e

View File

@@ -2976,8 +2976,14 @@ command_docgen(void)
cmds = g_list_insert_sorted(cmds, (gpointer)pcmd, (GCompareFunc)_cmp_command);
}
FILE* toc_fragment = fopen("toc_fragment.html", "w");
FILE* main_fragment = fopen("main_fragment.html", "w");
auto_FILE FILE* toc_fragment = fopen("toc_fragment.html", "w");
auto_FILE FILE* main_fragment = fopen("main_fragment.html", "w");
if (!toc_fragment || !main_fragment) {
printf("\nError opening html files: %s.\n", strerror(errno));
g_list_free(cmds);
return;
}
fputs("<ul><li><ul><li>\n", toc_fragment);
fputs("<hr>\n", main_fragment);
@@ -3045,8 +3051,6 @@ command_docgen(void)
fputs("</ul></ul>\n", toc_fragment);
fclose(toc_fragment);
fclose(main_fragment);
printf("\nProcessed %d commands.\n\n", g_list_length(cmds));
g_list_free(cmds);
}