From 51f9acbca935c5287d9a28205037b0923e9a65f5 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Tue, 13 Sep 2016 20:59:07 +0200 Subject: [PATCH] core: Use const char * where appropriate. Signed-off-by: Werner Koch --- src/engine-assuan.c | 2 +- src/engine-g13.c | 4 ++-- src/engine-gpg.c | 2 ++ src/engine-gpgsm.c | 9 ++++++--- src/engine-uiserver.c | 7 ++++--- src/gpgme-tool.c | 32 ++++++++++++++++++-------------- src/posix-io.c | 2 +- src/version.c | 2 +- 8 files changed, 35 insertions(+), 25 deletions(-) diff --git a/src/engine-assuan.c b/src/engine-assuan.c index 1f48173f..5f0ea06d 100644 --- a/src/engine-assuan.c +++ b/src/engine-assuan.c @@ -359,7 +359,7 @@ llass_set_locale (void *engine, int category, const char *value) gpgme_error_t err; engine_llass_t llass = engine; char *optstr; - char *catstr; + const char *catstr; if (!llass->opt.gpg_agent) return 0; diff --git a/src/engine-g13.c b/src/engine-g13.c index ce98b1bd..7f225eb2 100644 --- a/src/engine-g13.c +++ b/src/engine-g13.c @@ -356,7 +356,7 @@ g13_set_locale (void *engine, int category, const char *value) engine_g13_t g13 = engine; gpgme_error_t err; char *optstr; - char *catstr; + const char *catstr; /* FIXME: If value is NULL, we need to reset the option to default. But we can't do this. So we error out here. G13 needs support @@ -405,7 +405,7 @@ g13_set_locale (void *engine, int category, const char *value) #if USE_DESCRIPTOR_PASSING static gpgme_error_t -g13_assuan_simple_command (assuan_context_t ctx, char *cmd, +g13_assuan_simple_command (assuan_context_t ctx, const char *cmd, engine_status_handler_t status_fnc, void *status_fnc_value) { diff --git a/src/engine-gpg.c b/src/engine-gpg.c index 7270e362..f22d8b44 100644 --- a/src/engine-gpg.c +++ b/src/engine-gpg.c @@ -1574,6 +1574,8 @@ gpg_passwd (void *engine, gpgme_key_t key, unsigned int flags) engine_gpg_t gpg = engine; gpgme_error_t err; + (void)flags; + if (!key || !key->subkeys || !key->subkeys->fpr) return gpg_error (GPG_ERR_INV_CERT_OBJ); diff --git a/src/engine-gpgsm.c b/src/engine-gpgsm.c index 1cf50467..0610c7a7 100644 --- a/src/engine-gpgsm.c +++ b/src/engine-gpgsm.c @@ -517,7 +517,7 @@ gpgsm_set_locale (void *engine, int category, const char *value) engine_gpgsm_t gpgsm = engine; gpgme_error_t err; char *optstr; - char *catstr; + const char *catstr; /* FIXME: If value is NULL, we need to reset the option to default. But we can't do this. So we error out here. GPGSM needs support @@ -565,7 +565,7 @@ gpgsm_set_locale (void *engine, int category, const char *value) static gpgme_error_t -gpgsm_assuan_simple_command (engine_gpgsm_t gpgsm, char *cmd, +gpgsm_assuan_simple_command (engine_gpgsm_t gpgsm, const char *cmd, engine_status_handler_t status_fnc, void *status_fnc_value) { @@ -674,7 +674,7 @@ gpgsm_set_fd (engine_gpgsm_t gpgsm, fd_type_t fd_type, const char *opt) { gpg_error_t err = 0; char line[COMMANDLINELEN]; - char *which; + const char *which; iocb_data_t *iocb_data; #if USE_DESCRIPTOR_PASSING int dir; @@ -1480,6 +1480,7 @@ gpgsm_genkey (void *engine, } (void)userid; + (void)algo; (void)expires; (void)key; (void)flags; @@ -2017,6 +2018,8 @@ gpgsm_passwd (void *engine, gpgme_key_t key, unsigned int flags) gpgme_error_t err; char *line; + (void)flags; + if (!key || !key->subkeys || !key->subkeys->fpr) return gpg_error (GPG_ERR_INV_CERT_OBJ); diff --git a/src/engine-uiserver.c b/src/engine-uiserver.c index 215dbe39..2817527f 100644 --- a/src/engine-uiserver.c +++ b/src/engine-uiserver.c @@ -251,6 +251,7 @@ uiserver_new (void **engine, const char *file_name, const char *home_dir, char *dft_ttytype = NULL; char *optstr; + (void)home_dir; (void)version; /* Not yet used. */ uiserver = calloc (1, sizeof *uiserver); @@ -400,7 +401,7 @@ uiserver_set_locale (void *engine, int category, const char *value) engine_uiserver_t uiserver = engine; gpgme_error_t err; char *optstr; - char *catstr; + const char *catstr; /* FIXME: If value is NULL, we need to reset the option to default. But we can't do this. So we error out here. UISERVER needs support @@ -459,7 +460,7 @@ uiserver_set_protocol (void *engine, gpgme_protocol_t protocol) static gpgme_error_t -uiserver_assuan_simple_command (engine_uiserver_t uiserver, char *cmd, +uiserver_assuan_simple_command (engine_uiserver_t uiserver, const char *cmd, engine_status_handler_t status_fnc, void *status_fnc_value) { @@ -534,7 +535,7 @@ uiserver_set_fd (engine_uiserver_t uiserver, fd_type_t fd_type, const char *opt) { gpg_error_t err = 0; char line[COMMANDLINELEN]; - char *which; + const char *which; iocb_data_t *iocb_data; int dir; diff --git a/src/gpgme-tool.c b/src/gpgme-tool.c index 80d7d725..fb158f13 100644 --- a/src/gpgme-tool.c +++ b/src/gpgme-tool.c @@ -202,7 +202,7 @@ peek_membuf (membuf_t *mb, size_t *len) /* SUPPORT. */ FILE *log_stream; -char *program_name = "gpgme-tool"; +char program_name[] = "gpgme-tool"; #define spacep(p) (*(p) == ' ' || *(p) == '\t') @@ -308,7 +308,7 @@ struct result_xml_state #define MAX_TAGS 20 int next_tag; - char *tag[MAX_TAGS]; + const char *tag[MAX_TAGS]; int had_data[MAX_TAGS]; }; @@ -492,7 +492,8 @@ result_xml_tag_end (struct result_xml_state *state) gpg_error_t -result_add_error (struct result_xml_state *state, char *name, gpg_error_t err) +result_add_error (struct result_xml_state *state, + const char *name, gpg_error_t err) { char code[20]; char msg[1024]; @@ -508,7 +509,7 @@ result_add_error (struct result_xml_state *state, char *name, gpg_error_t err) gpg_error_t result_add_pubkey_algo (struct result_xml_state *state, - char *name, gpgme_pubkey_algo_t algo) + const char *name, gpgme_pubkey_algo_t algo) { char code[20]; char msg[80]; @@ -524,10 +525,11 @@ result_add_pubkey_algo (struct result_xml_state *state, gpg_error_t result_add_hash_algo (struct result_xml_state *state, - char *name, gpgme_hash_algo_t algo) + const char *name, gpgme_hash_algo_t algo) { char code[20]; char msg[80]; + snprintf (code, sizeof (code) - 1, "0x%x", algo); snprintf (msg, sizeof (msg) - 1, "%s", gpgme_hash_algo_name (algo)); @@ -539,7 +541,8 @@ result_add_hash_algo (struct result_xml_state *state, gpg_error_t -result_add_keyid (struct result_xml_state *state, char *name, char *keyid) +result_add_keyid (struct result_xml_state *state, + const char *name, const char *keyid) { result_xml_tag_start (state, name, NULL); result_xml_tag_data (state, keyid); @@ -549,7 +552,8 @@ result_add_keyid (struct result_xml_state *state, char *name, char *keyid) gpg_error_t -result_add_fpr (struct result_xml_state *state, char *name, char *fpr) +result_add_fpr (struct result_xml_state *state, + const char *name, const char *fpr) { result_xml_tag_start (state, name, NULL); result_xml_tag_data (state, fpr); @@ -559,7 +563,7 @@ result_add_fpr (struct result_xml_state *state, char *name, char *fpr) gpg_error_t -result_add_timestamp (struct result_xml_state *state, char *name, +result_add_timestamp (struct result_xml_state *state, const char *name, unsigned int timestamp) { char code[20]; @@ -572,10 +576,10 @@ result_add_timestamp (struct result_xml_state *state, char *name, gpg_error_t -result_add_sig_mode (struct result_xml_state *state, char *name, +result_add_sig_mode (struct result_xml_state *state, const char *name, gpgme_sig_mode_t sig_mode) { - char *mode; + const char *mode; char code[20]; snprintf (code, sizeof (code) - 1, "%i", sig_mode); @@ -602,7 +606,7 @@ result_add_sig_mode (struct result_xml_state *state, char *name, gpg_error_t -result_add_protocol (struct result_xml_state *state, char *name, +result_add_protocol (struct result_xml_state *state, const char *name, gpgme_protocol_t protocol) { const char *str; @@ -620,7 +624,7 @@ result_add_protocol (struct result_xml_state *state, char *name, gpg_error_t -result_add_validity (struct result_xml_state *state, char *name, +result_add_validity (struct result_xml_state *state, const char *name, gpgme_validity_t validity) { const char *str; @@ -657,7 +661,7 @@ result_add_validity (struct result_xml_state *state, char *name, gpg_error_t result_add_value (struct result_xml_state *state, - char *name, unsigned int val) + const char *name, unsigned int val) { char code[20]; @@ -670,7 +674,7 @@ result_add_value (struct result_xml_state *state, gpg_error_t result_add_string (struct result_xml_state *state, - char *name, char *str) + const char *name, const char *str) { if (!str) str = ""; diff --git a/src/posix-io.c b/src/posix-io.c index 258e8ea5..c0b2f4fa 100644 --- a/src/posix-io.c +++ b/src/posix-io.c @@ -282,7 +282,7 @@ _gpgme_io_set_nonblocking (int fd) static long int get_max_fds (void) { - char *source = NULL; + const char *source = NULL; long int fds = -1; int rc; diff --git a/src/version.c b/src/version.c index a9bf7b80..8bc898ff 100644 --- a/src/version.c +++ b/src/version.c @@ -196,7 +196,7 @@ _gpgme_compare_versions (const char *my_version, const char * gpgme_check_version (const char *req_version) { - char *result; + const char *result; do_subsystem_inits (); /* Catch-22: We need to get at least the debug subsystem ready