Minor adjustments to follow clixon programming style

This commit is contained in:
Jan-Olof Carlson 2022-08-27 07:16:37 +00:00 committed by Olof hagsand
parent ad7232d1ad
commit 2e3a5a6334

View file

@ -416,7 +416,8 @@ element2value(clicon_handle h,
*/
static int
xml_flag_default_value(cxobj *x, uint16_t flag)
xml_flag_default_value(cxobj *x,
uint16_t flag)
{
yang_stmt *y;
cg_var *cv;
@ -451,7 +452,8 @@ xml_flag_default_value(cxobj *x, uint16_t flag)
* @retval -1 Error
*/
static int
xml_add_default_tag(cxobj *x, uint16_t flags)
xml_add_default_tag(cxobj *x,
uint16_t flags)
{
int retval = -1;
cxobj *xattr;
@ -478,13 +480,16 @@ xml_add_default_tag(cxobj *x, uint16_t flags)
*/
static int
with_defaults(cxobj *xe, cxobj *xret) {
with_defaults(cxobj *xe,
cxobj *xret)
{
int retval = -1;
cxobj *xfind;
char *mode;
if ((xfind = xml_find(xe, "with-defaults")) != NULL) {
if ((mode = xml_find_value(xfind, "body")) != NULL) {
if ((mode = xml_find_value(xfind, "body")) == NULL)
goto done;
if (strcmp(mode, "explicit") == 0) {
/* Clear marked nodes */
@ -497,8 +502,9 @@ with_defaults(cxobj *xe, cxobj *xret) {
if (xml_tree_prune_flags(xret, XML_FLAG_DEFAULT, XML_FLAG_MARK | XML_FLAG_DEFAULT) < 0)
goto done;
/* TODO. Remove empty containers */
} else if (strcmp(mode, "trim") == 0) {
goto ok;
}
if (strcmp(mode, "trim") == 0) {
/* Remove default nodes from XML */
if (xml_tree_prune_flags(xret, XML_FLAG_DEFAULT, XML_FLAG_DEFAULT) < 0)
goto done;
@ -509,8 +515,9 @@ with_defaults(cxobj *xe, cxobj *xret) {
< 0)
goto done;
/* TODO. Remove empty containers */
} else if (strcmp(mode, "report-all-tagged") == 0) {
goto ok;
}
if (strcmp(mode, "report-all-tagged") == 0) {
if (xmlns_set(xret, "wd", "urn:ietf:params:xml:ns:netconf:default:1.0") < 0)
goto done;
/* Mark nodes having default schema values */
@ -519,12 +526,14 @@ with_defaults(cxobj *xe, cxobj *xret) {
/* Add tag attributes to default nodes */
if (xml_apply(xret, CX_ELMNT, (xml_applyfn_t*) xml_add_default_tag, (void*) (XML_FLAG_DEFAULT | XML_FLAG_MARK)) < 0)
goto done;
} else if (strcmp(mode, "report-all") == 0) {
goto ok;
}
if (strcmp(mode, "report-all") == 0) {
/* Accept mode, do nothing */
goto ok;
}
}
}
ok:
retval = 0;
done:
return retval;