From 3972f476e00f27d41a0aeabcb66600905b6737bd Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 13 Sep 2016 20:44:59 +0200 Subject: [PATCH] core: Do not pass const char* to functions taking a char*. Signed-off-by: Werner Koch --- src/argparse.c | 3 ++- src/engine-gpg.c | 6 +++++- src/engine-gpgsm.c | 7 +++++-- src/engine-uiserver.c | 7 +++++-- src/gpgme-tool.c | 5 +++-- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/argparse.c b/src/argparse.c index b6abf86b..003334f9 100644 --- a/src/argparse.c +++ b/src/argparse.c @@ -895,6 +895,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts) char **argv; char *s, *s2; int i; + char string_with_x[] = "x"; initialize( arg, NULL, NULL ); argc = *arg->argc; @@ -1106,7 +1107,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts) argc--; argv++; idx++; /* Skip one. */ } } - s = "x"; /* This is so that !s[1] yields false. */ + s = string_with_x; /* This is so that !s[1] yields false. */ } else { diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 289578b0..c528d051 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -1081,7 +1081,11 @@ read_status (engine_gpg_t gpg) err = gpg->status.mon_cb (gpg->status.mon_cb_value, GPGME_STATUS_EOF, ""); if (gpg->status.fnc) - err = gpg->status.fnc (gpg->status.fnc_value, GPGME_STATUS_EOF, ""); + { + char emptystring[1] = {0}; + err = gpg->status.fnc (gpg->status.fnc_value, + GPGME_STATUS_EOF, emptystring); + } return err; } diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 3f3230bb..81e8fab0 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -818,8 +818,11 @@ status_handler (void *opaque, int fd) && (line[2] == '\0' || line[2] == ' ')) { if (gpgsm->status.fnc) - err = gpgsm->status.fnc (gpgsm->status.fnc_value, - GPGME_STATUS_EOF, ""); + { + char emptystring[1] = {0}; + err = gpgsm->status.fnc (gpgsm->status.fnc_value, + GPGME_STATUS_EOF, emptystring); + } if (!err && gpgsm->colon.fnc && gpgsm->colon.any) { diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c index de12f2b1..2ed78255 100644 --- a/src/engine-uiserver.c +++ b/src/engine-uiserver.c @@ -669,8 +669,11 @@ status_handler (void *opaque, int fd) && (line[2] == '\0' || line[2] == ' ')) { if (uiserver->status.fnc) - err = uiserver->status.fnc (uiserver->status.fnc_value, - GPGME_STATUS_EOF, ""); + { + char emptystring[1] = {0}; + err = uiserver->status.fnc (uiserver->status.fnc_value, + GPGME_STATUS_EOF, emptystring); + } if (!err && uiserver->colon.fnc && uiserver->colon.any) { diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c index 5ad5b256..ec85039b 100644 --- a/src/gpgme-tool.c +++ b/src/gpgme-tool.c @@ -337,13 +337,14 @@ result_xml_indent (struct result_xml_state *state) gpg_error_t -result_xml_tag_start (struct result_xml_state *state, char *name, ...) +result_xml_tag_start (struct result_xml_state *state, const char *name, ...) { result_xml_write_cb_t cb = state->cb; void *hook = state->hook; va_list ap; char *attr; char *attr_val; + char string_null[] = "(null)"; va_start (ap, name); @@ -374,7 +375,7 @@ result_xml_tag_start (struct result_xml_state *state, char *name, ...) attr_val = va_arg (ap, char *); if (attr_val == NULL) - attr_val = "(null)"; + attr_val = string_null; (*cb) (hook, " ", 1); (*cb) (hook, attr, strlen (attr));