sanity checkof xret in param

test: updated to new openconfig network-instance version
This commit is contained in:
Olof hagsand 2022-12-20 13:13:00 +01:00
parent f46d675370
commit 8db7892e38
2 changed files with 14 additions and 10 deletions

View file

@ -825,7 +825,7 @@ xmldb_get_nocache(clicon_handle h,
* @param[in] nsc External XML namespace context, or NULL * @param[in] nsc External XML namespace context, or NULL
* @param[in] xpath String with XPATH syntax. or NULL for all * @param[in] xpath String with XPATH syntax. or NULL for all
* @param[in] wdef With-defaults parameter, see RFC 6243 * @param[in] wdef With-defaults parameter, see RFC 6243
* @param[out] xret Single return XML tree. Free with xml_free() * @param[out] xtop Single return XML tree. Free with xml_free()
* @param[out] msdiff If set, return modules-state differences * @param[out] msdiff If set, return modules-state differences
* @param[out] xerr XML error if retval is 0 * @param[out] xerr XML error if retval is 0
* @retval -1 General error, check specific clicon_errno, clicon_suberrno * @retval -1 General error, check specific clicon_errno, clicon_suberrno
@ -1254,6 +1254,10 @@ xmldb_get0(clicon_handle h,
{ {
int retval = -1; int retval = -1;
if (xret == NULL){
clicon_err(OE_DB, EINVAL, "xret is NULL");
goto done;
}
switch (clicon_datastore_cache(h)){ switch (clicon_datastore_cache(h)){
case DATASTORE_NOCACHE: case DATASTORE_NOCACHE:
/* Read from file into created/copy tree, prune non-matching xpath /* Read from file into created/copy tree, prune non-matching xpath
@ -1280,6 +1284,7 @@ xmldb_get0(clicon_handle h,
retval = xmldb_get_cache(h, db, yb, nsc, xpath, wdef, xret, msdiff, xerr); retval = xmldb_get_cache(h, db, yb, nsc, xpath, wdef, xret, msdiff, xerr);
break; break;
} }
done:
return retval; return retval;
} }

View file

@ -81,7 +81,6 @@ cat <<EOF > $dir/startup_db
<config> <config>
<name>default</name> <name>default</name>
<type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:DEFAULT_INSTANCE</type> <type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:DEFAULT_INSTANCE</type>
<enabled>true</enabled>
<router-id>1.2.3.4</router-id> <router-id>1.2.3.4</router-id>
</config> </config>
</network-instance> </network-instance>