From: Victor Julien Date: Tue, 23 Oct 2018 11:21:08 +0000 (+0200) Subject: rust/dns: don't compile unused C code if Rust is enabled X-Git-Tag: suricata-4.0.6~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6eba849068bc36e77aae1a0be2a4be1c8c29ff8b;p=thirdparty%2Fsuricata.git rust/dns: don't compile unused C code if Rust is enabled --- diff --git a/src/app-layer-dns-tcp.c b/src/app-layer-dns-tcp.c index 7098b540af..bcd39b3c23 100644 --- a/src/app-layer-dns-tcp.c +++ b/src/app-layer-dns-tcp.c @@ -51,6 +51,7 @@ #include "app-layer-dns-tcp-rust.h" #endif +#ifndef HAVE_RUST struct DNSTcpHeader_ { uint16_t len; uint16_t tx_id; @@ -693,14 +694,15 @@ static uint16_t DNSTcpProbeResponse(uint8_t *input, uint32_t len, return ALPROTO_DNS; } +#endif /* HAVE_RUST */ void RegisterDNSTCPParsers(void) { - const char *proto_name = "dns"; #ifdef HAVE_RUST RegisterRustDNSTCPParsers(); return; -#endif +#else + const char *proto_name = "dns"; /** DNS */ if (AppLayerProtoDetectConfProtoDetectionEnabled("tcp", proto_name)) { AppLayerProtoDetectRegisterProtocol(ALPROTO_DNS, proto_name); @@ -769,16 +771,16 @@ void RegisterDNSTCPParsers(void) SCLogInfo("Parsed disabled for %s protocol. Protocol detection" "still on.", proto_name); } - #ifdef UNITTESTS AppLayerParserRegisterProtocolUnittests(IPPROTO_TCP, ALPROTO_DNS, DNSTCPParserRegisterTests); #endif - return; +#endif /* HAVE_RUST */ } /* UNITTESTS */ +#ifndef HAVE_RUST #ifdef UNITTESTS #include "util-unittest-helper.h" @@ -898,3 +900,4 @@ void DNSTCPParserRegisterTests(void) } #endif /* UNITTESTS */ +#endif /* HAVE_RUST */ diff --git a/src/app-layer-dns-udp.c b/src/app-layer-dns-udp.c index 29a89b4955..3cbf451240 100644 --- a/src/app-layer-dns-udp.c +++ b/src/app-layer-dns-udp.c @@ -54,6 +54,7 @@ #include "app-layer-dns-udp-rust.h" #endif +#ifndef HAVE_RUST /** \internal * \brief Parse DNS request packet */ @@ -384,15 +385,14 @@ static void DNSUDPConfigure(void) SCLogConfig("DNS global memcap: %"PRIu64, global_memcap); DNSConfigSetGlobalMemcap(global_memcap); } +#endif /* HAVE_RUST */ void RegisterDNSUDPParsers(void) { - const char *proto_name = "dns"; - #ifdef HAVE_RUST return RegisterRustDNSUDPParsers(); -#endif - +#else + const char *proto_name = "dns"; /** DNS */ if (AppLayerProtoDetectConfProtoDetectionEnabled("udp", proto_name)) { AppLayerProtoDetectRegisterProtocol(ALPROTO_DNS, proto_name); @@ -465,9 +465,11 @@ void RegisterDNSUDPParsers(void) #ifdef UNITTESTS AppLayerParserRegisterProtocolUnittests(IPPROTO_UDP, ALPROTO_DNS, DNSUDPParserRegisterTests); #endif +#endif /* HAVE_RUST */ } /* UNITTESTS */ +#ifndef HAVE_RUST #ifdef UNITTESTS #include "util-unittest-helper.h" @@ -867,3 +869,4 @@ void DNSUDPParserRegisterTests(void) DNSUDPParserTestLostResponse); } #endif +#endif /* HAVE_RUST */ diff --git a/src/util-lua-dns.c b/src/util-lua-dns.c index c1fe6533c0..c825ba00df 100644 --- a/src/util-lua-dns.c +++ b/src/util-lua-dns.c @@ -96,8 +96,8 @@ static int DnsGetDnsRrname(lua_State *luastate) return ret; } } -#endif return LuaCallbackError(luastate, "no query"); +#endif } static int DnsGetTxid(lua_State *luastate)