Skip to content

Commit

Permalink
ci: fix and test with Wunused-macros
Browse files Browse the repository at this point in the history
Ticket: 6937
  • Loading branch information
catenacyber committed Apr 12, 2024
1 parent d9148d1 commit 4c84c1d
Show file tree
Hide file tree
Showing 38 changed files with 38 additions and 130 deletions.
10 changes: 10 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,16 @@
CFLAGS="$CFLAGS -std=gnu99"
fi

# check if our compiler supports -Wunused-macros
AC_MSG_CHECKING(for -Wunused-macros support)
OCFLAGS=$CFLAGS
CFLAGS="$CFLAGS -Wunused-macros"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],
[[]])],
AC_MSG_RESULT([yes]),
[AC_MSG_RESULT([no])
CFLAGS="$OCFLAGS"])

# check if our target supports thread local storage
AC_MSG_CHECKING(for thread local storage gnu __thread support)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
Expand Down
18 changes: 0 additions & 18 deletions src/app-layer-dnp3.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@
/* Maximum transport layer sequence number. */
#define DNP3_MAX_TRAN_SEQNO 64

/* Maximum application layer sequence number. */
#define DNP3_MAX_APP_SEQNO 16

/* The number of bytes in the header that are counted as part of the
* header length field. */
#define DNP3_LINK_HDR_LEN 5
Expand All @@ -75,18 +72,6 @@ enum {
DNP3_LINK_FC_UNCONFIRMED_USER_DATA
};

/* Reserved addresses. */
#define DNP3_RESERVED_ADDR_MIN 0xfff0
#define DNP3_RESERVED_ADDR_MAX 0xfffb

/* Source addresses must be < 0xfff0. */
#define DNP3_SRC_ADDR_MAX 0xfff0

#define DNP3_OBJ_TIME_SIZE 6 /* AKA UINT48. */
#define DNP3_OBJ_G12_V1_SIZE 11
#define DNP3_OBJ_G12_V2_SIZE 11
#define DNP3_OBJ_G12_V3_SIZE 1

/* Extract the prefix code from the object qualifier. */
#define DNP3_OBJ_PREFIX(x) ((x >> 4) & 0x7)

