return UBUS_STATUS_PERMISSION_DENIED;
ptr.package = blobmsg_data(tb[RPC_G_CONFIG]);
- uci_load(cursor, ptr.package, &p);
- if (!p)
- goto out;
+ if (uci_load(cursor, ptr.package, &p))
+ return rpc_uci_status();
if (tb[RPC_G_SECTION])
{
ubus_send_reply(ctx, req, buf.head);
out:
- if (p)
- uci_unload(cursor, p);
+ uci_unload(cursor, p);
return rpc_uci_status();
}
ptr.package = blobmsg_data(tb[RPC_A_CONFIG]);
- uci_load(cursor, ptr.package, &p);
-
- if (!p)
- goto out;
+ if (uci_load(cursor, ptr.package, &p))
+ return rpc_uci_status();
/* add named section */
if (tb[RPC_A_NAME])
ubus_send_reply(ctx, req, buf.head);
out:
- if (p)
- uci_unload(cursor, p);
+ uci_unload(cursor, p);
return rpc_uci_status();
}
return UBUS_STATUS_PERMISSION_DENIED;
ptr.package = blobmsg_data(tb[RPC_S_CONFIG]);
- uci_load(cursor, ptr.package, &p);
- if (!p)
- goto out;
+ if (uci_load(cursor, ptr.package, &p))
+ return rpc_uci_status();
if (tb[RPC_S_SECTION])
{
}
uci_save(cursor, p);
-
-out:
- if (p)
- uci_unload(cursor, p);
+ uci_unload(cursor, p);
return rpc_uci_status();
}
return UBUS_STATUS_PERMISSION_DENIED;
ptr.package = blobmsg_data(tb[RPC_D_CONFIG]);
- uci_load(cursor, ptr.package, &p);
- if (!p)
- goto out;
+ if (uci_load(cursor, ptr.package, &p))
+ return rpc_uci_status();
if (tb[RPC_D_SECTION])
{
}
uci_save(cursor, p);
-
-out:
- if (p)
- uci_unload(cursor, p);
+ uci_unload(cursor, p);
return rpc_uci_status();
}
if (tb[RPC_R_OPTION])
ptr.option = blobmsg_data(tb[RPC_R_OPTION]);
- uci_load(cursor, ptr.package, &p);
-
- if (!p)
- goto out;
+ if (uci_load(cursor, ptr.package, &p))
+ return rpc_uci_status();
if (uci_lookup_ptr(cursor, &ptr, NULL, true))
goto out;
uci_save(cursor, p);
out:
- if (p)
- uci_unload(cursor, p);
+ uci_unload(cursor, p);
return rpc_uci_status();
}
ptr.package = blobmsg_data(tb[RPC_O_CONFIG]);
- uci_load(cursor, ptr.package, &p);
-
- if (!p)
- goto out;
+ if (uci_load(cursor, ptr.package, &p))
+ return rpc_uci_status();
blobmsg_for_each_attr(cur, tb[RPC_O_SECTIONS], rem)
{
}
uci_save(cursor, p);
-
-out:
- if (p)
- uci_unload(cursor, p);
+ uci_unload(cursor, p);
return rpc_uci_status();
}
if (!rpc_uci_read_access(tb[RPC_C_SESSION], tb[RPC_C_CONFIG]))
return UBUS_STATUS_PERMISSION_DENIED;
- uci_load(cursor, blobmsg_data(tb[RPC_C_CONFIG]), &p);
-
- if (!p)
- goto out;
+ if (uci_load(cursor, blobmsg_data(tb[RPC_C_CONFIG]), &p))
+ return rpc_uci_status();
blob_buf_init(&buf, 0);
c = blobmsg_open_array(&buf, "changes");
ubus_send_reply(ctx, req, buf.head);
-out:
- if (p)
- uci_unload(cursor, p);
+ uci_unload(cursor, p);
return rpc_uci_status();
}
if (commit)
{
- uci_load(cursor, ptr.package, &p);
-
- if (p)
+ if (!uci_load(cursor, ptr.package, &p))
{
uci_commit(cursor, &p, false);
uci_unload(cursor, p);
struct uci_ptr ptr = { 0 };
ptr.package = config;
- uci_load(cursor, ptr.package, &p);
- if (p) {
+ if (!uci_load(cursor, ptr.package, &p)) {
uci_commit(cursor, &p, false);
uci_unload(cursor, p);
}