From: Victor Julien Date: Tue, 9 Oct 2012 15:22:42 +0000 (+0200) Subject: Fix/suppress a couple of harmless compiler warnings. X-Git-Tag: suricata-1.4beta3~91 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d68fd54a763a2633bf920b70688dc2a019833076;p=thirdparty%2Fsuricata.git Fix/suppress a couple of harmless compiler warnings. --- diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index af2eb2da62..b4708f0869 100644 --- a/src/alert-debuglog.c +++ b/src/alert-debuglog.c @@ -342,7 +342,7 @@ TmEcode AlertDebugLogger(ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, } SCMutexLock(&aft->file_ctx->fp_mutex); - MemBufferPrintToFPAsString(aft->buffer, aft->file_ctx->fp); + (void)MemBufferPrintToFPAsString(aft->buffer, aft->file_ctx->fp); fflush(aft->file_ctx->fp); aft->file_ctx->alerts += p->alerts.cnt; SCMutexUnlock(&aft->file_ctx->fp_mutex); @@ -402,7 +402,7 @@ TmEcode AlertDebugLogDecoderEvent(ThreadVars *tv, Packet *p, void *data, PacketQ GET_PKT_DATA(p), GET_PKT_LEN(p)); SCMutexLock(&aft->file_ctx->fp_mutex); - MemBufferPrintToFPAsString(aft->buffer, aft->file_ctx->fp); + (void)MemBufferPrintToFPAsString(aft->buffer, aft->file_ctx->fp); fflush(aft->file_ctx->fp); aft->file_ctx->alerts += p->alerts.cnt; SCMutexUnlock(&aft->file_ctx->fp_mutex); diff --git a/src/detect-filemd5.c b/src/detect-filemd5.c index 27c9ee3d1f..6bb9d03257 100644 --- a/src/detect-filemd5.c +++ b/src/detect-filemd5.c @@ -142,18 +142,6 @@ static int MD5MatchLookupBuffer(ROHashTable *hash, uint8_t *buf, size_t buflen) return 1; } -static int MD5MatchLookupString(ROHashTable *hash, char *string) { - uint8_t md5[16]; - if (Md5ReadString(md5, string) == 1) { - void *ptr = ROHashLookup(hash, &md5, (uint16_t)sizeof(md5)); - if (ptr == NULL) - return 0; - else - return 1; - } - return 0; -} - /** * \brief match the specified filemd5 * @@ -352,6 +340,18 @@ static void DetectFileMd5Free(void *ptr) { } #ifdef UNITTESTS +static int MD5MatchLookupString(ROHashTable *hash, char *string) { + uint8_t md5[16]; + if (Md5ReadString(md5, string) == 1) { + void *ptr = ROHashLookup(hash, &md5, (uint16_t)sizeof(md5)); + if (ptr == NULL) + return 0; + else + return 1; + } + return 0; +} + static int MD5MatchTest01(void) { ROHashTable *hash = ROHashInit(4, 16); if (hash == NULL) { diff --git a/src/log-httplog.c b/src/log-httplog.c index 15ff9e2caf..4a83f57b3a 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -523,7 +523,7 @@ static TmEcode LogHttpLogIPWrapper(ThreadVars *tv, Packet *p, void *data, Packet aft->uri_cnt ++; SCMutexLock(&hlog->file_ctx->fp_mutex); - MemBufferPrintToFPAsString(aft->buffer, hlog->file_ctx->fp); + (void)MemBufferPrintToFPAsString(aft->buffer, hlog->file_ctx->fp); fflush(hlog->file_ctx->fp); SCMutexUnlock(&hlog->file_ctx->fp_mutex); diff --git a/src/util-buffer.h b/src/util-buffer.h index 9c4813688c..0ab4583a32 100644 --- a/src/util-buffer.h +++ b/src/util-buffer.h @@ -74,9 +74,9 @@ void MemBufferFree(MemBuffer *buffer); * \param buffer Pointer to the src MemBuffer instance to write. * \param fp Pointer to the file file instance to write to. */ -#define MemBufferPrintToFPAsString(mem_buffer, fp) do { \ - fwrite((mem_buffer)->buffer, sizeof(uint8_t), (mem_buffer)->offset, fp); \ - } while (0) +#define MemBufferPrintToFPAsString(mem_buffer, fp) ({ \ + fwrite((mem_buffer)->buffer, sizeof(uint8_t), (mem_buffer)->offset, fp); \ +}) /** * \brief Write a buffer in hex format. diff --git a/src/util-host-os-info.c b/src/util-host-os-info.c index d692f5df03..fb34314048 100644 --- a/src/util-host-os-info.c +++ b/src/util-host-os-info.c @@ -60,22 +60,6 @@ SCEnumCharMap sc_hinfo_os_policy_map[ ] = { static SCRadixTree *sc_hinfo_tree = NULL; static SCRadixTree *sc_hinfo_tree_backup = NULL; -static void SCHInfoCreateContextBackup(void) -{ - sc_hinfo_tree_backup = sc_hinfo_tree; - sc_hinfo_tree = NULL; - - return; -} - -static void SCHInfoRestoreContextBackup(void) -{ - sc_hinfo_tree = sc_hinfo_tree_backup; - sc_hinfo_tree_backup = NULL; - - return; -} - /** * \brief Validates an IPV4 address and returns the network endian arranged * version of the IPV4 address @@ -448,6 +432,22 @@ void SCHInfoLoadFromConfig(void) #ifdef UNITTESTS +static void SCHInfoCreateContextBackup(void) +{ + sc_hinfo_tree_backup = sc_hinfo_tree; + sc_hinfo_tree = NULL; + + return; +} + +static void SCHInfoRestoreContextBackup(void) +{ + sc_hinfo_tree = sc_hinfo_tree_backup; + sc_hinfo_tree_backup = NULL; + + return; +} + /** * \test Check if we the IPs with the right OS flavours are added to the host OS * radix tree, and the IPS with invalid flavours returns an error(-1)