diff options
44 files changed, 106 insertions, 53 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index b7c18e0937..3504d17a98 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -772,17 +772,6 @@ if( NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") endif() endif() -if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang") - set (C_UNUSED "__attribute__((unused))" ) - set (WS_NORETURN "__attribute__((noreturn))") -elseif(MSVC) - set (C_UNUSED "") - set (WS_NORETURN "__declspec(noreturn)") -else() - set (C_UNUSED "") - set (WS_NORETURN "") -endif() - set(WIRESHARK_LD_FLAGS -Wl,--as-needed # -flto diff --git a/Makefile.am b/Makefile.am index 0ef06a6317..5c1ebd5fef 100644 --- a/Makefile.am +++ b/Makefile.am @@ -414,7 +414,8 @@ SHARK_COMMON_INCLUDES = \ fileset.h \ frame_tvbuff.h \ register.h \ - ws_symbol_export.h + ws_symbol_export.h \ + ws_attributes.h # wireshark specifics WIRESHARK_COMMON_SRC = \ diff --git a/capture_stop_conditions.c b/capture_stop_conditions.c index 415bbfedbd..38da7b381e 100644 --- a/capture_stop_conditions.c +++ b/capture_stop_conditions.c @@ -28,6 +28,7 @@ #include <stdarg.h> #include "conditions.h" #include "capture_stop_conditions.h" +#include "ws_attributes.h" /* predefined classes function prototypes */ static condition* _cnd_constr_timeout(condition*, va_list); diff --git a/caputils/capture-pcap-util.c b/caputils/capture-pcap-util.c index 910918c28d..87e0516692 100644 --- a/caputils/capture-pcap-util.c +++ b/caputils/capture-pcap-util.c @@ -39,6 +39,8 @@ #include <sys/socket.h> #endif +#include "ws_attributes.h" + /* * Linux bonding devices mishandle unknown ioctls; they fail * with ENODEV rather than ENOTSUP, EOPNOTSUPP, or ENOTTY, diff --git a/caputils/iface_monitor.c b/caputils/iface_monitor.c index 6ff5b54c54..f9bf13ebb7 100644 --- a/caputils/iface_monitor.c +++ b/caputils/iface_monitor.c @@ -25,6 +25,7 @@ #ifdef HAVE_LIBPCAP #include <caputils/iface_monitor.h> +#include "ws_attributes.h" #if defined(HAVE_LIBNL) diff --git a/caputils/ws80211_utils.h b/caputils/ws80211_utils.h index 247dfe2050..3e29acd6a0 100644 --- a/caputils/ws80211_utils.h +++ b/caputils/ws80211_utils.h @@ -27,6 +27,8 @@ extern "C" { #endif /* __cplusplus */ +#include "ws_attributes.h" + enum ws80211_channel_type { WS80211_CHAN_NO_HT, WS80211_CHAN_HT20, diff --git a/cmakeconfig.h.in b/cmakeconfig.h.in index 2b4048a08d..a8ab22fb90 100644 --- a/cmakeconfig.h.in +++ b/cmakeconfig.h.in @@ -437,13 +437,6 @@ /* Note: not use in the code */ #cmakedefine YYTEXT_POINTER -/* _U_ isn't needed for C++, simply don't name the variable. - However, we do need it for some headers that are shared between C and C++. */ -#define _U_ ${C_UNUSED} - -/* Hint to the compiler that a function never returns */ -#define WS_NORETURN @WS_NORETURN@ - #if defined(_WIN32) /* WpdPack/INclude/pcap/pcap.h checks for "#if defined(WIN32)" */ diff --git a/codecs/G711a/G711adecode.c b/codecs/G711a/G711adecode.c index 2ed2436058..3ca1fb4f8b 100644 --- a/codecs/G711a/G711adecode.c +++ b/codecs/G711a/G711adecode.c @@ -27,6 +27,8 @@ #include "G711adecode.h" #include "G711atable.h" +#include "ws_attributes.h" + void * codec_g711a_init(void) { diff --git a/codecs/G711u/G711udecode.c b/codecs/G711u/G711udecode.c index 8db44bed12..7c17f72ac5 100644 --- a/codecs/G711u/G711udecode.c +++ b/codecs/G711u/G711udecode.c @@ -27,6 +27,8 @@ #include "G711udecode.h" #include "G711utable.h" +#include "ws_attributes.h" + void * codec_g711u_init(void) { diff --git a/codecs/G722/G722decode.c b/codecs/G722/G722decode.c index e4951f8cd6..73d36f0847 100644 --- a/codecs/G722/G722decode.c +++ b/codecs/G722/G722decode.c @@ -28,6 +28,8 @@ #include "spandsp.h" #include "G722decode.h" +#include "ws_attributes.h" + void * codec_g722_init(void) { diff --git a/codecs/G726/G726decode.c b/codecs/G726/G726decode.c index fb98182614..b5580afd8b 100644 --- a/codecs/G726/G726decode.c +++ b/codecs/G726/G726decode.c @@ -27,6 +27,8 @@ #include "spandsp.h" #include "G726decode.h" +#include "ws_attributes.h" + typedef struct _g726_codec_ctx { g726_state_t *state; int bit_rate; diff --git a/codecs/G729/G729decode.c b/codecs/G729/G729decode.c index e5bb2ea61c..1594a5f9b4 100644 --- a/codecs/G729/G729decode.c +++ b/codecs/G729/G729decode.c @@ -27,6 +27,8 @@ #include "bcg729/decoder.h" #include "G729decode.h" +#include "ws_attributes.h" + void * codec_g729_init(void) { diff --git a/codecs/codecs.h b/codecs/codecs.h index 10aceae0d7..fabc734206 100644 --- a/codecs/codecs.h +++ b/codecs/codecs.h @@ -23,10 +23,9 @@ #ifndef _CODECS_H_ #define _CODECS_H_ -#include <config.h> - #include <epan/epan.h> #include "ws_symbol_export.h" +#include "ws_attributes.h" #ifdef __cplusplus extern "C" { diff --git a/codecs/speex/resample.c b/codecs/speex/resample.c index 4a0e53deb1..4457c639b8 100644 --- a/codecs/speex/resample.c +++ b/codecs/speex/resample.c @@ -80,6 +80,8 @@ static void speex_free (void *ptr) {g_free(ptr);} #include <math.h> #include <limits.h> +#include "ws_attributes.h" + #ifndef M_PI #define M_PI 3.14159265358979323846 #endif diff --git a/conditions.c b/conditions.c index aaaf959946..8f95a7e171 100644 --- a/conditions.c +++ b/conditions.c @@ -26,6 +26,7 @@ #include <stdlib.h> #include <stdarg.h> #include "conditions.h" +#include "ws_attributes.h" /* container for condition classes */ static GHashTable *classes = NULL; diff --git a/configure.ac b/configure.ac index a8a28ba7e5..738396899c 100644 --- a/configure.ac +++ b/configure.ac @@ -939,22 +939,6 @@ dnl build libwsutil_sse42 only if there is SSE4.2 AM_CONDITIONAL(SSE42_SUPPORTED, test "x$have_sse42" = "xyes") AC_SUBST(CFLAGS_SSE42) -# -# If we're running GCC or clang define _U_ to be "__attribute__((unused))" -# so we can use _U_ to flag unused function parameters and not get warnings -# about them. Otherwise, define _U_ to be an empty string so that _U_ used -# to flag an unused function parameters will compile with other compilers. -# -# XXX - similar hints for other compilers? -# -if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then - AC_DEFINE(_U_, __attribute__((unused)), [Hint to the compiler that a function parameters is not used]) - AC_DEFINE(WS_NORETURN, __attribute((noreturn)), [Hint to the compiler that a function never returns]) -else - AC_DEFINE(_U_, , [Hint to the compiler that a function parameters is not used]) - AC_DEFINE(WS_NORETURN, , [Hint to the compiler that a function never returns]) -fi - # If we're running GCC or CLang, use FORTIFY_SOURCE=2 # (only if the GCC 'optimization level' > 0). # diff --git a/debian/libwsutil-dev.install b/debian/libwsutil-dev.install index 7f9646cd8e..8e99533af7 100644 --- a/debian/libwsutil-dev.install +++ b/debian/libwsutil-dev.install @@ -1,4 +1,5 @@ usr/lib/*/libwsutil.so ws_symbol_export.h usr/include/wireshark ws_diag_control.h usr/include/wireshark +ws_attributes.h usr/include/wireshark wsutil/*.h usr/include/wireshark/wsutil diff --git a/epan/asm_utils.c b/epan/asm_utils.c index e02a737850..62ef49b095 100644 --- a/epan/asm_utils.c +++ b/epan/asm_utils.c @@ -26,6 +26,7 @@ #include <glib.h> #include "asm_utils.h" +#include "ws_attributes.h" /* String comparison func for dfilter_token GTree */ gint diff --git a/epan/dfilter/drange.h b/epan/dfilter/drange.h index d834c1d48f..6cad1f18ec 100644 --- a/epan/dfilter/drange.h +++ b/epan/dfilter/drange.h @@ -26,6 +26,7 @@ #include <glib.h> #include "ws_symbol_export.h" +#include "ws_attributes.h" /* Please don't directly manipulate these structs. Please use * the methods provided. If you REALLY can't do what you need to diff --git a/epan/dfilter/sttype-set.h b/epan/dfilter/sttype-set.h index 45576b58c2..51c3d159a3 100644 --- a/epan/dfilter/sttype-set.h +++ b/epan/dfilter/sttype-set.h @@ -24,6 +24,8 @@ #include <glib.h> +#include "ws_attributes.h" + void sttype_set_replace_element(stnode_t *node, stnode_t *oldnode, stnode_t *newnode); diff --git a/epan/dissectors/packet-epl-profile-parser.c b/epan/dissectors/packet-epl-profile-parser.c index f45e08f772..e4699a7254 100644 --- a/epan/dissectors/packet-epl-profile-parser.c +++ b/epan/dissectors/packet-epl-profile-parser.c @@ -31,6 +31,7 @@ #include "config.h" #include "packet-epl.h" +#include "ws_attributes.h" #include <wsutil/ws_printf.h> #include <epan/range.h> diff --git a/epan/dissectors/snort-config.h b/epan/dissectors/snort-config.h index 09a40ca1c9..411f26a63a 100644 --- a/epan/dissectors/snort-config.h +++ b/epan/dissectors/snort-config.h @@ -27,6 +27,8 @@ #ifndef SNORT_CONFIG_H #define SNORT_CONFIG_H +#include "ws_attributes.h" + /************************************************************************/ /* Rule related data types */ diff --git a/epan/dtd.h b/epan/dtd.h index 64e07e591c..2507303760 100644 --- a/epan/dtd.h +++ b/epan/dtd.h @@ -30,6 +30,7 @@ #include <glib.h> #include <stdlib.h> /* exit() */ +#include "ws_attributes.h" typedef struct _dtd_build_data_t { gchar* proto_name; diff --git a/epan/except.h b/epan/except.h index 0f979637e9..45ce069c72 100644 --- a/epan/except.h +++ b/epan/except.h @@ -35,6 +35,7 @@ #include <stdlib.h> #include <assert.h> #include "ws_symbol_export.h" +#include "ws_attributes.h" #define XCEPT_GROUP_ANY 0 #define XCEPT_CODE_ANY 0 diff --git a/epan/exported_pdu.h b/epan/exported_pdu.h index 8a3beb57c8..2220020fc4 100644 --- a/epan/exported_pdu.h +++ b/epan/exported_pdu.h @@ -25,9 +25,8 @@ #ifndef EXPORTED_PDU_H #define EXPORTED_PDU_H -#include <config.h> - #include "ws_symbol_export.h" +#include "ws_attributes.h" #include <glib.h> diff --git a/epan/plugin_if.h b/epan/plugin_if.h index 61258a92d8..8cd0c6a883 100644 --- a/epan/plugin_if.h +++ b/epan/plugin_if.h @@ -29,9 +29,8 @@ #ifndef EPAN_PLUGIN_IF_H #define EPAN_PLUGIN_IF_H -#include <config.h> - #include "ws_symbol_export.h" +#include "ws_attributes.h" #include <glib.h> #include <epan/epan.h> diff --git a/epan/proto.h b/epan/proto.h index deecd478a3..6981af8f04 100644 --- a/epan/proto.h +++ b/epan/proto.h @@ -51,6 +51,7 @@ #include "ftypes/ftypes.h" #include "register.h" #include "ws_symbol_export.h" +#include "ws_attributes.h" #ifdef __cplusplus extern "C" { diff --git a/epan/wmem/wmem_core.h b/epan/wmem/wmem_core.h index fc04524de8..a3cab03ee5 100644 --- a/epan/wmem/wmem_core.h +++ b/epan/wmem/wmem_core.h @@ -27,6 +27,7 @@ #include <string.h> #include <glib.h> #include <ws_symbol_export.h> +#include "ws_attributes.h" #ifdef __cplusplus extern "C" { diff --git a/extcap/extcap-base.c b/extcap/extcap-base.c index 1e1a49c7e0..ae2e68f561 100644 --- a/extcap/extcap-base.c +++ b/extcap/extcap-base.c @@ -38,6 +38,7 @@ #ifndef HAVE_GETOPT_LONG #include "wsutil/wsgetopt.h" #endif +#include "ws_attributes.h" enum extcap_options { EXTCAP_BASE_OPTIONS_ENUM diff --git a/extcap_parser.c b/extcap_parser.c index fcfee88a8e..9ca8a7a910 100644 --- a/extcap_parser.c +++ b/extcap_parser.c @@ -33,6 +33,7 @@ #include "extcap.h" #include "extcap_parser.h" +#include "ws_attributes.h" void extcap_printf_complex(extcap_complex *comp) { gchar *ret = extcap_get_complex_as_string(comp); diff --git a/tools/lemon/lemon.c b/tools/lemon/lemon.c index 02dc201367..399196b0cd 100644 --- a/tools/lemon/lemon.c +++ b/tools/lemon/lemon.c @@ -16,6 +16,8 @@ #include <stdlib.h> #include <assert.h> +#include "ws_attributes.h" + #define ISSPACE(X) isspace((unsigned char)(X)) #define ISDIGIT(X) isdigit((unsigned char)(X)) #define ISALNUM(X) isalnum((unsigned char)(X)) diff --git a/ui/cli/tap-funnel.c b/ui/cli/tap-funnel.c index 5f20d3ec1b..98446718f2 100644 --- a/ui/cli/tap-funnel.c +++ b/ui/cli/tap-funnel.c @@ -30,6 +30,8 @@ #include <epan/funnel.h> #include <stdio.h> +#include "ws_attributes.h" + void register_tap_listener_funnel(void); struct _funnel_text_window_t { diff --git a/ui/gtk/capture_dlg.h b/ui/gtk/capture_dlg.h index d6cf21b6b6..0dfeea5a93 100644 --- a/ui/gtk/capture_dlg.h +++ b/ui/gtk/capture_dlg.h @@ -32,6 +32,7 @@ */ #include "capture_opts.h" #include <gtk/gtk.h> +#include "ws_attributes.h" #define CR_MAIN_NB "compile_results_main_notebook" diff --git a/ui/gtk/help_dlg.h b/ui/gtk/help_dlg.h index 1ebd292d71..f921728250 100644 --- a/ui/gtk/help_dlg.h +++ b/ui/gtk/help_dlg.h @@ -26,6 +26,7 @@ #define __HELP_DLG_H__ #include "ui/help_url.h" +#include "ws_attributes.h" /** @file * "Help" dialog box. diff --git a/wiretap/wtap.h b/wiretap/wtap.h index ff3d5dd816..79a8251931 100644 --- a/wiretap/wtap.h +++ b/wiretap/wtap.h @@ -27,6 +27,7 @@ #include <wsutil/nstime.h> #include "wtap_opttypes.h" #include "ws_symbol_export.h" +#include "ws_attributes.h" #ifdef __cplusplus extern "C" { diff --git a/ws_attributes.h b/ws_attributes.h new file mode 100644 index 0000000000..d07ae75324 --- /dev/null +++ b/ws_attributes.h @@ -0,0 +1,59 @@ +/* ws_attributes.h + * + * Wireshark - Network traffic analyzer + * By Gerald Combs <gerald@wireshark.org> + * Copyright 1998 Gerald Combs + * + * 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 2 + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef __WS_ATTRIBUTES_H__ +#define __WS_ATTRIBUTES_H__ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* + * If we're running GCC or clang define _U_ to be "__attribute__((unused))" + * so we can use _U_ to flag unused function parameters and not get warnings + * about them. Otherwise, define _U_ to be an empty string so that _U_ used + * to flag an unused function parameters will compile with other compilers. + * + * XXX - similar hints for other compilers? + */ + +#if defined(__GNUC__) + /* This includes clang */ + #define _U_ __attribute__((unused)) +#else + #define _U_ +#endif + +/* Hint to the compiler that a function never returns */ +#if defined(__GNUC__) + /* This includes clang */ + #define WS_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) + #define WS_NORETURN __declspec(noreturn) +#else + #define WS_NORETURN +#endif + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __WS_ATTRIBUTES_H__ */ diff --git a/wsutil/bits_count_ones.h b/wsutil/bits_count_ones.h index fbaf820794..1c2b28b94d 100644 --- a/wsutil/bits_count_ones.h +++ b/wsutil/bits_count_ones.h @@ -24,8 +24,6 @@ #ifndef __WSUTIL_BITS_COUNT_ONES_H__ #define __WSUTIL_BITS_COUNT_ONES_H__ -#include "config.h" - #include <glib.h> /* diff --git a/wsutil/crash_info.h b/wsutil/crash_info.h index 91818c2802..482b4fe20e 100644 --- a/wsutil/crash_info.h +++ b/wsutil/crash_info.h @@ -24,6 +24,7 @@ #define __CRASH_INFO_H__ #include "ws_symbol_export.h" +#include "ws_attributes.h" #ifdef __cplusplus extern "C" { diff --git a/wsutil/filesystem.h b/wsutil/filesystem.h index f09e5ccaea..f6c0e0899e 100644 --- a/wsutil/filesystem.h +++ b/wsutil/filesystem.h @@ -24,6 +24,7 @@ #define FILESYSTEM_H #include "ws_symbol_export.h" +#include "ws_attributes.h" #ifdef __cplusplus extern "C" { diff --git a/wsutil/inet_addr-int.h b/wsutil/inet_addr-int.h index 25f698d1df..c702a9a435 100644 --- a/wsutil/inet_addr-int.h +++ b/wsutil/inet_addr-int.h @@ -22,8 +22,6 @@ #ifndef __WS_INET_ADDR_INT_H__ #define __WS_INET_ADDR_INT_H__ -#include "config.h" - #ifdef HAVE_ARPA_INET_H #include <arpa/inet.h> #endif diff --git a/wsutil/popcount.h b/wsutil/popcount.h index b58708f629..e23f69b4ac 100644 --- a/wsutil/popcount.h +++ b/wsutil/popcount.h @@ -22,8 +22,6 @@ #ifndef __POPCOUNT_H__ #define __POPCOUNT_H__ -#include "config.h" - #include "ws_symbol_export.h" WS_DLL_PUBLIC int popcount(unsigned int mask); diff --git a/wsutil/socket.h b/wsutil/socket.h index a26eb35363..372cd2f793 100644 --- a/wsutil/socket.h +++ b/wsutil/socket.h @@ -24,8 +24,6 @@ #ifndef __SOCKET_H__ #define __SOCKET_H__ -#include "config.h" - #if defined(_WIN32) && !defined(__CYGWIN__) #ifdef HAVE_WINDOWS_H #include <windows.h> diff --git a/wsutil/unicode-utils.h b/wsutil/unicode-utils.h index 30ec43a919..59e47f24b5 100644 --- a/wsutil/unicode-utils.h +++ b/wsutil/unicode-utils.h @@ -23,8 +23,6 @@ #ifndef __UNICODEUTIL_H__ #define __UNICODEUTIL_H__ -#include <config.h> - #include "ws_symbol_export.h" #include <glib.h> diff --git a/wsutil/win32-utils.h b/wsutil/win32-utils.h index 01026bcf8e..34705957ae 100644 --- a/wsutil/win32-utils.h +++ b/wsutil/win32-utils.h @@ -23,8 +23,6 @@ #ifndef __WIN32UTIL_H__ #define __WIN32UTIL_H__ -#include <config.h> - #include "ws_symbol_export.h" #include <glib.h> |