Skip to content

Commit 3b73112

Browse files
qarkaicaclark
authored andcommitted
Use maybe_unused attribute
1 parent 6cdf284 commit 3b73112

File tree

6 files changed

+11
-21
lines changed

6 files changed

+11
-21
lines changed

src/color-man-heif.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ guchar *nclx_to_lcms_profile(const heif_color_profile_nclx *nclx, guint &profile
120120
{
121121
if (!nclx || nclx->color_primaries == heif_color_primaries_unspecified) return nullptr;
122122

123-
const gchar *primaries_name = "";
123+
[[maybe_unused]] const gchar *primaries_name = "";
124124
switch (nclx->color_primaries)
125125
{
126126
case heif_color_primaries_ITU_R_BT_709_5:
@@ -161,7 +161,6 @@ guchar *nclx_to_lcms_profile(const heif_color_profile_nclx *nclx, guint &profile
161161
return nullptr;
162162
}
163163

164-
(void)primaries_name; // @todo Use [[maybe_unused]] since C++17
165164
DEBUG_1("nclx primaries: %s: ", primaries_name);
166165

167166
using GetCurve = std::function<cmsToneCurve *()>;
@@ -192,7 +191,7 @@ guchar *nclx_to_lcms_profile(const heif_color_profile_nclx *nclx, guint &profile
192191
};
193192

194193
g_auto(cmsHPROFILE) profile = nullptr;
195-
const gchar *trc_name = "";
194+
[[maybe_unused]] const gchar *trc_name = "";
196195
switch (nclx->transfer_characteristics)
197196
{
198197
case heif_transfer_characteristic_ITU_R_BT_709_5:
@@ -238,7 +237,6 @@ guchar *nclx_to_lcms_profile(const heif_color_profile_nclx *nclx, guint &profile
238237
break;
239238
}
240239

241-
(void)trc_name; // @todo Use [[maybe_unused]] since C++17
242240
DEBUG_1("nclx transfer characteristic: %s", trc_name);
243241

244242
if (!profile) return nullptr;

src/command-line-handling.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -871,9 +871,10 @@ void gq_log_file(GtkApplication *, GApplicationCommandLine *, GVariantDict *comm
871871
command_line->log_file = path_from_utf8(text);
872872
}
873873

874-
#if HAVE_LUA // @todo Use [[maybe_unused]] for command_line_options_dict since C++17 and merge declarations
875-
void gq_lua(GtkApplication *, GApplicationCommandLine *app_command_line, GVariantDict *command_line_options_dict, GList *)
874+
void gq_lua(GtkApplication *, GApplicationCommandLine *app_command_line,
875+
[[maybe_unused]] GVariantDict *command_line_options_dict, GList *)
876876
{
877+
#if HAVE_LUA
877878
const gchar *text;
878879
g_variant_dict_lookup(command_line_options_dict, "lua", "&s", &text);
879880

@@ -895,13 +896,10 @@ void gq_lua(GtkApplication *, GApplicationCommandLine *app_command_line, GVarian
895896
{
896897
g_application_command_line_print(app_command_line, _("lua error: no data\n"));
897898
}
898-
}
899899
#else
900-
void gq_lua(GtkApplication *, GApplicationCommandLine *app_command_line, GVariantDict *, GList *)
901-
{
902900
g_application_command_line_print(app_command_line, _("Lua is not available\n"));
903-
}
904901
#endif
902+
}
905903

906904
void gq_new_window(GtkApplication *, GApplicationCommandLine *app_command_line, GVariantDict *, GList *)
907905
{

src/jpeg-parser.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,8 @@ MPOData jpeg_get_mpo_data(const guchar *data, guint size)
304304
[size](MPOEntry &mpe){ return mpe.offset + mpe.length > size; });
305305
if (it != mpo.images.end())
306306
{
307-
const guint mpe_size = it->offset + it->length;
307+
[[maybe_unused]] const guint mpe_size = it->offset + it->length;
308308
mpo.images.erase(it, mpo.images.end());
309-
(void)mpe_size; // @todo Use [[maybe_unused]] since C++17
310309
DEBUG_1("MPO file truncated to %u valid images, %u %u", mpo.images.size(), mpe_size, size);
311310
}
312311

src/main.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,6 @@ void sig_handler_cb(int signo, siginfo_t *info, void *)
216216
gint i = 0;
217217
guint64 addr;
218218
guint64 char_index;
219-
ssize_t len;
220219
#if HAVE_EXECINFO_H
221220
gint bt_size;
222221
void *bt[1024];
@@ -271,6 +270,7 @@ void sig_handler_cb(int signo, siginfo_t *info, void *)
271270
i++;
272271
}
273272

273+
[[maybe_unused]] ssize_t len;
274274
len = write(STDERR_FILENO, "Geeqie fatal error\n", 19);
275275
len = write(STDERR_FILENO, "Signal: ", 8);
276276
len = write(STDERR_FILENO, signal_name, strlen(signal_name));
@@ -309,8 +309,6 @@ void sig_handler_cb(int signo, siginfo_t *info, void *)
309309
backtrace_symbols_fd(bt, bt_size, STDERR_FILENO);
310310
#endif
311311

312-
(void)len; // @todo Use [[maybe_unused]] since C++17
313-
314312
exit(EXIT_FAILURE);
315313
}
316314
#else /* defined(SA_SIGINFO) */
@@ -672,15 +670,14 @@ void exit_program_write_metadata_cb(gint success, const gchar *)
672670
#pragma GCC diagnostic push
673671
#pragma GCC diagnostic ignored "-Wunused-function"
674672
#if defined(SIGBUS) && defined(SA_SIGINFO)
675-
void sigbus_handler_cb_unused(int, siginfo_t *info, void *)
673+
void sigbus_handler_cb_unused(int, [[maybe_unused]] siginfo_t *info, void *)
676674
{
677675
/*
678676
* @FIXME Design and implement a POSIX-acceptable approach,
679677
* after first documenting the sitations where SIGBUS occurs.
680678
* See https://github.com/BestImageViewer/geeqie/issues/1052 for discussion
681679
*/
682680

683-
(void)info; // @todo Use [[maybe_unused]] since C++17
684681
DEBUG_1("SIGBUS %p NOT HANDLED", info->si_addr);
685682
exit(EXIT_FAILURE);
686683
}

src/rcfile.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,12 +1799,11 @@ static void start_element(GMarkupParseContext *,
17991799
}
18001800

18011801
static void end_element(GMarkupParseContext *,
1802-
const gchar *element_name,
1802+
[[maybe_unused]] const gchar *element_name,
18031803
gpointer user_data,
18041804
GError **)
18051805
{
18061806
auto parser_data = static_cast<GQParserData *>(user_data);
1807-
(void)element_name; // @todo Use [[maybe_unused]] since C++17
18081807
DEBUG_2("end %s", element_name);
18091808

18101809
parser_data->end_func();

src/ui-fileops.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,7 @@ gboolean copy_file_attributes(const gchar *s, const gchar *t, gint perms, gint m
381381
{
382382
/* Ignores chown errors, while still doing chown
383383
(so root still can copy files preserving ownership) */
384-
int err = chown(tl, st.st_uid, st.st_gid);
385-
(void)err; // @todo Use [[maybe_unused]] since C++17
384+
[[maybe_unused]] int err = chown(tl, st.st_uid, st.st_gid);
386385

387386
if (chmod(tl, st.st_mode) < 0)
388387
{

0 commit comments

Comments
 (0)