From ce55d06569596930fa97d9e8d31c836e1b9ba31c Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Fri, 12 Jul 2019 16:26:28 +0200 Subject: [PATCH] check: Using const keyword for some arguments For ConfigSetLogDirectory and PrintRawLineHexBuf --- src/decode.c | 3 ++- src/util-conf.c | 2 +- src/util-conf.h | 2 +- src/util-print.c | 4 ++-- src/util-print.h | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/decode.c b/src/decode.c index 0b8ecd36c8..bb27295e73 100644 --- a/src/decode.c +++ b/src/decode.c @@ -657,7 +657,8 @@ inline int PacketSetData(Packet *p, const uint8_t *pktdata, uint32_t pktlen) if (unlikely(!pktdata)) { return -1; } - p->ext_pkt = (uint8_t *)pktdata; + // ext_pkt cannot be const (because we sometimes copy) + p->ext_pkt = (uint8_t *) pktdata; p->flags |= PKT_ZERO_COPY; return 0; diff --git a/src/util-conf.c b/src/util-conf.c index c3fb07ea41..f36bfbf088 100644 --- a/src/util-conf.c +++ b/src/util-conf.c @@ -28,7 +28,7 @@ #include "runmodes.h" #include "util-conf.h" -TmEcode ConfigSetLogDirectory(char *name) +TmEcode ConfigSetLogDirectory(const char *name) { return ConfSetFinal("default-log-dir", name) ? TM_ECODE_OK : TM_ECODE_FAILED; } diff --git a/src/util-conf.h b/src/util-conf.h index ddf9372c65..1006c850cf 100644 --- a/src/util-conf.h +++ b/src/util-conf.h @@ -27,7 +27,7 @@ #include "conf.h" -TmEcode ConfigSetLogDirectory(char *name); +TmEcode ConfigSetLogDirectory(const char *name); const char *ConfigGetLogDirectory(void); TmEcode ConfigCheckLogDirectoryExists(const char *log_dir); diff --git a/src/util-print.c b/src/util-print.c index c0d72f2d2d..f9db2cae1b 100644 --- a/src/util-print.c +++ b/src/util-print.c @@ -39,7 +39,7 @@ * \param buf buffer to print from * \param buflen length of the input buffer */ -void PrintBufferRawLineHex(char *nbuf, int *offset, int max_size, uint8_t *buf, uint32_t buflen) +void PrintBufferRawLineHex(char *nbuf, int *offset, int max_size, const uint8_t *buf, uint32_t buflen) { uint32_t u = 0; @@ -58,7 +58,7 @@ void PrintBufferRawLineHex(char *nbuf, int *offset, int max_size, uint8_t *buf, * \param buf buffer to print from * \param buflen length of the input buffer */ -void PrintRawLineHexBuf(char *retbuf, uint32_t retbuflen, uint8_t *buf, uint32_t buflen) +void PrintRawLineHexBuf(char *retbuf, uint32_t retbuflen, const uint8_t *buf, uint32_t buflen) { uint32_t offset = 0; uint32_t u = 0; diff --git a/src/util-print.h b/src/util-print.h index 5bad4f8385..6548f02197 100644 --- a/src/util-print.h +++ b/src/util-print.h @@ -41,7 +41,7 @@ } \ } while (0) -void PrintBufferRawLineHex(char *, int *,int, uint8_t *, uint32_t); +void PrintBufferRawLineHex(char *, int *,int, const uint8_t *, uint32_t); void PrintRawUriFp(FILE *, uint8_t *, uint32_t); void PrintRawUriBuf(char *, uint32_t *, uint32_t, uint8_t *, uint32_t); @@ -51,7 +51,7 @@ void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32 const uint8_t *src_buf, uint32_t src_buf_len); void PrintStringsToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, const uint32_t src_buf_len); -void PrintRawLineHexBuf(char *, uint32_t, uint8_t *, uint32_t ); +void PrintRawLineHexBuf(char *, uint32_t, const uint8_t *, uint32_t ); const char *PrintInet(int , const void *, char *, socklen_t); #endif /* __UTIL_PRINT_H__ */