From 321fb6463e0e8e6cf20c53dfdc28f83fc1b7e7de Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Thu, 20 Oct 2016 14:21:53 +0200 Subject: [PATCH] vars: small cleanups --- src/detect.c | 2 +- src/util-var-name.c | 7 +++---- src/util-var-name.h | 6 ++++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/detect.c b/src/detect.c index cd0d226d03..6c1c907798 100644 --- a/src/detect.c +++ b/src/detect.c @@ -876,7 +876,7 @@ static void AlertDebugLogModeSyncFlowbitsNamesToPacketStruct(Packet *p, DetectEn } FlowBit *fb = (FlowBit *) gv; - char *name = VariableIdxGetName(de_ctx, fb->idx, VAR_TYPE_FLOW_BIT); + const char *name = VariableIdxGetName(de_ctx, fb->idx, VAR_TYPE_FLOW_BIT); if (name != NULL) { p->debuglog_flowbits_names[i] = SCStrdup(name); if (p->debuglog_flowbits_names[i] == NULL) { diff --git a/src/util-var-name.c b/src/util-var-name.c index 9132218978..73f87d3dad 100644 --- a/src/util-var-name.c +++ b/src/util-var-name.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2007-2010 Open Information Security Foundation +/* Copyright (C) 2007-2016 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -31,7 +31,6 @@ typedef struct VariableName_ { char *name; uint8_t type; /* flowbit, pktvar, etc */ - uint8_t flags; uint16_t idx; } VariableName; @@ -135,7 +134,7 @@ void VariableNameFreeHash(DetectEngineCtx *de_ctx) * \retval 0 in case of error * \retval idx the idx or 0 */ -uint16_t VariableNameGetIdx(DetectEngineCtx *de_ctx, char *name, enum VarTypes type) +uint16_t VariableNameGetIdx(DetectEngineCtx *de_ctx, const char *name, enum VarTypes type) { uint16_t idx = 0; @@ -174,7 +173,7 @@ error: * \retval NULL in case of error * \retval name of the variable if successful. */ -char *VariableIdxGetName(DetectEngineCtx *de_ctx, uint16_t idx, enum VarTypes type) +const char *VariableIdxGetName(DetectEngineCtx *de_ctx, uint16_t idx, enum VarTypes type) { VariableName *fn = SCMalloc(sizeof(VariableName)); if (unlikely(fn == NULL)) diff --git a/src/util-var-name.h b/src/util-var-name.h index 2be142689a..7d2c527a31 100644 --- a/src/util-var-name.h +++ b/src/util-var-name.h @@ -27,8 +27,10 @@ int VariableNameInitHash(DetectEngineCtx *); void VariableNameFreeHash(DetectEngineCtx *); -uint16_t VariableNameGetIdx(DetectEngineCtx *, char *, enum VarTypes); -char * VariableIdxGetName(DetectEngineCtx *, uint16_t , enum VarTypes); +uint16_t VariableNameGetIdx(DetectEngineCtx *, + const char *name, enum VarTypes type); +const char *VariableIdxGetName(DetectEngineCtx *, + uint16_t id, enum VarTypes type); #endif