From 1bd6340d364d29aa870e28dd456da1e74b494c9c Mon Sep 17 00:00:00 2001 From: Rainer Gerhards Date: Mon, 7 May 2018 12:31:56 +0200 Subject: [PATCH] change API to use const char where appropriate NOTE: this requires changes to ALL existing clients! closes https://github.com/rsyslog/librelp/issues/86 --- configure.ac | 2 +- src/librelp.h | 2 +- src/relp.c | 2 +- src/relp.h | 16 ++++++++-------- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/configure.ac b/configure.ac index bf402f54..933cf0b0 100644 --- a/configure.ac +++ b/configure.ac @@ -71,7 +71,7 @@ then m4_ifdef([AX_IS_RELEASE], [ AX_IS_RELEASE([git-directory]) m4_ifdef([AX_COMPILER_FLAGS], [ - AX_COMPILER_FLAGS(,,,,[-pedantic -Wunused-parameter -Wmissing-field-initializers]) + AX_COMPILER_FLAGS(,,,,[-pedantic -Wwrite-strings -Wunused-parameter -Wmissing-field-initializers]) # unfortunately, AX_COMPILER_FLAGS does not provide a way to override # the default -Wno-error=warning" flags. So we do this via sed below. # Note: we *really* want to have this error out during CI testing! diff --git a/src/librelp.h b/src/librelp.h index 6d5794c8..0f2e85e4 100644 --- a/src/librelp.h +++ b/src/librelp.h @@ -192,7 +192,7 @@ relpRetVal relpEngineSetDnsLookupMode(relpEngine_t *pThis, int iMode); relpRetVal relpEngineSetOnAuthErr(relpEngine_t *pThis, void (*pCB)(void*pUsr, char *authinfo, char*errmsg, relpRetVal errcode) ); relpRetVal relpEngineSetOnErr(relpEngine_t *pThis, - void (*pCB)(void*pUsr, char *objinfo, char*errmsg, relpRetVal errcode) ); + void (*pCB)(void*pUsr, const char *objinfo, char*errmsg, relpRetVal errcode) ); relpRetVal relpEngineSetOnGenericErr(relpEngine_t *pThis, void (*pCB)(char *objinfo, char*errmsg, relpRetVal errcode) ); diff --git a/src/relp.c b/src/relp.c index 8207e910..d7b93765 100644 --- a/src/relp.c +++ b/src/relp.c @@ -436,7 +436,7 @@ relpEngineSetOnAuthErr(relpEngine_t *pThis, void (*pCB)(void*pUsr, char *authinf * errcode - contains librelp error status */ relpRetVal -relpEngineSetOnErr(relpEngine_t *pThis, void (*pCB)(void*pUsr, char *objinfo, char*errmsg, relpRetVal errcode) ) +relpEngineSetOnErr(relpEngine_t *pThis, void (*pCB)(void*pUsr, const char *objinfo, char*errmsg, relpRetVal errcode) ) { ENTER_RELPFUNC; RELPOBJ_assert(pThis, Engine); diff --git a/src/relp.h b/src/relp.h index 48520f67..969f39c9 100644 --- a/src/relp.h +++ b/src/relp.h @@ -127,14 +127,14 @@ typedef struct relpEngSessLst_s { */ struct relpEngine_s { BEGIN_RELP_OBJ; - void (*dbgprint)(char *fmt, ...) __attribute__((format(printf, 1, 2))); - relpRetVal (*onSyslogRcv)(unsigned char*pHostname, unsigned char *pIP, - unsigned char *pMsg, size_t lenMsg); /**< callback for "syslog" cmd */ - relpRetVal (*onSyslogRcv2)(void*, unsigned char*pHostname, unsigned char *pIP, - unsigned char *pMsg, size_t lenMsg); /**< callback for "syslog" cmd */ - void (*onAuthErr)(void*pUsr, char *authinfo, char*errmsg, relpRetVal errcode); - void (*onErr)(void*pUsr, char *objinfo, char*errmsg, relpRetVal errcode); - void (*onGenericErr)(char *objinfo, char*errmsg, relpRetVal errcode); + void (*dbgprint)(const char *fmt, ...) __attribute__((format(printf, 1, 2))); + relpRetVal (*onSyslogRcv)(unsigned const char*pHostname, unsigned const char *pIP, + unsigned const char *pMsg, size_t lenMsg); /**< callback for "syslog" cmd */ + relpRetVal (*onSyslogRcv2)(void*, unsigned const char*pHostname, unsigned const char *pIP, + unsigned const char *pMsg, size_t lenMsg); /**< callback for "syslog" cmd */ + void (*onAuthErr)(void*pUsr, const char *authinfo, const char*errmsg, relpRetVal errcode); + void (*onErr)(void*pUsr, const char *objinfo, const char*errmsg, relpRetVal errcode); + void (*onGenericErr)(const char *objinfo, const char*errmsg, relpRetVal errcode); int protocolVersion; /**< version of the relp protocol supported by this engine */ /* Flags */