From 6e314dd96f70eb8402c1913a00f2ee3c3f145a4d Mon Sep 17 00:00:00 2001 From: Philip Prindeville Date: Thu, 24 Aug 2023 16:45:31 -0600 Subject: [PATCH] Log if restconf started w/o configuration --- apps/restconf/restconf_main_native.c | 22 ++++------------------ lib/src/clixon_plugin.c | 5 ++--- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/apps/restconf/restconf_main_native.c b/apps/restconf/restconf_main_native.c index ca6db46b2..ad8c23f8f 100644 --- a/apps/restconf/restconf_main_native.c +++ b/apps/restconf/restconf_main_native.c @@ -301,23 +301,10 @@ restconf_verify_certs(int preverify_ok, static int alpn_proto_dump(const char *label, const char *inp, - int len) + unsigned len) { - - int retval = -1; - char *str = NULL; - - if ((str = malloc(len+1)) == NULL){ - clicon_err(OE_UNIX, errno, "malloc"); - goto done; - } - strncpy(str, inp, len); - str[len] = '\0'; - clicon_debug(1, "%s %s", label, str); - retval = 0; - done: - free(str); - return retval; + clicon_debug(1, "%s %.*s", label, (int)len, inp); + return 0; } /*! Application-layer Protocol Negotiation (alpn) callback @@ -533,7 +520,6 @@ restconf_checkcert_file(cxobj *xrestconf, static int restconf_accept_client(int fd, void *arg) - { int retval = -1; restconf_socket *rsock; @@ -1315,7 +1301,7 @@ main(int argc, if ((ret = restconf_clixon_init(h, inline_config, &xrestconf)) < 0) goto done; if (ret == 0){ /* restconf disabled */ - clicon_debug(1, "restconf configuration not found or disabled"); + clicon_log(LOG_INFO, "restconf configuration not found or disabled"); retval = 0; goto done; } diff --git a/lib/src/clixon_plugin.c b/lib/src/clixon_plugin.c index 12eac6641..eea3ddafd 100644 --- a/lib/src/clixon_plugin.c +++ b/lib/src/clixon_plugin.c @@ -374,8 +374,7 @@ plugin_load_one(clicon_handle h, if ((p=strrchr(name, '.')) != NULL) *p = '\0'; /* Copy name to struct */ - snprintf(cp->cp_name, sizeof(cp->cp_name), "%*s", - (int)strlen(name), name); + snprintf(cp->cp_name, sizeof(cp->cp_name), "%s", name); cp->cp_api = *api; if (cp){ *cpp = cp; @@ -481,7 +480,7 @@ clixon_pseudo_plugin(clicon_handle h, goto done; } memset(cp, 0, sizeof(struct clixon_plugin)); - snprintf(cp->cp_name, sizeof(cp->cp_name), "%*s", (int)strlen(name), name); + snprintf(cp->cp_name, sizeof(cp->cp_name), "%s", name); ADDQ(cp, ms->ms_plugin_list); *cpp = cp; cp = NULL;