Skip to content

Commit

Permalink
Added pragmas to shut up spurious warnings with the clang 3.4.1 compi…
Browse files Browse the repository at this point in the history
…ler.
  • Loading branch information
rmanfredi committed Jan 10, 2016
1 parent 2afec27 commit 3d47182
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/if/gnet_property.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@

#include "lib/override.h" /* Must be the last header included */

/*
* Some of the generated const variables can be unused, avoid warnings.
*
* The -Wunused-const-variable warning may not be available with a particular
* compiler, so the -Wpragmas that is issued before prevents a warning to be
* emitted in that case...
*/
G_IGNORE(-Wunknown-pragmas); /* clang does not know -Wpragmas */
G_IGNORE(-Wpragmas); /* For gcc, not clang */
G_IGNORE(-Wunused-const-variable); /* Appears in clang version 3.4.1 */

gboolean gnet_property_variable_reading_hostfile = FALSE;
static const gboolean gnet_property_variable_reading_hostfile_default = FALSE;
Expand Down
10 changes: 10 additions & 0 deletions src/if/gui_property.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@

#include "lib/override.h" /* Must be the last header included */

/*
* Some of the generated const variables can be unused, avoid warnings.
*
* The -Wunused-const-variable warning may not be available with a particular
* compiler, so the -Wpragmas that is issued before prevents a warning to be
* emitted in that case...
*/
G_IGNORE(-Wunknown-pragmas); /* clang does not know -Wpragmas */
G_IGNORE(-Wpragmas); /* For gcc, not clang */
G_IGNORE(-Wunused-const-variable); /* Appears in clang version 3.4.1 */

gboolean gui_property_variable_monitor_enabled = FALSE;
static const gboolean gui_property_variable_monitor_enabled_default = FALSE;
Expand Down
18 changes: 14 additions & 4 deletions src/if/props.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@ void [=(. func-prefix)=]_shutdown(void);
[= ENDFOR uses =]
#include "lib/override.h" /* Must be the last header included */

/*
* Some of the generated const variables can be unused, avoid warnings.
*
* The -Wunused-const-variable warning may not be available with a particular
* compiler, so the -Wpragmas that is issued before prevents a warning to be
* emitted in that case...
*/
G_IGNORE(-Wunknown-pragmas); /* clang does not know -Wpragmas */
G_IGNORE(-Wpragmas); /* For gcc, not clang */
G_IGNORE(-Wunused-const-variable); /* Appears in clang version 3.4.1 */
[=
FOR prop =][=
(define item (sprintf "%s_variable_%s"
Expand Down Expand Up @@ -375,7 +385,7 @@ static const [= (. vtype)=][=(. item)=]_default[[=vector_size=]] = [=(. vdef)=]
static const [= (. vtype)=][=(. item)=]_default = [=(. vdef)=];[=
ENDIF=][=
IF (= (get "type") "multichoice")=]
prop_def_choice_t [=(. item)=]_choices[] = { [=
prop_def_choice_t [=(. item)=]_choices[] = {[=
FOR choice =]
{N_("[=name=]"), [=value=]},[=
ENDFOR choice =]
Expand All @@ -387,7 +397,7 @@ ENDFOR prop =]

static prop_set_t *[=(. prop-set)=];

G_GNUC_COLD prop_set_t *
prop_set_t * G_COLD
[=(. func-prefix)=]_init(void) {
guint32 n;
Expand Down Expand Up @@ -566,7 +576,7 @@ ENDFOR prop=]
/**
* Free memory allocated by the property set.
*/
G_GNUC_COLD void
void G_COLD
[=(. func-prefix)=]_shutdown(void) {
guint32 n;
Expand Down Expand Up @@ -805,7 +815,7 @@ pslist_t *
void
[=(. func-prefix)=]_set_from_string(property_t prop, const char *val)
{
prop_set_from_string([=(. prop-set)=], prop, val, FALSE);
prop_set_from_string([=(. prop-set)=], prop, val, FALSE);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/lib/crash.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void crash_setver(const char *version);
void crash_setnumbers(uint8 major, uint8 minor, uint8 patchlevel);
void crash_setbuild(unsigned build);
void crash_setmain(void);
void crash_oom(const char *format, ...) G_NORETURN;
void crash_oom(const char *format, ...) G_NORETURN G_PRINTF(1, 2);
void crash_oom_condition(void);
void crash_deadlocked(const char *file, unsigned line);
void crash_assert_failure(const struct assertion_data *a);
Expand All @@ -246,7 +246,7 @@ int crash_coredumps_disabled(void);
void crash_hook_add(const char *filename, const callback_fn_t hook);
void crash_set_restart(action_fn_t cb);
void crash_reexec(void) G_NORETURN;
void crash_restart(const char *format, ...);
void crash_restart(const char *format, ...) G_PRINTF(1, 2);
void crash_restarting(void);
void crash_print_decorated_stack(int fd);
void crash_divert_main(const char *caller, process_fn_t cb, void *arg);
Expand Down
4 changes: 4 additions & 0 deletions src/lib/glog.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ gl_logv(const char *domain, GLogLevelFlags flags, const char *fmt, va_list args)
static bool logging[THREAD_MAX];
unsigned stid = thread_small_id();

G_IGNORE_PUSH(-Wformat-nonliteral); /* s_minilogv() call below */

if (logging[stid]) {
s_minilogv(flags | G_LOG_FLAG_RECURSION, FALSE, fmt, args);
return;
}

G_IGNORE_POP;

/*
* This call is thread-unsafe by construction, and supposed to be called
* only from the main thread. This is why it's OK to have a global
Expand Down
6 changes: 3 additions & 3 deletions src/lib/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,7 @@ s_stacktrace(bool no_stdio, unsigned offset)
* @param format formatting string
* @param args variable argument list to format
*/
static void
static void G_PRINTF(3, 0)
s_logv(logthread_t *lt, GLogLevelFlags level, const char *format, va_list args)
{
int saved_errno = errno;
Expand Down Expand Up @@ -1361,7 +1361,7 @@ log_check_recursive(const char *format, va_list ap)
* @param format formatting string
* @param args variable argument list to format
*/
static void
static void G_PRINTF(5, 0)
s_logv_once_per(long period, const char *origin,
logthread_t *lt, GLogLevelFlags level, const char *format, va_list args)
{
Expand Down Expand Up @@ -2063,7 +2063,7 @@ log_str_logv(struct logstring *s,
* @param format formatting string
* @param args variable argument list to format
*/
static void
static void G_PRINTF(3, 0)
log_logv(logagent_t *la, GLogLevelFlags level, const char *format, va_list args)
{
logagent_check(la);
Expand Down

0 comments on commit 3d47182

Please sign in to comment.