From 077c764e9c1197a6b323cedc1d0cd083419117af Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 10 Jun 2023 03:56:10 +0300 Subject: [PATCH 47/47] Add macros to mark secfile entries ignored These macros (secfile_entry_ignore() and secfile_entry_ignore_by_path() ) silence "unused entry" warnings from secfile loading. They wrap secfile_entry_lookup() and secfile_entry_by_path() calls traditionally used for the task, but names of these new macros should indicate more clearly why the entry lookup is done, and also makes it possible to search for these specific cases. Some cases in tilespec code have been converted to use the new macros as an example, but mostly this patch just provides the macros. They are not taken to use everywhere yet. See osdn #48208 Signed-off-by: Marko Lindqvist --- client/tilespec.c | 8 ++++---- utility/registry_ini.h | 7 +++++++ 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/client/tilespec.c b/client/tilespec.c index 6954332f57..9ac17ccc88 100644 --- a/client/tilespec.c +++ b/client/tilespec.c @@ -1629,10 +1629,10 @@ static void scan_specfile(struct tileset *t, struct specfile *sf, } /* Currently unused */ - (void) secfile_entry_lookup(file, "info.artists"); + secfile_entry_ignore(file, "info.artists"); /* Not used here */ - (void) secfile_entry_lookup(file, "file.gfx"); + secfile_entry_ignore(file, "file.gfx"); if ((sections = secfile_sections_by_name_prefix(file, "grid_"))) { section_list_iterate(sections, psection) { @@ -2544,13 +2544,13 @@ static struct tileset *tileset_read_toplevel(const char *tileset_name, type_name = "svg"; /* Avoid "unused entry" warning about the other list */ - (void) secfile_entry_by_path(file, "tilespec.files_pixel"); + secfile_entry_ignore_by_path(file, "tilespec.files_pixel"); } else { slist_type = SFILE_PIXEL; type_name = "pixel"; /* Avoid "unused entry" warning about the other list */ - (void) secfile_entry_by_path(file, "tilespec.files_svg"); + secfile_entry_ignore_by_path(file, "tilespec.files_svg"); } spec_filenames[slist_type] = secfile_lookup_str_vec(file, diff --git a/utility/registry_ini.h b/utility/registry_ini.h index e98729c0f3..400ce4fcc7 100644 --- a/utility/registry_ini.h +++ b/utility/registry_ini.h @@ -409,6 +409,13 @@ struct entry *secfile_entry_lookup(const struct section_file *secfile, const char *path, ...) fc__attribute((__format__ (__printf__, 2, 3))); +/* Macros to silence "unused entry" warnings about entries that + * we intentionally ignore. */ +#define secfile_entry_ignore(_sfile_, _fmt_, ...) \ + (void) secfile_entry_lookup(_sfile_, _fmt_, ## __VA_ARGS__) +#define secfile_entry_ignore_by_path(_sfile_, _path_) \ + (void) secfile_entry_by_path(_sfile_, _path_) + bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path, ...) fc__warn_unused_result -- 2.39.2