Expand All @@ -107,9 +92,6 @@ SCEnumCharMap dnp3_decoder_event_table[] = {
/* Calculate the next transport sequence number. */
#define NEXT_TH_SEQNO(current) ((current + 1) % DNP3_MAX_TRAN_SEQNO)

/* Calculate the next application sequence number. */
#define NEXT_APP_SEQNO(current) ((current + 1) % DNP3_MAX_APP_SEQNO)

/* CRC table generated by pycrc - http://github.com/tpircher/pycrc.
* - Polynomial: 0x3d65. */
static const uint16_t crc_table[256] = {
Expand Down
1 change: 0 additions & 1 deletion src/app-layer-parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1677,7 +1677,6 @@ static void ValidateParserProtoDump(AppProto alproto, uint8_t ipproto)

#define BOTH_SET(a, b) ((a) != NULL && (b) != NULL)
#define BOTH_SET_OR_BOTH_UNSET(a, b) (((a) == NULL && (b) == NULL) || ((a) != NULL && (b) != NULL))
#define THREE_SET_OR_THREE_UNSET(a, b, c) (((a) == NULL && (b) == NULL && (c) == NULL) || ((a) != NULL && (b) != NULL && (c) != NULL))
#define THREE_SET(a, b, c) ((a) != NULL && (b) != NULL && (c) != NULL)

static void ValidateParserProto(AppProto alproto, uint8_t ipproto)
Expand Down
18 changes: 3 additions & 15 deletions src/app-layer-smtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,16 @@
#define FILEDATA_CONTENT_INSPECT_WINDOW 4096

/* raw extraction default value */
#define SMTP_RAW_EXTRACTION_DEFAULT_VALUE false
#define SMTP_MAX_REQUEST_AND_REPLY_LINE_LENGTH 510
#define SMTP_RAW_EXTRACTION_DEFAULT_VALUE false

#define SMTP_COMMAND_BUFFER_STEPS 5

/* we are in process of parsing a fresh command. Just a placeholder. If we
* are not in STATE_COMMAND_DATA_MODE, we have to be in this mode */
#define SMTP_PARSER_STATE_COMMAND_MODE 0x00
// unused #define SMTP_PARSER_STATE_COMMAND_MODE 0x00
/* we are in mode of parsing a command's data. Used when we are parsing tls
* or accepting the rfc 2822 mail after DATA command */
#define SMTP_PARSER_STATE_COMMAND_DATA_MODE 0x01
/* Used when we are still in the process of parsing a server command. Used
* with multi-line replies and the stream is fragmented before all the lines
* for a response is seen */
#define SMTP_PARSER_STATE_PARSING_SERVER_RESPONSE 0x02
#define SMTP_PARSER_STATE_COMMAND_DATA_MODE 0x01
/* Used to indicate that the parser has seen the first reply */
#define SMTP_PARSER_STATE_FIRST_REPLY_SEEN 0x04
/* Used to indicate that the parser is parsing a multiline reply */
Expand All @@ -105,13 +100,6 @@
#define SMTP_COMMAND_OTHER_CMD 5
#define SMTP_COMMAND_RSET 6

/* Different EHLO extensions. Not used now. */
#define SMTP_EHLO_EXTENSION_PIPELINING
#define SMTP_EHLO_EXTENSION_SIZE
#define SMTP_EHLO_EXTENSION_DSN
#define SMTP_EHLO_EXTENSION_STARTTLS
#define SMTP_EHLO_EXTENSION_8BITMIME

#define SMTP_DEFAULT_MAX_TX 256

typedef struct SMTPInput_ {
Expand Down
3 changes: 1 addition & 2 deletions src/app-layer-ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ SslConfig ssl_config;
#define SSLV2_MT_REQUEST_CERTIFICATE 7
#define SSLV2_MT_CLIENT_CERTIFICATE 8

#define SSLV3_RECORD_HDR_LEN 5
#define SSLV3_MESSAGE_HDR_LEN 4
#define SSLV3_RECORD_HDR_LEN 5
/** max length according to RFC 5246 6.2.2 is 2^14 + 1024 */
#define SSLV3_RECORD_MAX_LEN ((1 << 14) + 1024)

Expand Down
5 changes: 3 additions & 2 deletions src/detect-bytemath.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,13 @@

static int DetectByteMathSetup(DetectEngineCtx *, Signature *, const char *);
#ifdef UNITTESTS
#define DETECT_BYTEMATH_ENDIAN_DEFAULT (uint8_t) BigEndian
#define DETECT_BYTEMATH_BASE_DEFAULT (uint8_t) BaseDec

static void DetectByteMathRegisterTests(void);
#endif
static void DetectByteMathFree(DetectEngineCtx *, void *);

#define DETECT_BYTEMATH_ENDIAN_DEFAULT (uint8_t) BigEndian
#define DETECT_BYTEMATH_BASE_DEFAULT (uint8_t) BaseDec
/**
* \brief Registers the keyword handlers for the "byte_math" keyword.
*/
Expand Down
1 change: 0 additions & 1 deletion src/detect-dce-stub-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
#include "rust.h"

#define BUFFER_NAME "dce_stub_data"
#define KEYWORD_NAME "dce_stub_data"

static int DetectDceStubDataSetup(DetectEngineCtx *, Signature *, const char *);
#ifdef UNITTESTS
Expand Down
3 changes: 0 additions & 3 deletions src/detect-engine-state.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@

#include "flow-util.h"

/** convert enum to string */
#define CASE_CODE(E) case E: return #E

static inline int StateIsValid(uint16_t alproto, void *alstate)
{
if (alstate != NULL) {
Expand Down
11 changes: 0 additions & 11 deletions src/detect-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,17 +145,6 @@ typedef struct SigDuplWrapper_ {
Signature *s_prev;
} SigDuplWrapper;

#define CONFIG_PARTS 8

#define CONFIG_ACTION 0
#define CONFIG_PROTO 1
#define CONFIG_SRC 2
#define CONFIG_SP 3
#define CONFIG_DIREC 4
#define CONFIG_DST 5
#define CONFIG_DP 6
#define CONFIG_OPTS 7

/** helper structure for sig parsing */
typedef struct SignatureParser_ {
char action[DETECT_MAX_RULE_SIZE];
Expand Down
1 change: 0 additions & 1 deletion src/detect-quic-sni.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static void DetectQuicSniRegisterTests(void);

#define BUFFER_NAME "quic_sni"
#define KEYWORD_NAME "quic.sni"
#define KEYWORD_ID DETECT_AL_QUIC_SNI

static int quic_sni_id = 0;

Expand Down
1 change: 0 additions & 1 deletion src/detect-quic-ua.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static void DetectQuicUaRegisterTests(void);

#define BUFFER_NAME "quic_ua"
#define KEYWORD_NAME "quic.ua"
#define KEYWORD_ID DETECT_AL_QUIC_UA

static int quic_ua_id = 0;

Expand Down
1 change: 0 additions & 1 deletion src/detect-quic-version.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ static void DetectQuicVersionRegisterTests(void);

#define BUFFER_NAME "quic_version"
#define KEYWORD_NAME "quic.version"
#define KEYWORD_ID DETECT_AL_QUIC_VERSION

static int quic_version_id = 0;

Expand Down
3 changes: 1 addition & 2 deletions src/detect-smb-version.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

#define BUFFER_NAME "smb_version"
#define KEYWORD_NAME "smb.version"
#define KEYWORD_ID DETECT_SMB_VERSION

static int g_smb_version_list_id = 0;

Expand Down Expand Up @@ -152,4 +151,4 @@ void DetectSmbVersionRegister(void)
g_smb_version_list_id = DetectBufferTypeRegister(BUFFER_NAME);

SCLogDebug("registering " BUFFER_NAME " rule option");
}
}
8 changes: 0 additions & 8 deletions src/flow-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,6 @@ void FlowTimeoutsEmergency(void)
SC_ATOMIC_SET(flow_timeouts, flow_timeouts_emerg);
}

/* 1 seconds */
#define FLOW_NORMAL_MODE_UPDATE_DELAY_SEC 1
#define FLOW_NORMAL_MODE_UPDATE_DELAY_NSEC 0
/* 0.3 seconds */
#define FLOW_EMERG_MODE_UPDATE_DELAY_SEC 0
#define FLOW_EMERG_MODE_UPDATE_DELAY_NSEC 300000
#define NEW_FLOW_COUNT_COND 10

typedef struct FlowTimeoutCounters_ {
uint32_t rows_checked;
uint32_t rows_skipped;
Expand Down
3 changes: 1 addition & 2 deletions src/log-httplog.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,7 @@ void LogHttpLogRegister (void)
#define LOG_HTTP_CF_REQUEST_HOST 'h'
#define LOG_HTTP_CF_REQUEST_PROTOCOL 'H'
#define LOG_HTTP_CF_REQUEST_METHOD 'm'
#define LOG_HTTP_CF_REQUEST_URI 'u'
#define LOG_HTTP_CF_REQUEST_TIME 't'
#define LOG_HTTP_CF_REQUEST_URI 'u'
#define LOG_HTTP_CF_REQUEST_HEADER 'i'
#define LOG_HTTP_CF_REQUEST_COOKIE 'C'
#define LOG_HTTP_CF_REQUEST_LEN 'b'
Expand Down
3 changes: 1 addition & 2 deletions src/log-tlslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@

#define PRINT_BUF_LEN 46

#define OUTPUT_BUFFER_SIZE 65535
#define CERT_ENC_BUFFER_SIZE 2048
#define OUTPUT_BUFFER_SIZE 65535

#define LOG_TLS_DEFAULT 0
#define LOG_TLS_EXTENDED 1
Expand Down
2 changes: 0 additions & 2 deletions src/output-eve-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@

#define MODULE_NAME "EveStreamLog"

#define LOG_DROP_ALERTS 1

typedef struct EveStreamOutputCtx_ {
uint16_t trigger_flags; /**< presence of flags in packet trigger logging. 0xffff for all. */
OutputJsonCtx *eve_ctx;
Expand Down
2 changes: 0 additions & 2 deletions src/output-json-alert.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,6 @@ static void SetFlag(const ConfNode *conf, const char *name, uint16_t flag, uint1
}
}

#define DEFAULT_LOG_FILENAME "alert.json"

static void JsonAlertLogSetupMetadata(AlertJsonOutputCtx *json_output_ctx,
ConfNode *conf)
{
Expand Down
1 change: 0 additions & 1 deletion src/output-json-anomaly.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ static void JsonAnomalyLogDeInitCtxSub(OutputCtx *output_ctx)
JsonAnomalyLogDeInitCtxSubHelper(output_ctx);
}

#define DEFAULT_LOG_FILENAME "anomaly.json"
static void SetFlag(const ConfNode *conf, const char *name, uint16_t flag, uint16_t *out_flags)
{
DEBUG_VALIDATE_BUG_ON(conf == NULL);
Expand Down
2 changes: 0 additions & 2 deletions src/output-json-dnp3.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@ static void OutputDNP3LogDeInitCtxSub(OutputCtx *output_ctx)
SCFree(output_ctx);
}

#define DEFAULT_LOG_FILENAME "dnp3.json"

static OutputInitResult OutputDNP3LogInitSub(ConfNode *conf, OutputCtx *parent_ctx)
{
OutputInitResult result = { NULL, false };
Expand Down
4 changes: 0 additions & 4 deletions src/output-json-dns.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@
#include "output-json-dns.h"
#include "rust.h"

/* we can do query logging as well, but it's disabled for now as the
* TX id handling doesn't expect it */
#define QUERY 0

#define LOG_QUERIES BIT_U64(0)
#define LOG_ANSWERS BIT_U64(1)

Expand Down
2 changes: 0 additions & 2 deletions src/output-json-frame.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@

#define MODULE_NAME "JsonFrameLog"

#define JSON_STREAM_BUFFER_SIZE 4096

typedef struct FrameJsonOutputCtx_ {
LogFileCtx *file_ctx;
uint16_t flags;
Expand Down
2 changes: 0 additions & 2 deletions src/output-json-ssh.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@
#include "output-json-ssh.h"
#include "rust.h"

#define MODULE_NAME "LogSshLog"

static int JsonSshLogger(ThreadVars *tv, void *thread_data, const Packet *p,
Flow *f, void *state, void *txptr, uint64_t tx_id)
{
Expand Down
3 changes: 0 additions & 3 deletions src/output-json-tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,6 @@

SC_ATOMIC_EXTERN(unsigned int, cert_id);

#define MODULE_NAME "LogTlsLog"
#define DEFAULT_LOG_FILENAME "tls.json"

#define LOG_TLS_DEFAULT 0
#define LOG_TLS_EXTENDED (1 << 0)
#define LOG_TLS_CUSTOM (1 << 1)
Expand Down
1 change: 0 additions & 1 deletion src/runmode-af-xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* AF_XDP socket runmode
*
*/
#define PCAP_DONT_INCLUDE_PCAP_BPF_H 1
#define SC_PCAP_DONT_INCLUDE_PCAP_H 1
#include "suricata-common.h"
#include "tm-threads.h"
Expand Down
6 changes: 3 additions & 3 deletions src/runmode-napatech.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@
#include "runmode-napatech.h"
#include "source-napatech.h" // need NapatechStreamDevConf structure

#define NT_RUNMODE_AUTOFP 1
#define NT_RUNMODE_WORKERS 2

static const char *default_mode = "workers";

#ifdef HAVE_NAPATECH

#define NT_RUNMODE_AUTOFP 1
#define NT_RUNMODE_WORKERS 2

#define MAX_STREAMS 256
static uint16_t num_configured_streams = 0;
static uint16_t first_stream = 0xffff;
Expand Down
2 changes: 1 addition & 1 deletion src/runmode-pfring.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

#ifdef HAVE_PFRING
#include <pfring.h>
#endif

#define PFRING_CONF_V1 1
#define PFRING_CONF_V2 2
#endif

const char *RunModeIdsPfringGetDefaultMode(void)
{
Expand Down
4 changes: 2 additions & 2 deletions src/source-af-packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
*
*/

#define PCAP_DONT_INCLUDE_PCAP_BPF_H 1
#define SC_PCAP_DONT_INCLUDE_PCAP_H 1
#include "suricata-common.h"
#include "suricata.h"
Expand Down Expand Up @@ -73,14 +72,15 @@
#endif

#ifdef HAVE_PACKET_EBPF
#define PCAP_DONT_INCLUDE_PCAP_BPF_H 1
#include <bpf/libbpf.h>
#include <bpf/bpf.h>
#endif

struct bpf_program {
unsigned int bf_len;
struct bpf_insn *bf_insns;
};
#endif

#ifdef HAVE_PCAP_H
#include <pcap.h>
Expand Down
3 changes: 1 addition & 2 deletions src/source-af-xdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
* AF_XDP socket acquisition support
*
*/
#define PCAP_DONT_INCLUDE_PCAP_BPF_H 1
#define SC_PCAP_DONT_INCLUDE_PCAP_H 1
#include "suricata-common.h"
#include "suricata.h"
Expand Down Expand Up @@ -973,4 +972,4 @@ static TmEcode DecodeAFXDPThreadDeinit(ThreadVars *tv, void *data)
/* eof */
/**
* @}
*/
*/

0 comments on commit 4c84c1d

Please sign in to comment.