From: Michael Altizer (mialtize) Date: Mon, 21 Aug 2017 22:11:58 +0000 (-0400) Subject: Merge pull request #996 in SNORT/snort3 from warnings to master X-Git-Tag: 3.0.0-240~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=44d0f04b8b8605474d7b431fe07b9681cfbaf87f;p=thirdparty%2Fsnort3.git Merge pull request #996 in SNORT/snort3 from warnings to master Squashed commit of the following: commit 74780ac195a4bd913c9eda6a0c6d9d14698f431d Author: Michael Altizer Date: Fri Aug 18 16:16:13 2017 -0400 build: Clean up some more compiler warnings and remove spurious tabs --- diff --git a/src/detection/detect_trace.cc b/src/detection/detect_trace.cc index ced91eaca..22813b958 100644 --- a/src/detection/detect_trace.cc +++ b/src/detection/detect_trace.cc @@ -130,7 +130,7 @@ void node_eval_trace(const detection_option_tree_node_t* node, const Cursor& cur else { trace_logf(detection, TRACE_RULE_EVAL, "Reached leaf, cursor name %s, cursor position %u\n", - name, pos); + name, pos); } if (!trace_enabled(detection_trace, trace_buffer)) diff --git a/src/detection/detect_trace.h b/src/detection/detect_trace.h index 9dea9b8a1..e8c4cfec5 100644 --- a/src/detection/detect_trace.h +++ b/src/detection/detect_trace.h @@ -31,13 +31,13 @@ enum { - TRACE_DETECTION_ENGINE = 0x1, - TRACE_RULE_EVAL = 0x2, - TRACE_BUFFER_MINIMAL = 0x4, - TRACE_BUFFER_VERBOSE = 0x8, - TRACE_RULE_VARS = 0x10 + TRACE_DETECTION_ENGINE = 0x1, + TRACE_RULE_EVAL = 0x2, + TRACE_BUFFER_MINIMAL = 0x4, + TRACE_BUFFER_VERBOSE = 0x8, + TRACE_RULE_VARS = 0x10 }; - + void clear_trace_cursor_info(); void print_pkt_info(Packet* p); void print_pattern(const PatternMatchData* pmd); diff --git a/src/helpers/base64_encoder.h b/src/helpers/base64_encoder.h index 6c5a8d486..93c6db4db 100644 --- a/src/helpers/base64_encoder.h +++ b/src/helpers/base64_encoder.h @@ -40,7 +40,7 @@ public: unsigned finish(char* buf); void reset() - { step = step_A, state = 0; } + { step = step_A; state = 0; } private: enum Steps { step_A, step_B, step_C }; diff --git a/src/ips_options/ips_byte_math.cc b/src/ips_options/ips_byte_math.cc index 62767ee1f..f62a281cf 100644 --- a/src/ips_options/ips_byte_math.cc +++ b/src/ips_options/ips_byte_math.cc @@ -279,16 +279,16 @@ int ByteMathOption::eval(Cursor& c, Packet* p) static void parse_base(uint8_t value, ByteMathData& idx) { - assert(value <= 2); - int base[] = { 16, 10, 8 }; - idx.base = base[value]; + assert(value <= 2); + int base[] = { 16, 10, 8 }; + idx.base = base[value]; } static void parse_endian(uint8_t value, ByteMathData& idx) { - assert(value <= 1); - int endian[] = { ENDIAN_BIG, ENDIAN_LITTLE }; - set_byte_order(idx.endianess, endian[value], "byte_math"); + assert(value <= 1); + int endian[] = { ENDIAN_BIG, ENDIAN_LITTLE }; + set_byte_order(idx.endianess, endian[value], "byte_math"); } //------------------------------------------------------------------------- diff --git a/src/ips_options/ips_icmp_id.cc b/src/ips_options/ips_icmp_id.cc index ad64a6277..160f7601d 100644 --- a/src/ips_options/ips_icmp_id.cc +++ b/src/ips_options/ips_icmp_id.cc @@ -113,7 +113,7 @@ int IcmpIdOption::eval(Cursor&, Packet* p) ((uint8_t)p->ptrs.icmph->type == icmp::Icmp6Types::ECHO_REQUEST || (uint8_t)p->ptrs.icmph->type == icmp::Icmp6Types::ECHO_REPLY) ) { - uint16_t icmp_id = ntohs(p->ptrs.icmph->s_icmp_id); + uint16_t icmp_id = ntohs(p->ptrs.icmph->s_icmp_id); if ( config.eval( icmp_id ) ) return DETECTION_OPTION_MATCH; } diff --git a/src/ips_options/ips_icmp_seq.cc b/src/ips_options/ips_icmp_seq.cc index 461b0005c..506ba1248 100644 --- a/src/ips_options/ips_icmp_seq.cc +++ b/src/ips_options/ips_icmp_seq.cc @@ -112,7 +112,7 @@ int IcmpSeqOption::eval(Cursor&, Packet* p) ((uint8_t)p->ptrs.icmph->type == icmp::Icmp6Types::ECHO_REQUEST || (uint8_t)p->ptrs.icmph->type == icmp::Icmp6Types::ECHO_REPLY) ) { - uint16_t icmp_seq = ntohs(p->ptrs.icmph->s_icmp_seq); + uint16_t icmp_seq = ntohs(p->ptrs.icmph->s_icmp_seq); if ( config.eval( icmp_seq ) ) { return DETECTION_OPTION_MATCH; diff --git a/src/ips_options/ips_rpc.cc b/src/ips_options/ips_rpc.cc index 11b5a5df4..a6f71ac4e 100644 --- a/src/ips_options/ips_rpc.cc +++ b/src/ips_options/ips_rpc.cc @@ -40,7 +40,7 @@ struct RpcCheckData uint32_t program; uint32_t version; uint32_t procedure; - uint32_t flags; // which fields to check + uint32_t flags; // which fields to check }; #define RPC_CHECK_VERSION 0x1 @@ -155,7 +155,7 @@ bool RpcOption::is_match(Packet* p) // get a 32-bit int from the current location and increment to next int position uint32_t RpcOption::get_int(const uint8_t*& data) { - uint32_t value = extract_32bits(data); + uint32_t value = extract_32bits(data); data += 4; return value; } diff --git a/src/ips_options/ips_session.cc b/src/ips_options/ips_session.cc index 65d051245..fe357e287 100644 --- a/src/ips_options/ips_session.cc +++ b/src/ips_options/ips_session.cc @@ -62,9 +62,9 @@ static THREAD_LOCAL ProfileStats sessionPerfStats; -#define SESSION_PRINTABLE 1 -#define SESSION_BINARY 2 -#define SESSION_ALL 3 +#define SESSION_PRINTABLE 1 +#define SESSION_BINARY 2 +#define SESSION_ALL 3 struct SessionData { diff --git a/src/log/messages.cc b/src/log/messages.cc index c62b0f032..76e4d5c77 100644 --- a/src/log/messages.cc +++ b/src/log/messages.cc @@ -112,7 +112,7 @@ void ParseError(const char* format, ...) parse_errors++; } -NORETURN void ParseAbort(const char* format, ...) +[[noreturn]] void ParseAbort(const char* format, ...) { char buf[STD_BUF+1]; va_list ap; @@ -258,7 +258,7 @@ void ErrorMessage(const char* format,...) * * Returns: void function */ -NORETURN void FatalError(const char* format,...) +[[noreturn]] void FatalError(const char* format,...) { char buf[STD_BUF+1]; va_list ap; @@ -303,7 +303,7 @@ NORETURN void FatalError(const char* format,...) } } -void log_safec_error(const char* msg, void*, int e) +[[noreturn]] void log_safec_error(const char* msg, void*, int e) { static THREAD_LOCAL unsigned safec_errors = 0; diff --git a/src/log/messages.h b/src/log/messages.h index 3482d6027..af595badd 100644 --- a/src/log/messages.h +++ b/src/log/messages.h @@ -51,7 +51,7 @@ unsigned get_parse_warnings(); SO_PUBLIC void ParseMessage(const char*, ...) __attribute__((format (printf, 1, 2))); SO_PUBLIC void ParseWarning(WarningGroup, const char*, ...) __attribute__((format (printf, 2, 3))); SO_PUBLIC void ParseError(const char*, ...) __attribute__((format (printf, 1, 2))); -SO_PUBLIC NORETURN void ParseAbort(const char*, ...) __attribute__((format (printf, 1, 2))); +[[noreturn]] SO_PUBLIC void ParseAbort(const char*, ...) __attribute__((format (printf, 1, 2))); SO_PUBLIC void LogMessage(const char*, ...) __attribute__((format (printf, 1, 2))); SO_PUBLIC void LogMessage(FILE* fh, const char*, ...) __attribute__((format (printf, 2, 3))); @@ -59,9 +59,9 @@ SO_PUBLIC void WarningMessage(const char*, ...) __attribute__((format (printf, 1 SO_PUBLIC void ErrorMessage(const char*, ...) __attribute__((format (printf, 1, 2))); // FIXIT-M do not call FatalError() during runtime -SO_PUBLIC NORETURN void FatalError(const char*, ...) __attribute__((format (printf, 1, 2))); +[[noreturn]] SO_PUBLIC void FatalError(const char*, ...) __attribute__((format (printf, 1, 2))); -void log_safec_error(const char*, void*, int); +[[noreturn]] void log_safec_error(const char*, void*, int); class Dumper { diff --git a/src/main/help.cc b/src/main/help.cc index e86f862ae..a8eb6a313 100644 --- a/src/main/help.cc +++ b/src/main/help.cc @@ -112,13 +112,13 @@ void help_args(const char* pfx) } } -NORETURN void help_basic(SnortConfig*, const char*) +[[noreturn]] void help_basic(SnortConfig*, const char*) { fprintf(stdout, "%s\n", snort_help); exit(0); } -NORETURN void help_usage(SnortConfig*, const char* s) +[[noreturn]] void help_usage(SnortConfig*, const char* s) { fprintf(stdout, "usage:\n"); fprintf(stdout, " %s -?: list options\n", s); @@ -130,13 +130,13 @@ NORETURN void help_usage(SnortConfig*, const char* s) exit(0); } -NORETURN void help_options(SnortConfig*, const char* val) +[[noreturn]] void help_options(SnortConfig*, const char* val) { help_args(val); exit(0); } -NORETURN void help_signals(SnortConfig*, const char*) +[[noreturn]] void help_signals(SnortConfig*, const char*) { help_signals(); exit(0); @@ -149,7 +149,7 @@ enum HelpType HT_IPS, HT_LST, HT_MOD, HT_PEG, HT_PLG }; -NORETURN static void show_help(SnortConfig* sc, const char* val, HelpType ht) +[[noreturn]] static void show_help(SnortConfig* sc, const char* val, HelpType ht) { snort_conf = new SnortConfig; ScriptManager::load_scripts(sc->script_paths); @@ -211,12 +211,12 @@ NORETURN static void show_help(SnortConfig* sc, const char* val, HelpType ht) exit(0); } -NORETURN void help_config(SnortConfig* sc, const char* val) +[[noreturn]] void help_config(SnortConfig* sc, const char* val) { show_help(sc, val, HT_CFG); } -NORETURN void help_commands(SnortConfig* sc, const char* val) +[[noreturn]] void help_commands(SnortConfig* sc, const char* val) { show_help(sc, val, HT_CMD); } @@ -226,48 +226,48 @@ void config_markup(SnortConfig*, const char*) Markup::enable(); } -NORETURN void help_gids(SnortConfig* sc, const char* val) +[[noreturn]] void help_gids(SnortConfig* sc, const char* val) { show_help(sc, val, HT_GID); } -NORETURN void help_buffers(SnortConfig* sc, const char* val) +[[noreturn]] void help_buffers(SnortConfig* sc, const char* val) { show_help(sc, val, HT_BUF); } -NORETURN void help_builtin(SnortConfig* sc, const char* val) +[[noreturn]] void help_builtin(SnortConfig* sc, const char* val) { show_help(sc, val, HT_IPS); } -NORETURN void help_counts(SnortConfig* sc, const char* val) +[[noreturn]] void help_counts(SnortConfig* sc, const char* val) { show_help(sc, val, HT_PEG); } -NORETURN void help_module(SnortConfig* sc, const char* val) +[[noreturn]] void help_module(SnortConfig* sc, const char* val) { show_help(sc, val, HT_MOD); } -NORETURN void help_modules(SnortConfig* sc, const char* val) +[[noreturn]] void help_modules(SnortConfig* sc, const char* val) { show_help(sc, val, HT_HMO); } -NORETURN void help_plugins(SnortConfig* sc, const char* val) +[[noreturn]] void help_plugins(SnortConfig* sc, const char* val) { show_help(sc, val, HT_HPL); } -NORETURN void help_version(SnortConfig*) +[[noreturn]] void help_version(SnortConfig*) { DisplayBanner(); exit(0); } -NORETURN void list_daqs(SnortConfig* sc) +[[noreturn]] void list_daqs(SnortConfig* sc) { SFDAQ::load(sc); SFDAQ::print_types(cout); @@ -275,55 +275,55 @@ NORETURN void list_daqs(SnortConfig* sc) exit(0); } -NORETURN void list_interfaces(SnortConfig*) +[[noreturn]] void list_interfaces(SnortConfig*) { PrintAllInterfaces(); exit(0); } -NORETURN void list_modules(SnortConfig* sc, const char* val) +[[noreturn]] void list_modules(SnortConfig* sc, const char* val) { show_help(sc, val, HT_LST); } -NORETURN void list_plugins(SnortConfig* sc, const char* val) +[[noreturn]] void list_plugins(SnortConfig* sc, const char* val) { show_help(sc, val, HT_PLG); } -NORETURN void dump_defaults(SnortConfig* sc, const char* val) +[[noreturn]] void dump_defaults(SnortConfig* sc, const char* val) { show_help(sc, val, HT_DFL); } -NORETURN void dump_builtin_rules(SnortConfig* sc, const char* val) +[[noreturn]] void dump_builtin_rules(SnortConfig* sc, const char* val) { show_help(sc, val, HT_DBR); } -NORETURN void dump_dynamic_rules(SnortConfig* sc, const char* val) +[[noreturn]] void dump_dynamic_rules(SnortConfig* sc, const char* val) { show_help(sc, val, HT_DDR); } -NORETURN void dump_msg_map(SnortConfig* sc, const char* val) +[[noreturn]] void dump_msg_map(SnortConfig* sc, const char* val) { show_help(sc, val, HT_DMM); } -NORETURN void dump_rule_hex(SnortConfig*, const char* val) +[[noreturn]] void dump_rule_hex(SnortConfig*, const char* val) { SoManager::rule_to_hex(val); exit(0); } -NORETURN void dump_rule_text(SnortConfig*, const char* val) +[[noreturn]] void dump_rule_text(SnortConfig*, const char* val) { SoManager::rule_to_text(val); exit(0); } -NORETURN void dump_version(SnortConfig*) +[[noreturn]] void dump_version(SnortConfig*) { cout << VERSION << endl; exit(0); diff --git a/src/main/help.h b/src/main/help.h index 2f249b01c..f2242b9e7 100644 --- a/src/main/help.h +++ b/src/main/help.h @@ -28,33 +28,33 @@ struct SnortConfig; void config_markup(SnortConfig*, const char*); void help_args(const char* pfx); -void help_basic(SnortConfig*, const char*); -void help_usage(SnortConfig*, const char*); -void help_options(SnortConfig*, const char*); -void help_signals(SnortConfig*, const char*); -void help_config(SnortConfig* sc, const char*); -void help_commands(SnortConfig* sc, const char*); -void help_gids(SnortConfig* sc, const char*); -void help_buffers(SnortConfig* sc, const char*); -void help_builtin(SnortConfig* sc, const char*); -void help_module(SnortConfig* sc, const char*); -void help_modules(SnortConfig* sc, const char*); -void help_plugins(SnortConfig* sc, const char*); -void help_version(SnortConfig*); -void help_counts(SnortConfig* sc, const char*); - -void list_modules(SnortConfig* sc, const char*); -void list_plugins(SnortConfig* sc, const char*); -void list_interfaces(SnortConfig*); -void list_daqs(SnortConfig* sc); - -void dump_defaults(SnortConfig* sc, const char*); -void dump_builtin_rules(SnortConfig* sc, const char*); -void dump_dynamic_rules(SnortConfig* sc, const char*); -void dump_msg_map(SnortConfig* sc, const char*); -void dump_rule_hex(SnortConfig* sc, const char*); -void dump_rule_text(SnortConfig* sc, const char*); -void dump_version(SnortConfig* sc); +[[noreturn]] void help_basic(SnortConfig*, const char*); +[[noreturn]] void help_usage(SnortConfig*, const char*); +[[noreturn]] void help_options(SnortConfig*, const char*); +[[noreturn]] void help_signals(SnortConfig*, const char*); +[[noreturn]] void help_config(SnortConfig* sc, const char*); +[[noreturn]] void help_commands(SnortConfig* sc, const char*); +[[noreturn]] void help_gids(SnortConfig* sc, const char*); +[[noreturn]] void help_buffers(SnortConfig* sc, const char*); +[[noreturn]] void help_builtin(SnortConfig* sc, const char*); +[[noreturn]] void help_module(SnortConfig* sc, const char*); +[[noreturn]] void help_modules(SnortConfig* sc, const char*); +[[noreturn]] void help_plugins(SnortConfig* sc, const char*); +[[noreturn]] void help_version(SnortConfig*); +[[noreturn]] void help_counts(SnortConfig* sc, const char*); + +[[noreturn]] void list_modules(SnortConfig* sc, const char*); +[[noreturn]] void list_plugins(SnortConfig* sc, const char*); +[[noreturn]] void list_interfaces(SnortConfig*); +[[noreturn]] void list_daqs(SnortConfig* sc); + +[[noreturn]] void dump_defaults(SnortConfig* sc, const char*); +[[noreturn]] void dump_builtin_rules(SnortConfig* sc, const char*); +[[noreturn]] void dump_dynamic_rules(SnortConfig* sc, const char*); +[[noreturn]] void dump_msg_map(SnortConfig* sc, const char*); +[[noreturn]] void dump_rule_hex(SnortConfig* sc, const char*); +[[noreturn]] void dump_rule_text(SnortConfig* sc, const char*); +[[noreturn]] void dump_version(SnortConfig* sc); #endif diff --git a/src/main/snort_debug.cc b/src/main/snort_debug.cc index 7b216679e..97fd84ad1 100644 --- a/src/main/snort_debug.cc +++ b/src/main/snort_debug.cc @@ -104,11 +104,11 @@ static inline void trace_vprintf(const char* name, Trace mask, const char* file, if ( !trace_enabled(mask, flags) ) return; - char buf[STD_BUF]; + char buf[STD_BUF]; int buf_len = sizeof(buf); char* buf_ptr = buf; int size; - + if (name) { size = snprintf(buf, buf_len, "%s: ", name); @@ -120,7 +120,7 @@ static inline void trace_vprintf(const char* name, Trace mask, const char* file, buf_len -= size; } } - + if ( file ) { size = snprintf(buf_ptr, buf_len, "%s:%d: ", file, line); diff --git a/src/main/snort_module.cc b/src/main/snort_module.cc index 3b6a06926..0cbf94fd2 100644 --- a/src/main/snort_module.cc +++ b/src/main/snort_module.cc @@ -95,19 +95,19 @@ static const Command snort_cmds[] = // why not //------------------------------------------------------------------------- -NORETURN static void c2x(const char* s) +[[noreturn]] static void c2x(const char* s) { printf("'%c' = 0x%2.2X (%d)\n", s[0], s[0], s[0]); exit(0); } -NORETURN static void x2c(unsigned x) +[[noreturn]] static void x2c(unsigned x) { printf("0x%2.2X (%u) = '%c'\n", x, x, static_cast(x)); exit(0); } -NORETURN static void x2s(const char* s) +[[noreturn]] static void x2s(const char* s) { bool inv; string out, in = "\""; diff --git a/src/main/snort_types.h b/src/main/snort_types.h index 33b191e6c..23c5c4119 100644 --- a/src/main/snort_types.h +++ b/src/main/snort_types.h @@ -59,18 +59,6 @@ typedef uint16_t Port; #endif #endif -/* specifies that a function does not return - * used for quieting Visual Studio warnings */ -#ifdef _MSC_VER -# if _MSC_VER >= 1400 -# define NORETURN __declspec(noreturn) -# else -# define NORETURN -# endif -#else -# define NORETURN __attribute__ ((noreturn)) -#endif - #if !defined(__GNUC__) || __GNUC__ < 2 || \ (__GNUC__ == 2 && __GNUC_MINOR__ < 5) #define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */ diff --git a/src/network_inspectors/appid/detector_plugins/http_url_patterns.h b/src/network_inspectors/appid/detector_plugins/http_url_patterns.h index ffe619d77..252b75b10 100644 --- a/src/network_inspectors/appid/detector_plugins/http_url_patterns.h +++ b/src/network_inspectors/appid/detector_plugins/http_url_patterns.h @@ -228,20 +228,20 @@ typedef std::vector CHPMatchTally; struct ChpMatchDescriptor { - void free_rewrite_buffers() - { + void free_rewrite_buffers() + { for (unsigned i = 0; i < NUMBER_OF_PTYPES; i++) if (chp_rewritten[i]) { snort_free(chp_rewritten[i]); chp_rewritten[i] = nullptr; } - } + } - void sort_chp_matches() - { - chp_matches[cur_ptype].sort(ChpMatchDescriptor::comp_chp_actions); - } + void sort_chp_matches() + { + chp_matches[cur_ptype].sort(ChpMatchDescriptor::comp_chp_actions); + } PatternType cur_ptype; char* buffer[NUMBER_OF_PTYPES] = { nullptr }; diff --git a/src/parser/parser.cc b/src/parser/parser.cc index de5b7901c..b481c1b3c 100644 --- a/src/parser/parser.cc +++ b/src/parser/parser.cc @@ -779,7 +779,7 @@ RuleTreeNode* deleteRtnFromOtn(OptTreeNode* otn, SnortConfig* sc) return deleteRtnFromOtn(otn, get_ips_policy()->policy_id, sc); } -uint32_t rtn_hash_func(SFHASHFCN*, unsigned char *k, int) +static uint32_t rtn_hash_func(SFHASHFCN*, unsigned char *k, int) { uint32_t a,b,c; RuleTreeNodeKey* rtnk = (RuleTreeNodeKey*)k; @@ -800,7 +800,7 @@ uint32_t rtn_hash_func(SFHASHFCN*, unsigned char *k, int) return c; } -int rtn_compare_func(const void *k1, const void *k2, size_t) +static int rtn_compare_func(const void *k1, const void *k2, size_t) { RuleTreeNodeKey* rtnk1 = (RuleTreeNodeKey*)k1; RuleTreeNodeKey* rtnk2 = (RuleTreeNodeKey*)k2; @@ -814,7 +814,7 @@ int rtn_compare_func(const void *k1, const void *k2, size_t) if (same_headers(rtnk1->rtn, rtnk2->rtn)) return 0; - return 1; + return 1; } /**Add RTN to OTN for a particular OTN. diff --git a/src/ports/port_table.cc b/src/ports/port_table.cc index fb0ba6242..561ab8840 100644 --- a/src/ports/port_table.cc +++ b/src/ports/port_table.cc @@ -583,7 +583,7 @@ static inline SF_LIST** create_port_lists(PortTable* p) SF_LIST** parray = (SF_LIST**)snort_calloc(sizeof(SF_LIST*), SFPO_MAX_PORTS); assert(parray); - PortObject* po; + PortObject* po; SF_LNODE* lpos; for ( po = (PortObject*)sflist_first(p->pt_polist, &lpos); po; @@ -653,9 +653,9 @@ static int PortTableCompileMergePortObjects(PortTable* p) po; po = (PortObject*)sflist_next(&lpos) ) { - if (pol_cnt < SFPO_MAX_LPORTS ) + if (pol_cnt < SFPO_MAX_LPORTS ) { - pol[ pol_cnt++ ] = po; + pol[ pol_cnt++ ] = po; } } p->pt_port_object[i] = 0; @@ -685,8 +685,8 @@ static int PortTableCompileMergePortObjects(PortTable* p) DEBUG_WRAP(DebugMessage(DEBUG_PORTLISTS, "\n"); fflush(stdout); ); } - delete_port_lists(optimized_pl); - snort_free(optimized_pl); + delete_port_lists(optimized_pl); + snort_free(optimized_pl); /* * Normalize the Ports so they indicate only the ports that diff --git a/src/search_engines/acsmx2.cc b/src/search_engines/acsmx2.cc index 5a2f5cc7f..0dde93532 100644 --- a/src/search_engines/acsmx2.cc +++ b/src/search_engines/acsmx2.cc @@ -350,16 +350,16 @@ static void AC_FREE_DFA(void* p, int n, int sizeofstate) static int List_GetNextStateOpt( ACSM_STRUCT2 * acsm, trans_node_t **acsmTransTableOpt, int state, int input ) { - int index = state * acsm->acsmAlphabetSize + input; - trans_node_t * t = acsmTransTableOpt[index]; + int index = state * acsm->acsmAlphabetSize + input; + trans_node_t * t = acsmTransTableOpt[index]; - if ( t ) - return t->next_state; + if ( t ) + return t->next_state; - if( state == 0 ) + if( state == 0 ) return 0; - return ACSM_FAIL_STATE2; /* Fail state ??? */ + return ACSM_FAIL_STATE2; /* Fail state ??? */ } @@ -408,34 +408,34 @@ static int List_GetNextState2(ACSM_STRUCT2* acsm, int state, int input) * Put Next State - Head insertion, and transition updates */ static int List_PutNextStateOpt( ACSM_STRUCT2 * acsm, trans_node_t **acsmTransTableOpt, - int state, int input, int next_state ) + int state, int input, int next_state ) { - int index = state * acsm->acsmAlphabetSize + input; + int index = state * acsm->acsmAlphabetSize + input; - trans_node_t *t = acsmTransTableOpt[index]; + trans_node_t *t = acsmTransTableOpt[index]; - if ( t ) - { - t->next_state = next_state; - return 0; - } + if ( t ) + { + t->next_state = next_state; + return 0; + } - /* Definitely not an existing transition - add it */ - trans_node_t * tnew = (trans_node_t*)AC_MALLOC(sizeof(trans_node_t), - ACSM2_MEMORY_TYPE__TRANSTABLE); + /* Definitely not an existing transition - add it */ + trans_node_t * tnew = (trans_node_t*)AC_MALLOC(sizeof(trans_node_t), + ACSM2_MEMORY_TYPE__TRANSTABLE); - if( !tnew ) - return -1; + if( !tnew ) + return -1; - tnew->key = input; - tnew->next_state = next_state; - tnew->next = acsm->acsmTransTable[state]; - acsm->acsmTransTable[state] = tnew; - acsm->acsmNumTrans++; + tnew->key = input; + tnew->next_state = next_state; + tnew->next = acsm->acsmTransTable[state]; + acsm->acsmTransTable[state] = tnew; + acsm->acsmNumTrans++; - acsmTransTableOpt[index] = tnew; + acsmTransTableOpt[index] = tnew; - return 0; + return 0; } /* @@ -741,19 +741,19 @@ static void Convert_NFA_To_DFA(ACSM_STRUCT2* acsm) for (int i=0; iacsmAlphabetSize; i++) { if ( int s = List_GetNextStateOpt(acsm, acsmTransTableOpt, 0, i) ) - { - if ( !queue_array[s] ) - { - queue.push_back(s); - queue_array[s] = true; - } - } + { + if ( !queue_array[s] ) + { + queue.push_back(s); + queue_array[s] = true; + } + } } /* Start building the next layer of transitions */ for ( auto r : queue ) { - queue_array[r] = false; + queue_array[r] = false; /* Process this states layer */ for (int i = 0; i < acsm->acsmAlphabetSize; i++) @@ -762,11 +762,11 @@ static void Convert_NFA_To_DFA(ACSM_STRUCT2* acsm) if ( (acstate_t)s != ACSM_FAIL_STATE2 && s != 0 ) { - if ( !queue_array[s] ) - { - queue.push_back(s); - queue_array[s] = true; - } + if ( !queue_array[s] ) + { + queue.push_back(s); + queue_array[s] = true; + } } else { @@ -780,8 +780,8 @@ static void Convert_NFA_To_DFA(ACSM_STRUCT2* acsm) } } - snort_free(queue_array); - snort_free(acsmTransTableOpt); + snort_free(queue_array); + snort_free(acsmTransTableOpt); } /* diff --git a/src/service_inspectors/dce_rpc/smb_message.cc b/src/service_inspectors/dce_rpc/smb_message.cc index 5e2b3e3cd..d15e47ad1 100644 --- a/src/service_inspectors/dce_rpc/smb_message.cc +++ b/src/service_inspectors/dce_rpc/smb_message.cc @@ -1338,34 +1338,34 @@ static DCE2_SmbSsnData* dce2_create_new_smb_session(Packet* p, dce2SmbProtoConf* { Profile profile(dce2_smb_pstat_new_session); - DebugMessage(DEBUG_DCE_SMB, "DCE over SMB packet detected\n"); - DebugMessage(DEBUG_DCE_SMB, "Creating new session\n"); + DebugMessage(DEBUG_DCE_SMB, "DCE over SMB packet detected\n"); + DebugMessage(DEBUG_DCE_SMB, "Creating new session\n"); DCE2_SmbSsnData* dce2_smb_sess = set_new_dce2_smb_session(p); - if ( dce2_smb_sess ) - { - dce2_smb_sess->dialect_index = DCE2_SENTINEL; - dce2_smb_sess->max_outstanding_requests = 10; // Until Negotiate/SessionSetupAndX - dce2_smb_sess->cli_data_state = DCE2_SMB_DATA_STATE__NETBIOS_HEADER; - dce2_smb_sess->srv_data_state = DCE2_SMB_DATA_STATE__NETBIOS_HEADER; - dce2_smb_sess->pdu_state = DCE2_SMB_PDU_STATE__COMMAND; - dce2_smb_sess->uid = DCE2_SENTINEL; - dce2_smb_sess->tid = DCE2_SENTINEL; - dce2_smb_sess->ftracker.fid_v1 = DCE2_SENTINEL; - dce2_smb_sess->rtracker.mid = DCE2_SENTINEL; - dce2_smb_sess->max_file_depth = FileService::get_max_file_depth(); - - DCE2_ResetRopts(&dce2_smb_sess->sd.ropts); - - dce2_smb_stats.smb_sessions++; - DebugFormat(DEBUG_DCE_SMB,"Created (%p)\n", (void*)dce2_smb_sess); - - dce2_smb_sess->sd.trans = DCE2_TRANS_TYPE__SMB; - dce2_smb_sess->sd.server_policy = config->common.policy; - dce2_smb_sess->sd.client_policy = DCE2_POLICY__WINXP; - dce2_smb_sess->sd.wire_pkt = p; - dce2_smb_sess->sd.config = (void*)config; - } + if ( dce2_smb_sess ) + { + dce2_smb_sess->dialect_index = DCE2_SENTINEL; + dce2_smb_sess->max_outstanding_requests = 10; // Until Negotiate/SessionSetupAndX + dce2_smb_sess->cli_data_state = DCE2_SMB_DATA_STATE__NETBIOS_HEADER; + dce2_smb_sess->srv_data_state = DCE2_SMB_DATA_STATE__NETBIOS_HEADER; + dce2_smb_sess->pdu_state = DCE2_SMB_PDU_STATE__COMMAND; + dce2_smb_sess->uid = DCE2_SENTINEL; + dce2_smb_sess->tid = DCE2_SENTINEL; + dce2_smb_sess->ftracker.fid_v1 = DCE2_SENTINEL; + dce2_smb_sess->rtracker.mid = DCE2_SENTINEL; + dce2_smb_sess->max_file_depth = FileService::get_max_file_depth(); + + DCE2_ResetRopts(&dce2_smb_sess->sd.ropts); + + dce2_smb_stats.smb_sessions++; + DebugFormat(DEBUG_DCE_SMB,"Created (%p)\n", (void*)dce2_smb_sess); + + dce2_smb_sess->sd.trans = DCE2_TRANS_TYPE__SMB; + dce2_smb_sess->sd.server_policy = config->common.policy; + dce2_smb_sess->sd.client_policy = DCE2_POLICY__WINXP; + dce2_smb_sess->sd.wire_pkt = p; + dce2_smb_sess->sd.config = (void*)config; + } return dce2_smb_sess; } diff --git a/src/service_inspectors/ftp_telnet/ftp_data.cc b/src/service_inspectors/ftp_telnet/ftp_data.cc index e8c73275d..090e154f5 100644 --- a/src/service_inspectors/ftp_telnet/ftp_data.cc +++ b/src/service_inspectors/ftp_telnet/ftp_data.cc @@ -277,7 +277,7 @@ void FtpData::eval(Packet* p) StreamSplitter* FtpData::get_splitter(bool to_server) { - return new FtpDataSplitter(to_server); + return new FtpDataSplitter(to_server); } //------------------------------------------------------------------------- diff --git a/src/service_inspectors/http_inspect/http_enum.h b/src/service_inspectors/http_inspect/http_enum.h index 8055a9776..910aae390 100644 --- a/src/service_inspectors/http_inspect/http_enum.h +++ b/src/service_inspectors/http_inspect/http_enum.h @@ -90,11 +90,11 @@ enum MethodId { METH_REBIND, METH_UNBIND, METH_UNLINK, METH_UPDATEREDIRECTREF, METH__WEBDAV_LOW=1000, // All WebDAV related methods go after this. - METH_PROPFIND, METH_PROPPATCH, METH_MKCOL, METH_COPY, METH_MOVE, - METH_LOCK, METH_UNLOCK, METH_SEARCH, METH_BCOPY, METH_BDELETE, - METH_BMOVE, METH_BPROPFIND, METH_BPROPPATCH, METH_NOTIFY, METH_POLL, - METH_SUBSCRIBE, METH_UNSUBSCRIBE, METH_X_MS_ENUMATTS, - METH__WEBDAV_HIGH // All WebDAV related methods go before this. + METH_PROPFIND, METH_PROPPATCH, METH_MKCOL, METH_COPY, METH_MOVE, + METH_LOCK, METH_UNLOCK, METH_SEARCH, METH_BCOPY, METH_BDELETE, + METH_BMOVE, METH_BPROPFIND, METH_BPROPPATCH, METH_NOTIFY, METH_POLL, + METH_SUBSCRIBE, METH_UNSUBSCRIBE, METH_X_MS_ENUMATTS, + METH__WEBDAV_HIGH // All WebDAV related methods go before this. }; // URI formats diff --git a/src/sfip/sf_ip.h b/src/sfip/sf_ip.h index 39442f3b8..a38bf6718 100644 --- a/src/sfip/sf_ip.h +++ b/src/sfip/sf_ip.h @@ -76,7 +76,7 @@ struct SO_PUBLIC SfIp /* Returns true if the IPv6 address appears mapped. */ bool is_mapped() const; bool is_loopback() const; - bool is_private() const; + bool is_private() const; const char* ntop(char* buf, int bufsize) const; const char* ntoa() const; diff --git a/src/utils/util.cc b/src/utils/util.cc index 522512157..2f17b0edd 100644 --- a/src/utils/util.cc +++ b/src/utils/util.cc @@ -495,7 +495,7 @@ std::string read_infile(const char* key, const char* fname) else { ParseError("can't open file %s = %s: %s", key, fname, get_error(errno)); - return ""; + return ""; } return line; diff --git a/src/utils/util_cstring.cc b/src/utils/util_cstring.cc index 47b156d7c..d47cdf45b 100644 --- a/src/utils/util_cstring.cc +++ b/src/utils/util_cstring.cc @@ -340,4 +340,5 @@ int safe_snprintf(char* s, size_t n, const char* format, ... ) len = 0; return len; -} \ No newline at end of file +} + diff --git a/tools/snort2lua/helpers/parse_cmd_line.cc b/tools/snort2lua/helpers/parse_cmd_line.cc index 80c20e392..38bf01107 100644 --- a/tools/snort2lua/helpers/parse_cmd_line.cc +++ b/tools/snort2lua/helpers/parse_cmd_line.cc @@ -72,7 +72,6 @@ const std::string get_rule_file() { return rule_file.empty() ? get_out_file() : rule_file; } static void help_args(const char* pfx, const char* /*val*/); -static void print_args(const char* pfx, const char* /*val*/); //------------------------------------------------------------------------- // arg foo @@ -171,7 +170,7 @@ bool ArgList::get_arg(const char*& key, const char*& val) return false; } -static void help_usage() +[[noreturn]] static void help_usage() { std::cout << "usage:\n"; std::cout << " -?: list options\n"; @@ -283,14 +282,14 @@ static void print_version(const char* /*key*/, const char* /*val*/) } #ifdef REG_TEST -static void print_binder_order(const char* /*key*/, const char* /*val*/) +[[noreturn]] static void print_binder_order(const char* /*key*/, const char* /*val*/) { print_binder_priorities(); exit(0); } #endif -static void help(const char* key, const char* val) +[[noreturn]] static void help(const char* key, const char* val) { std::cout << Markup::head(3) << "Usage: snort2lua [OPTIONS]... -c ...\n"; std::cout << "\n"; @@ -319,7 +318,7 @@ static void help(const char* key, const char* val) exit(0); } -static void print_args(const char* key, const char* val) +[[noreturn]] static void print_args(const char* key, const char* val) { help_args(key, val); exit(0);