From: Jason Ish Date: Mon, 11 Mar 2024 23:13:25 +0000 (-0600) Subject: eve/filetypes: use more const X-Git-Tag: suricata-8.0.0-beta1~1634 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3354e55e674213b6232df89a713f6d3c43e14a9;p=thirdparty%2Fsuricata.git eve/filetypes: use more const --- diff --git a/examples/plugins/c-json-filetype/filetype.c b/examples/plugins/c-json-filetype/filetype.c index e20697bcb4..a66b9779df 100644 --- a/examples/plugins/c-json-filetype/filetype.c +++ b/examples/plugins/c-json-filetype/filetype.c @@ -64,7 +64,7 @@ typedef struct Context_ { * configuration for the eve instance, not just a node named after the plugin. * This allows the plugin to get more context about what it is logging. */ -static int FiletypeInit(ConfNode *conf, bool threaded, void **data) +static int FiletypeInit(const ConfNode *conf, const bool threaded, void **data) { SCLogNotice("Initializing template eve output plugin: threaded=%d", threaded); Context *context = SCCalloc(1, sizeof(Context)); @@ -125,7 +125,7 @@ static void FiletypeDeinit(void *data) * In the case of non-threaded EVE logging this function is called * once with a thread_id of 0. */ -static int FiletypeThreadInit(void *ctx, ThreadId thread_id, void **thread_data) +static int FiletypeThreadInit(const void *ctx, const ThreadId thread_id, void **thread_data) { SCLogNotice("thread_id=%d", thread_id); ThreadData *tdata = SCCalloc(1, sizeof(ThreadData)); @@ -146,7 +146,7 @@ static int FiletypeThreadInit(void *ctx, ThreadId thread_id, void **thread_data) * This is where any cleanup per thread should be done including free'ing of the * thread_data if needed. */ -static void FiletypeThreadDeinit(void *ctx, void *thread_data) +static void FiletypeThreadDeinit(const void *ctx, void *thread_data) { SCLogNotice("thread_data=%p", thread_data); if (thread_data == NULL) { @@ -171,9 +171,10 @@ static void FiletypeThreadDeinit(void *ctx, void *thread_data) * to any resource that may block it might be best to enqueue the buffers for * further processing which will require copying of the provided buffer. */ -static int FiletypeWrite(const char *buffer, int buffer_len, void *data, void *thread_data) +static int FiletypeWrite( + const char *buffer, const int buffer_len, const void *data, void *thread_data) { - Context *ctx = data; + const Context *ctx = data; ThreadData *thread = thread_data; SCLogNotice("thread_id=%d, data=%p, thread_data=%p", thread->thread_id, data, thread_data); diff --git a/src/output-eve-null.c b/src/output-eve-null.c index 59e8c452fb..368836e783 100644 --- a/src/output-eve-null.c +++ b/src/output-eve-null.c @@ -37,24 +37,25 @@ void NullLogInitialize(void) #define OUTPUT_NAME "nullsink" -static int NullLogInit(ConfNode *conf, bool threaded, void **init_data) +static int NullLogInit(const ConfNode *conf, const bool threaded, void **init_data) { *init_data = NULL; return 0; } -static int NullLogWrite(const char *buffer, int buffer_len, void *init_data, void *thread_data) +static int NullLogWrite( + const char *buffer, const int buffer_len, const void *init_data, void *thread_data) { return 0; } -static int NullLogThreadInit(void *init_data, ThreadId thread_id, void **thread_data) +static int NullLogThreadInit(const void *init_data, const ThreadId thread_id, void **thread_data) { *thread_data = NULL; return 0; } -static void NullLogThreadDeInit(void *init_data, void *thread_data) +static void NullLogThreadDeInit(const void *init_data, void *thread_data) { } diff --git a/src/output-eve-syslog.c b/src/output-eve-syslog.c index 0787e4b750..4560bc73e3 100644 --- a/src/output-eve-syslog.c +++ b/src/output-eve-syslog.c @@ -41,7 +41,7 @@ typedef struct Context_ { int alert_syslog_level; } Context; -static int SyslogInit(ConfNode *conf, bool threaded, void **init_data) +static int SyslogInit(const ConfNode *conf, const bool threaded, void **init_data) { Context *context = SCCalloc(1, sizeof(Context)); if (context == NULL) { @@ -79,9 +79,10 @@ static int SyslogInit(ConfNode *conf, bool threaded, void **init_data) return 0; } -static int SyslogWrite(const char *buffer, int buffer_len, void *init_data, void *thread_data) +static int SyslogWrite( + const char *buffer, const int buffer_len, const void *init_data, void *thread_data) { - Context *context = init_data; + const Context *context = init_data; syslog(context->alert_syslog_level, "%s", (const char *)buffer); return 0; diff --git a/src/output-eve.h b/src/output-eve.h index 6ee0228a07..3b2637f64c 100644 --- a/src/output-eve.h +++ b/src/output-eve.h @@ -100,7 +100,7 @@ typedef struct SCEveFileType_ { * * \retval 0 on success, -1 on failure */ - int (*Init)(ConfNode *conf, bool threaded, void **init_data); + int (*Init)(const ConfNode *conf, const bool threaded, void **init_data); /** * \brief Called for each EVE log record. @@ -119,7 +119,8 @@ typedef struct SCEveFileType_ { * * \retval 0 on success, -1 on failure */ - int (*Write)(const char *buffer, int buffer_len, void *init_data, void *thread_data); + int (*Write)( + const char *buffer, const int buffer_len, const void *init_data, void *thread_data); /** * \brief Final call to deinitialize this filetype. @@ -150,7 +151,7 @@ typedef struct SCEveFileType_ { * * \retval 0 on success, -1 on failure */ - int (*ThreadInit)(void *init_data, ThreadId thread_id, void **thread_data); + int (*ThreadInit)(const void *init_data, const ThreadId thread_id, void **thread_data); /** * \brief Called to deinitialize each thread. @@ -162,7 +163,7 @@ typedef struct SCEveFileType_ { * * \param thread_data The data setup in ThreadInit */ - void (*ThreadDeinit)(void *init_data, void *thread_data); + void (*ThreadDeinit)(const void *init_data, void *thread_data); /* Internal list management. */ TAILQ_ENTRY(SCEveFileType_) entries;