From c1c5e9546cf2881f89d4a479eccb3fa1f5ae5d1a Mon Sep 17 00:00:00 2001 From: Jens Georg Date: Sun, 14 Jun 2015 00:15:30 +0200 Subject: Remove gnome-common Signed-off-by: Jens Georg --- configure.ac | 23 ++---- libgssdp/Makefile.am | 9 ++- libgssdp/gssdp-client.c | 2 +- libgssdp/gssdp-resource-browser.c | 5 +- libgssdp/gssdp-socket-functions.c | 2 +- m4/ax_append_compile_flags.m4 | 65 ++++++++++++++++ m4/ax_append_flag.m4 | 71 +++++++++++++++++ m4/ax_check_compile_flag.m4 | 74 ++++++++++++++++++ m4/ax_check_enable_debug.m4 | 113 +++++++++++++++++++++++++++ m4/ax_compiler_flags.m4 | 158 ++++++++++++++++++++++++++++++++++++++ m4/ax_compiler_flags_cflags.m4 | 133 ++++++++++++++++++++++++++++++++ m4/ax_compiler_flags_gir.m4 | 60 +++++++++++++++ m4/ax_compiler_flags_ldflags.m4 | 75 ++++++++++++++++++ m4/ax_is_release.m4 | 69 +++++++++++++++++ m4/ax_require_defined.m4 | 37 +++++++++ tests/Makefile.am | 6 +- tests/test-functional.c | 6 +- tests/test-regression.c | 10 +-- tests/test-util.c | 4 +- tools/Makefile.am | 4 +- tools/gssdp-device-sniffer.c | 44 ++++++++--- 21 files changed, 921 insertions(+), 49 deletions(-) create mode 100644 m4/ax_append_compile_flags.m4 create mode 100644 m4/ax_append_flag.m4 create mode 100644 m4/ax_check_compile_flag.m4 create mode 100644 m4/ax_check_enable_debug.m4 create mode 100644 m4/ax_compiler_flags.m4 create mode 100644 m4/ax_compiler_flags_cflags.m4 create mode 100644 m4/ax_compiler_flags_gir.m4 create mode 100644 m4/ax_compiler_flags_ldflags.m4 create mode 100644 m4/ax_is_release.m4 create mode 100644 m4/ax_require_defined.m4 diff --git a/configure.ac b/configure.ac index 4c08d4c..26b171f 100644 --- a/configure.ac +++ b/configure.ac @@ -16,14 +16,19 @@ AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([1.11 tar-ustar no-dist-gzip dist-xz]) AM_MAINTAINER_MODE([enable]) -GNOME_COMPILE_WARNINGS - AM_SILENT_RULES([yes]) +AX_REQUIRE_DEFINED([GTK_DOC_CHECK]) +AX_REQUIRE_DEFINED([GOBJECT_INTROSPECTION_CHECK]) +AX_CHECK_ENABLE_DEBUG([yes]) + AC_SEARCH_LIBS([strerror],[cposix]) AC_PROG_CC AC_HEADER_STDC +AX_IS_RELEASE([git-directory]) +AX_COMPILER_FLAGS([WARN_CFLAGS]) + LT_PREREQ([2.2]) LT_INIT @@ -69,20 +74,6 @@ AM_CONDITIONAL(USE_LIBGTK, test x$USE_LIBGTK = xyes) GLIB_GENMARSHAL=`pkg-config --variable=glib_genmarshal glib-2.0` AC_SUBST(GLIB_GENMARSHAL) -# Debugging -AC_ARG_ENABLE(debug, - [ --enable-debug enable debugging],, - enable_debug=no) -if test "x$enable_debug" = "xyes"; then - CFLAGS="$CFLAGS -g -Wall" -fi - -AC_ARG_ENABLE([strict-c], - AS_HELP_STRING([--enable-strict-c],[Error out on warnings]),, - [enable_strict_c=no]) -AS_IF([test "x$[]enable_strict_c" = "xyes"], - [CFLAGS="$CFLAGS -Werror"]) - GOBJECT_INTROSPECTION_CHECK([0.6.7]) # vapigen diff --git a/libgssdp/Makefile.am b/libgssdp/Makefile.am index 63283a4..7674d42 100644 --- a/libgssdp/Makefile.am +++ b/libgssdp/Makefile.am @@ -10,7 +10,7 @@ LTVERSION = 3:0:0 -AM_CFLAGS = $(LIBGSSDP_CFLAGS) -I$(top_srcdir) +AM_CFLAGS = $(LIBGSSDP_CFLAGS) -I$(top_srcdir) $(WARN_CFLAGS) libgssdpincdir = $(includedir)/gssdp-1.0/libgssdp @@ -38,7 +38,7 @@ introspection_sources = $(libgssdpinc_HEADERS) \ gssdp-resource-browser.c\ gssdp-resource-group.c -libgssdp_1_0_la_LDFLAGS = -version-info $(LTVERSION) +libgssdp_1_0_la_LDFLAGS = -version-info $(LTVERSION) $(WARN_LDFLAGS) libgssdp_1_0_la_SOURCES = $(introspection_sources) \ gssdp-client-private.h \ gssdp-protocol.h \ @@ -71,11 +71,12 @@ CLEANFILES = $(BUILT_SOURCES) -include $(INTROSPECTION_MAKEFILE) INTROSPECTION_GIRS = -INTROSPECTION_SCANNER_ARGS = --warn-all \ +INTROSPECTION_SCANNER_ARGS = \ --symbol-prefix=gssdp \ --identifier-prefix=GSSDP \ --add-include-path=$(top_srcdir) \ - --pkg-export=gssdp-1.0 + --pkg-export=gssdp-1.0 \ + $(WARN_SCANNERFLAGS) INTROSPECTION_COMPILER_ARGS = --includedir=$(top_srcdir) diff --git a/libgssdp/gssdp-client.c b/libgssdp/gssdp-client.c index 64987b4..ab25469 100644 --- a/libgssdp/gssdp-client.c +++ b/libgssdp/gssdp-client.c @@ -1511,7 +1511,7 @@ get_host_ip (GSSDPNetworkDevice *device) g_free (adapters_addresses); return TRUE; -#elif __BIONIC__ +#elif defined(__BIONIC__) struct ifreq *ifaces = NULL; struct ifreq *iface = NULL; struct ifreq tmp_iface; diff --git a/libgssdp/gssdp-resource-browser.c b/libgssdp/gssdp-resource-browser.c index 75ca9f9..c02a4a7 100644 --- a/libgssdp/gssdp-resource-browser.c +++ b/libgssdp/gssdp-resource-browser.c @@ -467,7 +467,7 @@ gssdp_resource_browser_set_target (GSSDPResourceBrowser *resource_browser, { char *pattern; char *version; - char *version_pattern; + const char *version_pattern; GError *error; g_return_if_fail (GSSDP_IS_RESOURCE_BROWSER (resource_browser)); @@ -1027,6 +1027,9 @@ message_received_cb (G_GNUC_UNUSED GSSDPClient *client, case _GSSDP_ANNOUNCEMENT: received_announcement (resource_browser, headers); break; + case _GSSDP_DISCOVERY_REQUEST: + /* Should not happend */ + break; default: break; } diff --git a/libgssdp/gssdp-socket-functions.c b/libgssdp/gssdp-socket-functions.c index ecbe5f9..0ba8c6d 100644 --- a/libgssdp/gssdp-socket-functions.c +++ b/libgssdp/gssdp-socket-functions.c @@ -50,7 +50,7 @@ gssdp_socket_error_message (int error) { } static int -gssdp_socket_errno () { +gssdp_socket_errno (void) { #ifdef G_OS_WIN32 return WSAGetLastError (); #else diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4 new file mode 100644 index 0000000..dc7b866 --- /dev/null +++ b/m4/ax_append_compile_flags.m4 @@ -0,0 +1,65 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# For every FLAG1, FLAG2 it is checked whether the compiler works with the +# flag. If it does, the flag is added FLAGS-VARIABLE +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. During the check the flag is always added to the +# current language's flags. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# NOTE: This macro depends on the AX_APPEND_FLAG and +# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with +# AX_APPEND_LINK_FLAGS. +# +# LICENSE +# +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 4 + +AC_DEFUN([AX_APPEND_COMPILE_FLAGS], +[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) +AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) +for flag in $1; do + AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3]) +done +])dnl AX_APPEND_COMPILE_FLAGS diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4 new file mode 100644 index 0000000..aeab899 --- /dev/null +++ b/m4/ax_append_flag.m4 @@ -0,0 +1,71 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE]) +# +# DESCRIPTION +# +# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space +# added in between. +# +# If FLAGS-VARIABLE is not specified, the current language's flags (e.g. +# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains +# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly +# FLAG. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 5 + +AC_DEFUN([AX_APPEND_FLAG], +[dnl +AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF +AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])]) +AS_VAR_SET_IF(FLAGS,[ + AS_CASE([" AS_VAR_GET(FLAGS) "], + [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])], + [ + AS_VAR_APPEND(FLAGS," $1") + AC_RUN_LOG([: FLAGS="$FLAGS"]) + ]) + ], + [ + AS_VAR_SET(FLAGS,[$1]) + AC_RUN_LOG([: FLAGS="$FLAGS"]) + ]) +AS_VAR_POPDEF([FLAGS])dnl +])dnl AX_APPEND_FLAG diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000..ca36397 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,74 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 4 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/m4/ax_check_enable_debug.m4 b/m4/ax_check_enable_debug.m4 new file mode 100644 index 0000000..37add91 --- /dev/null +++ b/m4/ax_check_enable_debug.m4 @@ -0,0 +1,113 @@ +# =========================================================================== +# http://autoconf-archive.cryp.to/ax_check_enable_debug.html +# =========================================================================== +# +# SYNOPSIS +# +# Check for the presence of an --enable-debug option to configure and +# allow/avoid compiled debugging flags appropriately. +# +# AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no], +# [ENABLE DEBUG VARIABLES …], +# [DISABLE DEBUG VARIABLES NDEBUG …]) +# +# DESCRIPTION +# +# Check for the presence of an --enable-debug option to configure, with the +# specified default value used when the option is not present. Return the +# value in the variable $ax_enable_debug. +# +# Specifying 'yes' adds '-g -O0' to the compilation flags for all languages. +# Specifying 'info' adds '-g' to the compilation flags. Specifying 'profile' +# adds '-g -pg' to the compilation flags and '-pg' to the linking flags. +# Otherwise, nothing is added. +# +# Define the variables listed in the second argument if debug is enabled, +# defaulting to no variables. Defines the variables listed in the third +# argument if debug is disabled, defaulting to NDEBUG. All lists of +# variables should be space-separated. +# +# If debug is not enabled, ensure AC_PROG_* will not add debugging flags. +# Should be invoked prior to any AC_PROG_* compiler checks. +# +# LAST MODIFICATION +# +# 2014-05-12 +# +# COPYLEFT +# +# Copyright (c) 2011 Rhys Ulerich +# Copyright © 2014 Philip Withnall +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. + +AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[ + AC_BEFORE([$0],[AC_PROG_CC])dnl + AC_BEFORE([$0],[AC_PROG_CXX])dnl + AC_BEFORE([$0],[AC_PROG_F77])dnl + AC_BEFORE([$0],[AC_PROG_FC])dnl + + AC_MSG_CHECKING(whether to enable debugging) + + m4_define(ax_enable_debug_default,[m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))]) + m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))]) + m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))]) + + AC_ARG_ENABLE(debug, + [AS_HELP_STRING([--enable-debug]@<:@=ax_enable_debug_default@:>@,[compile with debugging; one of yes/info/profile/no])], + [],enable_debug=ax_enable_debug_default) + if test "x$enable_debug" = "xyes" || test "x$enable_debug" = "x"; then + AC_MSG_RESULT(yes) + CFLAGS="${CFLAGS} -g -O0" + CXXFLAGS="${CXXFLAGS} -g -O0" + FFLAGS="${FFLAGS} -g -O0" + FCFLAGS="${FCFLAGS} -g -O0" + OBJCFLAGS="${OBJCFLAGS} -g -O0" + + dnl Define various variables if debugging is enabled. + m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])]) + else + if test "x$enable_debug" = "xinfo"; then + AC_MSG_RESULT(info) + CFLAGS="${CFLAGS} -g" + CXXFLAGS="${CXXFLAGS} -g" + FFLAGS="${FFLAGS} -g" + FCFLAGS="${FCFLAGS} -g" + OBJCFLAGS="${OBJCFLAGS} -g" + elif test "x$enable_debug" = "xprofile"; then + AC_MSG_RESULT(profile) + CFLAGS="${CFLAGS} -g -pg" + CXXFLAGS="${CXXFLAGS} -g -pg" + FFLAGS="${FFLAGS} -g -pg" + FCFLAGS="${FCFLAGS} -g -pg" + OBJCFLAGS="${OBJCFLAGS} -g -pg" + LDFLAGS="${LDFLAGS} -pg" + else + AC_MSG_RESULT(no) + dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags + dnl by setting any unset environment flag variables + if test "x${CFLAGS+set}" != "xset"; then + CFLAGS="" + fi + if test "x${CXXFLAGS+set}" != "xset"; then + CXXFLAGS="" + fi + if test "x${FFLAGS+set}" != "xset"; then + FFLAGS="" + fi + if test "x${FCFLAGS+set}" != "xset"; then + FCFLAGS="" + fi + if test "x${OBJCFLAGS+set}" != "xset"; then + OBJCFLAGS="" + fi + fi + + dnl Define various variables if debugging is disabled. + dnl assert.h is a NOP if NDEBUG is defined, so define it by default. + m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])]) + fi + ax_enable_debug=$enable_debug +]) diff --git a/m4/ax_compiler_flags.m4 b/m4/ax_compiler_flags.m4 new file mode 100644 index 0000000..6cfe398 --- /dev/null +++ b/m4/ax_compiler_flags.m4 @@ -0,0 +1,158 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPILER_FLAGS([CFLAGS-VARIABLE], [LDFLAGS-VARIABLE], [IS-RELEASE], [EXTRA-BASE-CFLAGS], [EXTRA-YES-CFLAGS], [UNUSED], [UNUSED], [UNUSED], [EXTRA-BASE-LDFLAGS], [EXTRA-YES-LDFLAGS], [UNUSED], [UNUSED], [UNUSED]) +# +# DESCRIPTION +# +# Check for the presence of an --enable-compile-warnings option to +# configure, defaulting to "error" in normal operation, or "yes" if +# IS-RELEASE is equal to "yes". Return the value in the variable +# $ax_enable_compile_warnings. +# +# Depending on the value of --enable-compile-warnings, different compiler +# warnings are checked to see if they work with the current compiler and, +# if so, are appended to CFLAGS-VARIABLE and LDFLAGS-VARIABLE. This +# allows a consistent set of baseline compiler warnings to be used across +# a code base, irrespective of any warnings enabled locally by individual +# developers. By standardising the warnings used by all developers of a +# project, the project can commit to a zero-warnings policy, using -Werror +# to prevent compilation if new warnings are introduced. This makes +# catching bugs which are flagged by warnings a lot easier. +# +# By providing a consistent --enable-compile-warnings argument across all +# projects using this macro, continuous integration systems can easily be +# configured the same for all projects. Automated systems or build +# systems aimed at beginners may want to pass the --disable-Werror +# argument to unconditionally prevent warnings being fatal. +# +# --enable-compile-warnings can take the values: +# +# * no: Base compiler warnings only; not even -Wall. +# * yes: The above, plus a broad range of useful warnings. +# * error: The above, plus -Werror so that all warnings are fatal. +# Use --disable-Werror to override this and disable fatal +# warnings. +# +# The set of base and enabled flags can be augmented using the +# EXTRA-*-CFLAGS and EXTRA-*-LDFLAGS variables, which are tested and +# appended to the output variable if --enable-compile-warnings is not +# "no". Flags should not be disabled using these arguments, as the entire +# point of AX_COMPILER_FLAGS is to enforce a consistent set of useful +# compiler warnings on code, using warnings which have been chosen for low +# false positive rates. If a compiler emits false positives for a +# warning, a #pragma should be used in the code to disable the warning +# locally. See: +# +# https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas +# +# The EXTRA-* variables should only be used to supply extra warning flags, +# and not general purpose compiler flags, as they are controlled by +# configure options such as --disable-Werror. +# +# IS-RELEASE can be used to disable -Werror when making a release, which +# is useful for those hairy moments when you just want to get the release +# done as quickly as possible. Set it to "yes" to disable -Werror. By +# default, it uses the value of $ax_is_release, so if you are using the +# AX_IS_RELEASE macro, there is no need to pass this parameter. For +# example: +# +# AX_IS_RELEASE([git-directory]) +# AX_COMPILER_FLAGS() +# +# CFLAGS-VARIABLE defaults to WARN_CFLAGS, and LDFLAGS-VARIABLE defaults +# to WARN_LDFLAGS. Both variables are AC_SUBST-ed by this macro, but must +# be manually added to the CFLAGS and LDFLAGS variables for each target in +# the code base. +# +# If C++ language support is enabled with AC_PROG_CXX, which must occur +# before this macro in configure.ac, warning flags for the C++ compiler +# are AC_SUBST-ed as WARN_CXXFLAGS, and must be manually added to the +# CXXFLAGS variables for each target in the code base. EXTRA-*-CFLAGS can +# be used to augment the base and enabled flags. +# +# Warning flags for g-ir-scanner (from GObject Introspection) are +# AC_SUBST-ed as WARN_SCANNERFLAGS. This variable must be manually added +# to the SCANNERFLAGS variable for each GIR target in the code base. If +# extra g-ir-scanner flags need to be enabled, the AX_COMPILER_FLAGS_GIR +# macro must be invoked manually. +# +# AX_COMPILER_FLAGS may add support for other tools in future, in addition +# to the compiler and linker. No extra EXTRA-* variables will be added +# for those tools, and all extra support will still use the single +# --enable-compile-warnings configure option. For finer grained control +# over the flags for individual tools, use AX_COMPILER_FLAGS_CFLAGS, +# AX_COMPILER_FLAGS_LDFLAGS and AX_COMPILER_FLAGS_* for new tools. +# +# The UNUSED variables date from a previous version of this macro, and are +# automatically appended to the preceding non-UNUSED variable. They should +# be left empty in new uses of the macro. +# +# LICENSE +# +# Copyright (c) 2014, 2015 Philip Withnall +# Copyright (c) 2015 David King +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 13 + +# _AX_COMPILER_FLAGS_LANG([LANGNAME]) +m4_defun([_AX_COMPILER_FLAGS_LANG], +[m4_ifdef([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [], + [m4_define([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [])dnl + AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_]$1[FLAGS])])dnl +]) + +AC_DEFUN([AX_COMPILER_FLAGS],[ + # C support is enabled by default. + _AX_COMPILER_FLAGS_LANG([C]) + # Only enable C++ support if AC_PROG_CXX is called. The redefinition of + # AC_PROG_CXX is so that a fatal error is emitted if this macro is called + # before AC_PROG_CXX, which would otherwise cause no C++ warnings to be + # checked. + AC_PROVIDE_IFELSE([AC_PROG_CXX], + [_AX_COMPILER_FLAGS_LANG([CXX])], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AX_COMPILER_FLAGS_LANG([CXX])])]) + AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_LDFLAGS]) + + # Default value for IS-RELEASE is $ax_is_release + ax_compiler_flags_is_release=m4_tolower(m4_normalize(ifelse([$3],, + [$ax_is_release], + [$3]))) + + AC_ARG_ENABLE([compile-warnings], + AS_HELP_STRING([--enable-compile-warnings=@<:@no/yes/error@:>@], + [Enable compiler warnings and errors]),, + [AS_IF([test "$ax_compiler_flags_is_release" = "yes"], + [enable_compile_warnings="yes"], + [enable_compile_warnings="error"])]) + AC_ARG_ENABLE([Werror], + AS_HELP_STRING([--disable-Werror], + [Unconditionally make all compiler warnings non-fatal]),, + [enable_Werror=maybe]) + + # Return the user's chosen warning level + AS_IF([test "$enable_Werror" = "no" -a \ + "$enable_compile_warnings" = "error"],[ + enable_compile_warnings="yes" + ]) + + ax_enable_compile_warnings=$enable_compile_warnings + + AX_COMPILER_FLAGS_CFLAGS([$1],[$ax_compiler_flags_is_release], + [$4],[$5 $6 $7 $8]) + m4_ifdef([_AX_COMPILER_FLAGS_LANG_CXX_enabled], + [AX_COMPILER_FLAGS_CXXFLAGS([WARN_CXXFLAGS], + [$ax_compiler_flags_is_release], + [$4],[$5 $6 $7 $8])]) + AX_COMPILER_FLAGS_LDFLAGS([$2],[$ax_compiler_flags_is_release], + [$9],[$10 $11 $12 $13]) + AX_COMPILER_FLAGS_GIR([WARN_SCANNERFLAGS],[$ax_compiler_flags_is_release]) +])dnl AX_COMPILER_FLAGS diff --git a/m4/ax_compiler_flags_cflags.m4 b/m4/ax_compiler_flags_cflags.m4 new file mode 100644 index 0000000..f470f8f --- /dev/null +++ b/m4/ax_compiler_flags_cflags.m4 @@ -0,0 +1,133 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_cflags.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_COMPILER_FLAGS_CFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS]) +# +# DESCRIPTION +# +# Add warning flags for the C compiler to VARIABLE, which defaults to +# WARN_CFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be +# manually added to the CFLAGS variable for each target in the code base. +# +# This macro depends on the environment set up by AX_COMPILER_FLAGS. +# Specifically, it uses the value of $ax_enable_compile_warnings to decide +# which flags to enable. +# +# LICENSE +# +# Copyright (c) 2014, 2015 Philip Withnall +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 11 + +AC_DEFUN([AX_COMPILER_FLAGS_CFLAGS],[ + AC_REQUIRE([AC_PROG_SED]) + AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) + AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) + AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) + + # Variable names + m4_define(ax_warn_cflags_variable, + [m4_normalize(ifelse([$1],,[WARN_CFLAGS],[$1]))]) + + AC_LANG_PUSH([C]) + + # Always pass -Werror=unknown-warning-option to get Clang to fail on bad + # flags, otherwise they are always appended to the warn_cflags variable, and + # Clang warns on them for every compilation unit. + # If this is passed to GCC, it will explode, so the flag must be enabled + # conditionally. + AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[ + ax_compiler_flags_test="-Werror=unknown-warning-option" + ],[ + ax_compiler_flags_test="" + ]) + + # Base flags + AX_APPEND_COMPILE_FLAGS([ dnl + -fno-strict-aliasing dnl + $3 dnl + ],ax_warn_cflags_variable,[$ax_compiler_flags_test]) + + AS_IF([test "$ax_enable_compile_warnings" != "no"],[ + # "yes" flags + AX_APPEND_COMPILE_FLAGS([ dnl + -Wall dnl + -Wextra dnl + -Wundef dnl + -Wnested-externs dnl + -Wwrite-strings dnl + -Wpointer-arith dnl + -Wmissing-declarations dnl + -Wmissing-prototypes dnl + -Wstrict-prototypes dnl + -Wredundant-decls dnl + -Wno-unused-parameter dnl + -Wno-missing-field-initializers dnl + -Wdeclaration-after-statement dnl + -Wformat=2 dnl + -Wold-style-definition dnl + -Wcast-align dnl + -Wformat-nonliteral dnl + -Wformat-security dnl + -Wsign-compare dnl + -Wstrict-aliasing dnl + -Wshadow dnl + -Winline dnl + -Wpacked dnl + -Wmissing-format-attribute dnl + -Wmissing-noreturn dnl + -Winit-self dnl + -Wredundant-decls dnl + -Wmissing-include-dirs dnl + -Wunused-but-set-variable dnl + -Warray-bounds dnl + -Wimplicit-function-declaration dnl + -Wreturn-type dnl + -Wswitch-enum dnl + -Wswitch-default dnl + $4 dnl + $5 dnl + $6 dnl + $7 dnl + ],ax_warn_cflags_variable,[$ax_compiler_flags_test]) + ]) + AS_IF([test "$ax_enable_compile_warnings" = "error"],[ + # "error" flags; -Werror has to be appended unconditionally because + # it's not possible to test for + # + # suggest-attribute=format is disabled because it gives too many false + # positives + AX_APPEND_FLAG([-Werror],ax_warn_cflags_variable) + + AX_APPEND_COMPILE_FLAGS([ dnl + -Wno-suggest-attribute=format dnl + ],ax_warn_cflags_variable,[$ax_compiler_flags_test]) + ]) + + # In the flags below, when disabling specific flags, always add *both* + # -Wno-foo and -Wno-error=foo. This fixes the situation where (for example) + # we enable -Werror, disable a flag, and a build bot passes CFLAGS=-Wall, + # which effectively turns that flag back on again as an error. + for flag in $ax_warn_cflags_variable; do + AS_CASE([$flag], + [-Wno-*=*],[], + [-Wno-*],[ + AX_APPEND_COMPILE_FLAGS([-Wno-error=$(AS_ECHO([$flag]) | $SED 's/^-Wno-//')], + ax_warn_cflags_variable, + [$ax_compiler_flags_test]) + ]) + done + + AC_LANG_POP([C]) + + # Substitute the variables + AC_SUBST(ax_warn_cflags_variable) +])dnl AX_COMPILER_FLAGS diff --git a/m4/ax_compiler_flags_gir.m4 b/m4/ax_compiler_flags_gir.m4 new file mode 100644 index 0000000..180f50d --- /dev/null +++ b/m4/ax_compiler_flags_gir.m4 @@ -0,0 +1,60 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_gir.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_COMPILER_FLAGS_GIR([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS]) +# +# DESCRIPTION +# +# Add warning flags for the g-ir-scanner (from GObject Introspection) to +# VARIABLE, which defaults to WARN_SCANNERFLAGS. VARIABLE is AC_SUBST-ed +# by this macro, but must be manually added to the SCANNERFLAGS variable +# for each GIR target in the code base. +# +# This macro depends on the environment set up by AX_COMPILER_FLAGS. +# Specifically, it uses the value of $ax_enable_compile_warnings to decide +# which flags to enable. +# +# LICENSE +# +# Copyright (c) 2015 Philip Withnall +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 4 + +AC_DEFUN([AX_COMPILER_FLAGS_GIR],[ + AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) + + # Variable names + m4_define(ax_warn_scannerflags_variable, + [m4_normalize(ifelse([$1],,[WARN_SCANNERFLAGS],[$1]))]) + + # Base flags + AX_APPEND_FLAG([$3],ax_warn_scannerflags_variable) + + AS_IF([test "$ax_enable_compile_warnings" != "no"],[ + # "yes" flags + AX_APPEND_FLAG([ dnl + --warn-all dnl + $4 dnl + $5 dnl + $6 dnl + $7 dnl + ],ax_warn_scannerflags_variable) + ]) + AS_IF([test "$ax_enable_compile_warnings" = "error"],[ + # "error" flags + AX_APPEND_FLAG([ dnl + --warn-error dnl + ],ax_warn_scannerflags_variable) + ]) + + # Substitute the variables + AC_SUBST(ax_warn_scannerflags_variable) +])dnl AX_COMPILER_FLAGS diff --git a/m4/ax_compiler_flags_ldflags.m4 b/m4/ax_compiler_flags_ldflags.m4 new file mode 100644 index 0000000..f393ba4 --- /dev/null +++ b/m4/ax_compiler_flags_ldflags.m4 @@ -0,0 +1,75 @@ +# ============================================================================= +# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_ldflags.html +# ============================================================================= +# +# SYNOPSIS +# +# AX_COMPILER_FLAGS_LDFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS]) +# +# DESCRIPTION +# +# Add warning flags for the linker to VARIABLE, which defaults to +# WARN_LDFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be +# manually added to the LDFLAGS variable for each target in the code base. +# +# This macro depends on the environment set up by AX_COMPILER_FLAGS. +# Specifically, it uses the value of $ax_enable_compile_warnings to decide +# which flags to enable. +# +# LICENSE +# +# Copyright (c) 2014, 2015 Philip Withnall +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 4 + +AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[ + AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS]) + AX_REQUIRE_DEFINED([AX_APPEND_FLAG]) + AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG]) + + # Variable names + m4_define(ax_warn_ldflags_variable, + [m4_normalize(ifelse([$1],,[WARN_LDFLAGS],[$1]))]) + + # Always pass -Werror=unknown-warning-option to get Clang to fail on bad + # flags, otherwise they are always appended to the warn_ldflags variable, + # and Clang warns on them for every compilation unit. + # If this is passed to GCC, it will explode, so the flag must be enabled + # conditionally. + AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[ + ax_compiler_flags_test="-Werror=unknown-warning-option" + ],[ + ax_compiler_flags_test="" + ]) + + # Base flags + AX_APPEND_COMPILE_FLAGS([ dnl + -Wl,--no-as-needed dnl + $3 dnl + ],ax_warn_ldflags_variable,[$ax_compiler_flags_test]) + + AS_IF([test "$ax_enable_compile_warnings" != "no"],[ + # "yes" flags + AX_APPEND_COMPILE_FLAGS([$4 $5 $6 $7], + ax_warn_ldflags_variable, + [$ax_compiler_flags_test]) + ]) + AS_IF([test "$ax_enable_compile_warnings" = "error"],[ + # "error" flags; -Werror has to be appended unconditionally because + # it's not possible to test for + # + # suggest-attribute=format is disabled because it gives too many false + # positives + AX_APPEND_COMPILE_FLAGS([ dnl + -Wl,--fatal-warnings dnl + ],ax_warn_ldflags_variable,[$ax_compiler_flags_test]) + ]) + + # Substitute the variables + AC_SUBST(ax_warn_ldflags_variable) +])dnl AX_COMPILER_FLAGS diff --git a/m4/ax_is_release.m4 b/m4/ax_is_release.m4 new file mode 100644 index 0000000..9ec6746 --- /dev/null +++ b/m4/ax_is_release.m4 @@ -0,0 +1,69 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_is_release.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_IS_RELEASE(POLICY) +# +# DESCRIPTION +# +# Determine whether the code is being configured as a release, or from +# git. Set the ax_is_release variable to 'yes' or 'no'. +# +# If building a release version, it is recommended that the configure +# script disable compiler errors and debug features, by conditionalising +# them on the ax_is_release variable. If building from git, these +# features should be enabled. +# +# The POLICY parameter specifies how ax_is_release is determined. It can +# take the following values: +# +# * git-directory: ax_is_release will be 'no' if a '.git' directory exists +# * minor-version: ax_is_release will be 'no' if the minor version number +# in $PACKAGE_VERSION is odd; this assumes +# $PACKAGE_VERSION follows the 'major.minor.micro' scheme +# * micro-version: ax_is_release will be 'no' if the micro version number +# in $PACKAGE_VERSION is odd; this assumes +# $PACKAGE_VERSION follows the 'major.minor.micro' scheme +# * always: ax_is_release will always be 'yes' +# * never: ax_is_release will always be 'no' +# +# Other policies may be added in future. +# +# LICENSE +# +# Copyright (c) 2015 Philip Withnall +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. + +#serial 3 + +AC_DEFUN([AX_IS_RELEASE],[ + AC_BEFORE([AC_INIT],[$0]) + + m4_case([$1], + [git-directory],[ + # $is_release = (.git directory does not exist) + AS_IF([test -d .git],[ax_is_release=no],[ax_is_release=yes]) + ], + [minor-version],[ + # $is_release = ($minor_version is even) + minor_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'` + AS_IF([test "$(( $minor_version % 2 ))" -ne 0], + [ax_is_release=no],[ax_is_release=yes]) + ], + [micro-version],[ + # $is_release = ($micro_version is even) + micro_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]]*\.[[^.]]*\.\([[^.]]*\).*/\1/'` + AS_IF([test "$(( $micro_version % 2 ))" -ne 0], + [ax_is_release=no],[ax_is_release=yes]) + ], + [always],[ax_is_release=yes], + [never],[ax_is_release=no], + [ + AC_MSG_ERROR([Invalid policy. Valid policies: git-directory, minor-version.]) + ]) +]) diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4 new file mode 100644 index 0000000..cae1111 --- /dev/null +++ b/m4/ax_require_defined.m4 @@ -0,0 +1,37 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_REQUIRE_DEFINED(MACRO) +# +# DESCRIPTION +# +# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have +# been defined and thus are available for use. This avoids random issues +# where a macro isn't expanded. Instead the configure script emits a +# non-fatal: +# +# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found +# +# It's like AC_REQUIRE except it doesn't expand the required macro. +# +# Here's an example: +# +# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG]) +# +# LICENSE +# +# Copyright (c) 2014 Mike Frysinger +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +AC_DEFUN([AX_REQUIRE_DEFINED], [dnl + m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])]) +])dnl AX_REQUIRE_DEFINED diff --git a/tests/Makefile.am b/tests/Makefile.am index 722f058..6c9befc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -10,7 +10,9 @@ noinst_LIBRARIES = libtestutil.a libtestutil_a_SOURCES = test-util.h test-util.c test_regression_SOURCES = test-regression.c +test_regression_LDFLAGS = $(WARN_LDFLAGS) test_functional_SOURCES = test-functional.c +test_functional_LDFLAGS = $(WARN_LDFLAGS) LDADD = \ $(top_builddir)/libgssdp/libgssdp-1.0.la \ @@ -20,5 +22,5 @@ LDADD = \ AM_CFLAGS = \ $(LIBGSSDP_CFLAGS) \ -I $(top_srcdir) \ - -DDATA_PATH="\"$(srcdir)\"" - + -DDATA_PATH="\"$(srcdir)\"" \ + $(WARN_CFLAGS) diff --git a/tests/test-functional.c b/tests/test-functional.c index c9b9fc0..6c779a8 100644 --- a/tests/test-functional.c +++ b/tests/test-functional.c @@ -37,7 +37,7 @@ /* Helper functions */ static GSocket * -create_socket() +create_socket (void) { GSocket *socket; GError *error = NULL; @@ -61,7 +61,7 @@ create_socket() return socket; } -char * +static char * create_alive_message (const char *nt) { char *usn, *msg; @@ -83,7 +83,7 @@ create_alive_message (const char *nt) return msg; } -char * +static char * create_byebye_message (const char *nt) { char *usn, *msg; diff --git a/tests/test-regression.c b/tests/test-regression.c index dc5a802..52b4b7e 100644 --- a/tests/test-regression.c +++ b/tests/test-regression.c @@ -37,7 +37,7 @@ /* Utility functions */ static GSocket * -create_socket() +create_socket(void) { GSocket *socket; GError *error = NULL; @@ -61,7 +61,7 @@ create_socket() return socket; } -char * +static char * create_alive_message (const char *nt, int max_life) { char *usn, *msg; @@ -211,7 +211,7 @@ resource_unavailabe_bgo682099 (GSSDPResourceBrowser *src, g_main_loop_quit ((GMainLoop *) user_data); } -void test_bgo682099 (void) +static void test_bgo682099 (void) { GSSDPClient *dest; GSSDPResourceBrowser *browser; @@ -263,7 +263,7 @@ void test_bgo682099 (void) #define LOCATION_MISSED_BYE_BYE_1 "http://127.0.0.1:1234" #define LOCATION_MISSED_BYE_BYE_2 "http://127.0.0.1:1235" -char * +static char * create_alive_message_bgo724030 (const char *location) { char *msg; @@ -326,7 +326,7 @@ resource_unavailabe_bgo724030 (GSSDPResourceBrowser *src, g_main_loop_quit ((GMainLoop *) user_data); } -void test_bgo724030 (void) +static void test_bgo724030 (void) { GSSDPClient *dest; GSSDPResourceBrowser *browser; diff --git a/tests/test-util.c b/tests/test-util.c index 5bebefc..e53546a 100644 --- a/tests/test-util.c +++ b/tests/test-util.c @@ -21,7 +21,7 @@ #include "test-util.h" -void +G_GNUC_NORETURN void on_resource_unavailable_assert_not_reached (G_GNUC_UNUSED GSSDPResourceBrowser *src, G_GNUC_UNUSED const char *usn, G_GNUC_UNUSED gpointer user_data) @@ -29,7 +29,7 @@ on_resource_unavailable_assert_not_reached (G_GNUC_UNUSED GSSDPResourceBrowser * g_assert_not_reached (); } -void +G_GNUC_NORETURN void on_resource_available_assert_not_reached (G_GNUC_UNUSED GSSDPResourceBrowser *src, G_GNUC_UNUSED const char *usn, G_GNUC_UNUSED GList *locations, diff --git a/tools/Makefile.am b/tools/Makefile.am index 565e556..840f9bb 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,12 +1,12 @@ uidir = $(datadir)/gssdp dist_ui_DATA = $(srcdir)/gssdp-device-sniffer.ui -AM_CFLAGS = $(LIBGSSDP_CFLAGS) $(LIBGTK_CFLAGS) -I$(top_srcdir) -DUI_DIR='"$(uidir)"' +AM_CFLAGS = $(LIBGSSDP_CFLAGS) $(LIBGTK_CFLAGS) -I$(top_srcdir) -DUI_DIR='"$(uidir)"' $(WARN_CFLAGS) bin_PROGRAMS = gssdp-device-sniffer gssdp_device_sniffer_SOURCES = gssdp-device-sniffer.c gssdp_device_sniffer_LDADD = $(LIBGSSDP_LIBS) $(LIBGTK_LIBS) $(top_builddir)/libgssdp/libgssdp-1.0.la -gssdp_device_sniffer_LDFLAGS = -export-dynamic +gssdp_device_sniffer_LDFLAGS = -export-dynamic $(WARN_LDFLAGS) MAINTAINERCLEANFILES = Makefile.in diff --git a/tools/gssdp-device-sniffer.c b/tools/gssdp-device-sniffer.c index 2fd98b9..470c9d8 100644 --- a/tools/gssdp-device-sniffer.c +++ b/tools/gssdp-device-sniffer.c @@ -41,8 +41,28 @@ GOptionEntry entries[] = { NULL } }; -G_MODULE_EXPORT void +on_enable_packet_capture_activate (GtkCheckMenuItem *menuitem, + gpointer user_data); +void +on_details_activate (GtkWidget *scrolled_window, GtkCheckMenuItem *menuitem); + +void +on_clear_packet_capture_activate (GtkMenuItem *menuitem, + gpointer user_data); + +void +on_use_filter_radiobutton_toggled (GtkToggleButton *togglebutton, + gpointer user_data); +void +on_address_filter_dialog_response (GtkDialog *dialog, + gint response, + gpointer user_data); + +gboolean +on_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data); + +G_MODULE_EXPORT void on_enable_packet_capture_activate (GtkCheckMenuItem *menuitem, G_GNUC_UNUSED gpointer user_data) { @@ -50,7 +70,7 @@ on_enable_packet_capture_activate (GtkCheckMenuItem *menuitem, } static void -clear_packet_treeview () +clear_packet_treeview (void) { GtkWidget *treeview; GtkTreeModel *model; @@ -102,7 +122,7 @@ clear_textbuffer (GtkTextBuffer *textbuffer) } static void -update_packet_details (char *text, unsigned int len) +update_packet_details (const char *text, unsigned int len) { GtkWidget *textview; GtkTextBuffer *textbuffer; @@ -164,7 +184,7 @@ on_clear_packet_capture_activate (G_GNUC_UNUSED GtkMenuItem *menuitem, clear_packet_treeview (); } -static char *message_types[] = {"M-SEARCH", "RESPONSE", "NOTIFY"}; +static const char *message_types[] = {"M-SEARCH", "RESPONSE", "NOTIFY"}; static char ** packet_to_treeview_data (const gchar *from_ip, @@ -233,7 +253,7 @@ append_packet (const gchar *from_ip, } static void -on_ssdp_message (G_GNUC_UNUSED GSSDPClient *client, +on_ssdp_message (G_GNUC_UNUSED GSSDPClient *ssdp_client, G_GNUC_UNUSED const gchar *from_ip, G_GNUC_UNUSED gushort from_port, _GSSDPMessageType type, @@ -308,7 +328,7 @@ append_device (const char *uuid, } static void -resource_available_cb (G_GNUC_UNUSED GSSDPResourceBrowser *resource_browser, +resource_available_cb (G_GNUC_UNUSED GSSDPResourceBrowser *ssdp_resource_browser, const char *usn, GList *locations) { @@ -370,7 +390,7 @@ remove_device (const char *uuid) } static void -resource_unavailable_cb (G_GNUC_UNUSED GSSDPResourceBrowser *resource_browser, +resource_unavailable_cb (G_GNUC_UNUSED GSSDPResourceBrowser *ssdp_resource_browser, const char *usn) { char **usn_tokens; @@ -401,7 +421,7 @@ on_use_filter_radiobutton_toggled (GtkToggleButton *togglebutton, } static char * -get_ip_filter () +get_ip_filter (void) { int i; char *ip; @@ -483,7 +503,7 @@ create_device_treemodel (void) static void setup_treeview (GtkWidget *treeview, GtkTreeModel *model, - char *headers[]) + const char *headers[]) { int i; @@ -506,11 +526,11 @@ setup_treeview (GtkWidget *treeview, } static void -setup_treeviews () +setup_treeviews (void) { GtkWidget *treeviews[2]; GtkTreeModel *treemodels[2]; - char *headers[2][6] = { {"Time", + const char *headers[2][6] = { {"Time", "Source Address", "Packet Type", "Packet Information", @@ -561,7 +581,7 @@ init_ui (gint *argc, gchar **argv[]) { GtkWidget *main_window; gint window_width, window_height; - gchar *ui_path = NULL; + const gchar *ui_path = NULL; GError *error = NULL; GOptionContext *context; -- cgit v1.2.1