From 82e1d1116794e91485353f73febfa54ab5cf28b7 Mon Sep 17 00:00:00 2001 From: Jennifer Richards Date: Mon, 7 May 2018 14:11:43 -0400 Subject: [PATCH] Miscellaneous minor code cleanup for MRW's review comments * Remove generation of DH in trmon.c, it's not needed * Check return value of mon_req_add_option() in a few places it had been ignored * Spell out "Trust Router" in trmon version/help description * Rename _decode -> _encode after a copy/paste * Fix a few incorrect comments describing file contents * Fix function name in debug messages in tr_cfg_parse_config_files() * Include glib.h instead of gmodule.h in a few files --- common/tr_config.c | 4 ++-- include/tr_config.h | 2 +- mon/mon_common.c | 2 +- mon/mon_req.c | 4 ++-- mon/mon_req_decode.c | 6 ++++-- mon/mon_req_encode.c | 6 +++--- mon/mon_resp.c | 2 +- mon/mon_resp_decode.c | 2 +- mon/mon_resp_encode.c | 2 ++ mon/mons_handlers.c | 2 +- tr/trmon_main.c | 24 +++++++++++------------- tr/trpc_main.c | 2 +- 12 files changed, 30 insertions(+), 28 deletions(-) diff --git a/common/tr_config.c b/common/tr_config.c index 8c0f577..2ddda12 100644 --- a/common/tr_config.c +++ b/common/tr_config.c @@ -310,13 +310,13 @@ static json_t **tr_cfg_parse_config_files(TALLOC_CTX *mem_ctx, unsigned int n_fi this_file->serial = get_cfg_serial(jcfgs[ii]); if (this_file->serial != TR_CFG_INVALID_SERIAL) { - tr_notice("tr_parse_one_config_file: Attempting to load revision %" + tr_notice("tr_parse_config_files: Attempting to load revision %" JSON_INTEGER_FORMAT " of '%s'.", this_file->serial, this_file->name); } else { - tr_notice("tr_parse_one_config_file: Attempting to load '%s'.", + tr_notice("tr_parse_config_files: Attempting to load '%s'.", this_file->name); } } diff --git a/include/tr_config.h b/include/tr_config.h index 30317de..8dc66c4 100644 --- a/include/tr_config.h +++ b/include/tr_config.h @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include diff --git a/mon/mon_common.c b/mon/mon_common.c index a237b5d..9a71af4 100644 --- a/mon/mon_common.c +++ b/mon/mon_common.c @@ -34,7 +34,7 @@ #include -#include +#include #include #include diff --git a/mon/mon_req.c b/mon/mon_req.c index bffa92e..e7cc43b 100644 --- a/mon/mon_req.c +++ b/mon/mon_req.c @@ -34,11 +34,11 @@ #include -#include +#include #include -// Monitoring request message common code +/* Monitoring request message common code */ /** * Destructor used by talloc to ensure proper cleanup diff --git a/mon/mon_req_decode.c b/mon/mon_req_decode.c index 21bb64b..2d05620 100644 --- a/mon/mon_req_decode.c +++ b/mon/mon_req_decode.c @@ -38,7 +38,7 @@ #include -// Monitoring request decoders +/* Monitoring request decoders */ /** * Decode a single option @@ -98,7 +98,9 @@ static MON_RC mon_options_decode(json_t *opts_json, MON_REQ *req) &opt) != MON_SUCCESS) { return MON_NOPARSE; } - mon_req_add_option(req, opt.type); + if (MON_SUCCESS != mon_req_add_option(req, opt.type)){ + return MON_NOPARSE; + } } return MON_SUCCESS; } diff --git a/mon/mon_req_encode.c b/mon/mon_req_encode.c index 5bcf8b2..12e408c 100644 --- a/mon/mon_req_encode.c +++ b/mon/mon_req_encode.c @@ -39,7 +39,7 @@ #include -// Monitoring request encoders +/* Monitoring request encoders */ /** * Encode options array as a JSON array @@ -54,7 +54,7 @@ * @param opts array of options * @return reference to a JSON array of options */ -static json_t *mon_opts_decode(GArray *opts) +static json_t *mon_opts_encode(GArray *opts) { json_t *array_json = json_array(); // the array of options json_t *opt_json = NULL; // individual option JSON object @@ -142,7 +142,7 @@ json_t *mon_req_encode(MON_REQ *req) /* If we have options, add them to the object */ if (req->options->len > 0) { - opts_json = mon_opts_decode(req->options); + opts_json = mon_opts_encode(req->options); if (opts_json == NULL) { json_decref(req_json); return NULL; diff --git a/mon/mon_resp.c b/mon/mon_resp.c index f0729ad..3049eaa 100644 --- a/mon/mon_resp.c +++ b/mon/mon_resp.c @@ -38,7 +38,7 @@ #include -// Monitoring request message common code +/* Monitoring response message common code */ /** * Destructor used by talloc to ensure proper cleanup diff --git a/mon/mon_resp_decode.c b/mon/mon_resp_decode.c index 83b0ac3..c6ca379 100644 --- a/mon/mon_resp_decode.c +++ b/mon/mon_resp_decode.c @@ -38,7 +38,7 @@ #include -// Monitoring response decoder +/* Monitoring response decoder */ /** * Decode a JSON response diff --git a/mon/mon_resp_encode.c b/mon/mon_resp_encode.c index 7e41c65..515fb7a 100644 --- a/mon/mon_resp_encode.c +++ b/mon/mon_resp_encode.c @@ -37,6 +37,8 @@ #include +/* Monitoring response encoder */ + /* Helper for encoding. Adds a newly allocated JSON object to * jobj. If the allocation or setting fails, returns NULL after * cleaning up. */ diff --git a/mon/mons_handlers.c b/mon/mons_handlers.c index 5e19db0..24cce1f 100644 --- a/mon/mons_handlers.c +++ b/mon/mons_handlers.c @@ -34,7 +34,7 @@ /* Handlers for monitoring requests */ -#include +#include #include #include diff --git a/tr/trmon_main.c b/tr/trmon_main.c index e6d4253..761b433 100644 --- a/tr/trmon_main.c +++ b/tr/trmon_main.c @@ -44,7 +44,7 @@ /* command-line option setup */ static void print_version_info(void) { - printf("Moonshot TR Monitoring Client %s\n\n", PACKAGE_VERSION); + printf("Moonshot Trust Router Monitoring Client %s\n\n", PACKAGE_VERSION); } @@ -52,7 +52,7 @@ static void print_version_info(void) const char *argp_program_bug_address=PACKAGE_BUGREPORT; /* bug reporting address */ /* doc strings */ -static const char doc[]=PACKAGE_NAME " - Moonshot TR Monitoring Client"; +static const char doc[]=PACKAGE_NAME " - Moonshot Trust Router Monitoring Client"; static const char arg_doc[]=" [