Formatting and debugs

This commit is contained in:
Olof hagsand 2024-05-28 18:50:07 +02:00
parent c377a28d56
commit e2140aed10
7 changed files with 14 additions and 8 deletions

View file

@ -87,7 +87,7 @@ Notes:
### Comments ### Comments
Use `/* */`. Use `//` only for temporal comments. Use `/* */`. Use `//` only for temporary comments.
Do not use "======", ">>>>>" or "<<<<<<" in comments since git merge conflict uses that. Do not use "======", ">>>>>" or "<<<<<<" in comments since git merge conflict uses that.

View file

@ -74,6 +74,7 @@
/* Command line options to be passed to getopt(3) */ /* Command line options to be passed to getopt(3) */
#define CLI_OPTS "+hVD:f:E:l:C:F:1a:u:d:m:qp:GLy:c:U:o:" #define CLI_OPTS "+hVD:f:E:l:C:F:1a:u:d:m:qp:GLy:c:U:o:"
/*! Check if there is a CLI history file and if so dump the CLI histiry to it /*! Check if there is a CLI history file and if so dump the CLI histiry to it
* *
* Just log if file does not exist or is not readable * Just log if file does not exist or is not readable

View file

@ -748,7 +748,6 @@ clicon_cliread(clixon_handle h,
goto done; goto done;
goto fail; goto fail;
} }
retval = 1; retval = 1;
done: done:
if (pfmt) if (pfmt)

View file

@ -323,10 +323,12 @@ restconf_connection_sanity(clixon_handle h,
char *media_str = NULL; char *media_str = NULL;
char *oneline = NULL; char *oneline = NULL;
clixon_debug(CLIXON_DBG_RESTCONF, "");
/* 1) Check if http/2 non-tls is disabled */ /* 1) Check if http/2 non-tls is disabled */
if (rc->rc_ssl == NULL && if (rc->rc_ssl == NULL &&
rc->rc_proto == HTTP_2 && rc->rc_proto == HTTP_2 &&
clicon_option_bool(h, "CLICON_RESTCONF_HTTP2_PLAIN") == 0){ clicon_option_bool(h, "CLICON_RESTCONF_HTTP2_PLAIN") == 0){
clixon_debug(CLIXON_DBG_RESTCONF, "Sanity check http/2 non-tls failed, disconnect");
if (netconf_invalid_value_xml(&xerr, "protocol", "Only HTTP/2 with TLS is enabled, plain http/2 is disabled") < 0) if (netconf_invalid_value_xml(&xerr, "protocol", "Only HTTP/2 with TLS is enabled, plain http/2 is disabled") < 0)
goto done; goto done;
if ((media_str = restconf_param_get(h, "HTTP_ACCEPT")) == NULL){ if ((media_str = restconf_param_get(h, "HTTP_ACCEPT")) == NULL){
@ -343,6 +345,7 @@ restconf_connection_sanity(clixon_handle h,
/* 2) Check if ssl client cert is valid */ /* 2) Check if ssl client cert is valid */
else if (rc->rc_ssl != NULL && else if (rc->rc_ssl != NULL &&
(code = SSL_get_verify_result(rc->rc_ssl)) != 0){ (code = SSL_get_verify_result(rc->rc_ssl)) != 0){
clixon_debug(CLIXON_DBG_RESTCONF, "Sanity check cert error SSL_get_verify_result: %ld, disconnect", code);
/* Syslog cert failure */ /* Syslog cert failure */
if (ssl_x509_name_oneline(rc->rc_ssl, &oneline) < 0) if (ssl_x509_name_oneline(rc->rc_ssl, &oneline) < 0)
goto done; goto done;
@ -372,6 +375,7 @@ restconf_connection_sanity(clixon_handle h,
} }
retval = 0; retval = 0;
done: done:
clixon_debug(CLIXON_DBG_RESTCONF, "retval:%d", retval);
if (oneline) if (oneline)
free(oneline); free(oneline);
if (cberr) if (cberr)

View file

@ -492,7 +492,7 @@ xmldb_multi_read_applyfn(cxobj *x,
dbfile = cbuf_get(cb); dbfile = cbuf_get(cb);
clixon_debug(CLIXON_DBG_DATASTORE, "Parsing: %s", dbfile); clixon_debug(CLIXON_DBG_DATASTORE, "Parsing: %s", dbfile);
if ((fp = fopen(dbfile, "r")) == NULL){ if ((fp = fopen(dbfile, "r")) == NULL){
clixon_err(OE_CFG, errno, "fdopen(%s)", dbfile); clixon_err(OE_CFG, errno, "fopen(%s)", dbfile);
goto done; goto done;
} }
switch (mr->mr_format){ switch (mr->mr_format){

View file

@ -2245,8 +2245,10 @@ clixon_compare_xmls(cxobj *xc1,
clixon_err(OE_UNDEF, errno, "tmpfile"); clixon_err(OE_UNDEF, errno, "tmpfile");
goto done; goto done;
} }
if ((f = fdopen(fd, "w")) == NULL) if ((f = fdopen(fd, "w")) == NULL){
clixon_err(OE_XML, errno, "fdopen(%s)", filename1);
goto done; goto done;
}
switch(format){ switch(format){
case FORMAT_TEXT: case FORMAT_TEXT:
if (clixon_text2file(f, xc1, 0, cligen_output, 1, 1) < 0) if (clixon_text2file(f, xc1, 0, cligen_output, 1, 1) < 0)
@ -2260,14 +2262,14 @@ clixon_compare_xmls(cxobj *xc1,
} }
fclose(f); fclose(f);
close(fd); close(fd);
if ((fd = mkstemp(filename2)) < 0){ if ((fd = mkstemp(filename2)) < 0){
clixon_err(OE_UNDEF, errno, "mkstemp: %s", strerror(errno)); clixon_err(OE_UNDEF, errno, "mkstemp: %s", strerror(errno));
goto done; goto done;
} }
if ((f = fdopen(fd, "w")) == NULL) if ((f = fdopen(fd, "w")) == NULL){
clixon_err(OE_XML, errno, "fdopen(%s)", filename2);
goto done; goto done;
}
switch(format){ switch(format){
case FORMAT_TEXT: case FORMAT_TEXT:
if (clixon_text2file(f, xc2, 0, cligen_output, 1, 1) < 0) if (clixon_text2file(f, xc2, 0, cligen_output, 1, 1) < 0)

View file

@ -1178,7 +1178,7 @@ xpath2canonical(const char *xpath0,
* @param[in] xcur xml-tree where to search * @param[in] xcur xml-tree where to search
* @param[in] nsc External XML namespace context, or NULL * @param[in] nsc External XML namespace context, or NULL
* @param[in] xpath XPath syntax * @param[in] xpath XPath syntax
* @param[oit] count Nr of elements of xpath * @param[out] count Nr of elements of xpath
* @retval 0 OK * @retval 0 OK
* @retval -1 Error * @retval -1 Error
* @note This function is made for making optimizations in certain circumstances, such as a list * @note This function is made for making optimizations in certain circumstances, such as a list