plugins: config.h must not be included by public headers

For a sane plugin build environment. Include config.h as the first
header in the .c file instead.

Fix by moving required compiler attribute macros to a new
"ws_attributes.h" API header.

Change-Id: I34f58a927f68c1a0e59686c14d214825149749e1
Reviewed-on: https://code.wireshark.org/review/23400
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
This commit is contained in:
João Valverde 2017-09-05 17:18:00 +01:00 committed by João Valverde
parent 143bc04ca7
commit d0a91b27f2
44 changed files with 106 additions and 53 deletions

View File

@ -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

View File

@ -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 = \

View File

@ -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);

View File

@ -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,

View File

@ -25,6 +25,7 @@
#ifdef HAVE_LIBPCAP
#include <caputils/iface_monitor.h>
#include "ws_attributes.h"
#if defined(HAVE_LIBNL)

View File

@ -27,6 +27,8 @@
extern "C" {
#endif /* __cplusplus */
#include "ws_attributes.h"
enum ws80211_channel_type {
WS80211_CHAN_NO_HT,
WS80211_CHAN_HT20,

View File

@ -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)" */

View File

@ -27,6 +27,8 @@
#include "G711adecode.h"
#include "G711atable.h"
#include "ws_attributes.h"
void *
codec_g711a_init(void)
{

View File

@ -27,6 +27,8 @@
#include "G711udecode.h"
#include "G711utable.h"
#include "ws_attributes.h"
void *
codec_g711u_init(void)
{

View File

@ -28,6 +28,8 @@
#include "spandsp.h"
#include "G722decode.h"
#include "ws_attributes.h"
void *
codec_g722_init(void)
{

View File

@ -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;

View File

@ -27,6 +27,8 @@
#include "bcg729/decoder.h"
#include "G729decode.h"
#include "ws_attributes.h"
void *
codec_g729_init(void)
{

View File

@ -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" {

View File

@ -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

View File

@ -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;

View File

@ -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).
#

View File

@ -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

View File

@ -26,6 +26,7 @@
#include <glib.h>
#include "asm_utils.h"
#include "ws_attributes.h"
/* String comparison func for dfilter_token GTree */
gint

View File

@ -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

View File

@ -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);

View File

@ -31,6 +31,7 @@
#include "config.h"
#include "packet-epl.h"
#include "ws_attributes.h"
#include <wsutil/ws_printf.h>
#include <epan/range.h>

View File

@ -27,6 +27,8 @@
#ifndef SNORT_CONFIG_H
#define SNORT_CONFIG_H
#include "ws_attributes.h"
/************************************************************************/
/* Rule related data types */

View File

@ -30,6 +30,7 @@
#include <glib.h>
#include <stdlib.h> /* exit() */
#include "ws_attributes.h"
typedef struct _dtd_build_data_t {
gchar* proto_name;

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -51,6 +51,7 @@
#include "ftypes/ftypes.h"
#include "register.h"
#include "ws_symbol_export.h"
#include "ws_attributes.h"
#ifdef __cplusplus
extern "C" {

View File

@ -27,6 +27,7 @@
#include <string.h>
#include <glib.h>
#include <ws_symbol_export.h>
#include "ws_attributes.h"
#ifdef __cplusplus
extern "C" {

View File

@ -38,6 +38,7 @@
#ifndef HAVE_GETOPT_LONG
#include "wsutil/wsgetopt.h"
#endif
#include "ws_attributes.h"
enum extcap_options {
EXTCAP_BASE_OPTIONS_ENUM

View File

@ -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);

View File

@ -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))

View File

@ -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 {

View File

@ -32,6 +32,7 @@
*/
#include "capture_opts.h"
#include <gtk/gtk.h>
#include "ws_attributes.h"
#define CR_MAIN_NB "compile_results_main_notebook"

View File

@ -26,6 +26,7 @@
#define __HELP_DLG_H__
#include "ui/help_url.h"
#include "ws_attributes.h"
/** @file
* "Help" dialog box.

View File

@ -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" {

59
ws_attributes.h Normal file
View File

@ -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__ */

View File

@ -24,8 +24,6 @@
#ifndef __WSUTIL_BITS_COUNT_ONES_H__
#define __WSUTIL_BITS_COUNT_ONES_H__
#include "config.h"
#include <glib.h>
/*

View File

@ -24,6 +24,7 @@
#define __CRASH_INFO_H__
#include "ws_symbol_export.h"
#include "ws_attributes.h"
#ifdef __cplusplus
extern "C" {

View File

@ -24,6 +24,7 @@
#define FILESYSTEM_H
#include "ws_symbol_export.h"
#include "ws_attributes.h"
#ifdef __cplusplus
extern "C" {

View File

@ -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

View File

@ -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);

View File

@ -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>

View File

@ -23,8 +23,6 @@
#ifndef __UNICODEUTIL_H__
#define __UNICODEUTIL_H__
#include <config.h>
#include "ws_symbol_export.h"
#include <glib.h>

View File

@ -23,8 +23,6 @@
#ifndef __WIN32UTIL_H__
#define __WIN32UTIL_H__
#include <config.h>
#include "ws_symbol_export.h"
#include <glib.h>