From 0e7c9af4431f993280d5b369f4e6827d4018f89d Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Tue, 9 Oct 2012 17:22:42 +0200 Subject: [PATCH] Fix/suppress a couple of harmless compiler warnings. --- src/alert-debuglog.c | 4 ++-- src/detect-filemd5.c | 24 ++++++++++++------------ src/log-httplog.c | 2 +- src/util-buffer.h | 6 +++--- src/util-host-os-info.c | 32 ++++++++++++++++---------------- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/alert-debuglog.c b/src/alert-debuglog.c index 92f5cbad0f..2d1fc865ba 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 afc184fb64..03a4a1b1d4 100644 --- a/src/detect-filemd5.c +++ b/src/detect-filemd5.c @@ -143,18 +143,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 * @@ -351,6 +339,18 @@ 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 aeeea50fc1..59bb20d3bf 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -327,7 +327,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)