From: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
As far as I can tell, the name, logfile and helptext strings passed to
pmdaDaemon() should never be modified in place. However, they're declared
as char *, rather than const char *.
This patch changes the signature, and propagates the necessary changes
through to __pmdaSetup() and the pmdaExt structure.
Signed-off-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
---
src/include/pcp/pmda.h | 9 +++++----
src/libpcp_pmda/src/open.c | 6 +++---
2 files changed, 8 insertions(+), 7 deletions(-)
Hi, haven't contributed to PCP before, testing the waters with this
pretty trivial cleanup. I encountered this while trying to write a
PMDA in C++ - that gives warnings when attempting to pass string
literals into these (char *) parameters.
diff --git a/src/include/pcp/pmda.h b/src/include/pcp/pmda.h
index 61b6db9..a211448 100644
--- a/src/include/pcp/pmda.h
+++ b/src/include/pcp/pmda.h
@@ -123,9 +123,9 @@ typedef struct pmdaExt {
void *e_ext; /* used internally within libpcp_pmda */
char *e_sockname; /* socket name to pmcd */
- char *e_name; /* name of this pmda */
- char *e_logfile; /* path to log file */
- char *e_helptext; /* path to help text */
+ const char *e_name; /* name of this pmda */
+ const char *e_logfile; /* path to log file */
+ const char *e_helptext; /* path to help text */
int e_status; /* =0 is OK */
int e_infd; /* input file descriptor from pmcd */
int e_outfd; /* output file descriptor to pmcd */
@@ -424,7 +424,8 @@ typedef struct pmdaOptions {
PMDA_CALL extern int pmdaGetOpt(int, char *const *, const char *,
pmdaInterface *, int *);
PMDA_CALL extern int pmdaGetOptions(int, char *const *, pmdaOptions *,
pmdaInterface *);
PMDA_CALL extern void pmdaUsageMessage(pmdaOptions *);
-PMDA_CALL extern void pmdaDaemon(pmdaInterface *, int, char *, int , char *,
char *);
+PMDA_CALL extern void pmdaDaemon(pmdaInterface *, int, const char *, int,
+ const char *, const char *);
PMDA_CALL extern void pmdaDSO(pmdaInterface *, int, char *, char *);
PMDA_CALL extern void pmdaOpenLog(pmdaInterface *);
PMDA_CALL extern void pmdaSetFlags(pmdaInterface *, int);
diff --git a/src/libpcp_pmda/src/open.c b/src/libpcp_pmda/src/open.c
index 02f771a..8896a9a 100644
--- a/src/libpcp_pmda/src/open.c
+++ b/src/libpcp_pmda/src/open.c
@@ -899,7 +899,7 @@ pmdaConnect(pmdaInterface *dispatch)
*/
static void
-__pmdaSetup(pmdaInterface *dispatch, int version, char *name)
+__pmdaSetup(pmdaInterface *dispatch, int version, const char *name)
{
pmdaExt *pmda = NULL;
e_ext_t *extp;
@@ -980,8 +980,8 @@ __pmdaSetup(pmdaInterface *dispatch, int version, char
*name)
*/
void
-pmdaDaemon(pmdaInterface *dispatch, int version, char *name, int domain,
- char *logfile, char *helptext)
+pmdaDaemon(pmdaInterface *dispatch, int version, const char *name, int domain,
+ const char *logfile, const char *helptext)
{
pmdaExt *pmda;
--
2.1.4
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
signature.asc
Description: PGP signature
|