mirror of
https://dev.iopsys.eu/bbf/icwmp.git
synced 2025-12-10 07:44:41 +01:00
Remove unused argument in transaction API
This commit is contained in:
parent
6e7554d1b1
commit
27231b20dc
5 changed files with 45 additions and 56 deletions
|
|
@ -130,7 +130,7 @@ function install_bbfdmd()
|
|||
if [ -n "${BBFDM_BRANCH}" ]; then
|
||||
exec_cmd git clone -b ${BBFDM_BRANCH} https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm
|
||||
else
|
||||
exec_cmd git clone https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm
|
||||
exec_cmd git clone -b release-7.3 https://dev.iopsys.eu/bbf/bbfdm.git /opt/dev/bbfdm
|
||||
fi
|
||||
|
||||
cd /opt/dev/bbfdm
|
||||
|
|
|
|||
|
|
@ -28,11 +28,6 @@ struct setm_values_res {
|
|||
struct list_head *faults_list;
|
||||
};
|
||||
|
||||
struct transaction_info {
|
||||
bool status;
|
||||
bool restart_services;
|
||||
};
|
||||
|
||||
/*
|
||||
* Common functions
|
||||
*/
|
||||
|
|
@ -76,26 +71,23 @@ static void ubus_transaction_callback(struct ubus_request *req, int type __attri
|
|||
if (msg == NULL || req == NULL)
|
||||
return;
|
||||
|
||||
struct transaction_info *trans_info = (struct transaction_info *)req->priv;
|
||||
bool *status = (bool *)req->priv;
|
||||
|
||||
blobmsg_parse(p, 3, tb, blobmsg_data(msg), blobmsg_len(msg));
|
||||
|
||||
if (!tb[0]) {
|
||||
trans_info->status = false;
|
||||
*status = false;
|
||||
return;
|
||||
}
|
||||
|
||||
trans_info->status = blobmsg_get_u8(tb[0]);
|
||||
if (trans_info->status == false)
|
||||
*status = blobmsg_get_u8(tb[0]);
|
||||
if (*status == false)
|
||||
return;
|
||||
|
||||
if (tb[1]) {
|
||||
transaction_id = blobmsg_get_u32(tb[1]);
|
||||
}
|
||||
|
||||
if (trans_info->restart_services == false)
|
||||
return;
|
||||
|
||||
if (tb[2]) {
|
||||
struct blob_attr *updated_services = tb[2];
|
||||
struct blob_attr *service = NULL;
|
||||
|
|
@ -113,13 +105,10 @@ static void ubus_transaction_callback(struct ubus_request *req, int type __attri
|
|||
}
|
||||
}
|
||||
|
||||
bool cwmp_transaction(const char *cmd, bool restart_services)
|
||||
bool cwmp_transaction(const char *cmd)
|
||||
{
|
||||
struct blob_buf b = {0};
|
||||
struct transaction_info trans_info = {
|
||||
.status = false,
|
||||
.restart_services = restart_services
|
||||
};
|
||||
bool status = false;
|
||||
|
||||
if (CWMP_STRLEN(cmd) == 0)
|
||||
return false;
|
||||
|
|
@ -144,7 +133,7 @@ bool cwmp_transaction(const char *cmd, bool restart_services)
|
|||
blobmsg_add_u8(&b, "restart_services", false);
|
||||
prepare_optional_table(&b);
|
||||
|
||||
int e = icwmp_ubus_invoke(BBFDM_OBJECT_NAME, "transaction", b.head, ubus_transaction_callback, &trans_info);
|
||||
int e = icwmp_ubus_invoke(BBFDM_OBJECT_NAME, "transaction", b.head, ubus_transaction_callback, &status);
|
||||
|
||||
blob_buf_free(&b);
|
||||
|
||||
|
|
@ -156,7 +145,7 @@ bool cwmp_transaction(const char *cmd, bool restart_services)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (!trans_info.status) {
|
||||
if (!status) {
|
||||
CWMP_LOG(INFO, "Transaction %s failed: Status => false", cmd);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ struct object_result {
|
|||
|
||||
extern unsigned int transaction_id;
|
||||
|
||||
bool cwmp_transaction(const char *cmd, bool restart_services);
|
||||
bool cwmp_transaction(const char *cmd);
|
||||
|
||||
bool cwmp_get_parameter_value(const char *parameter_name, struct cwmp_dm_parameter *dm_parameter);
|
||||
|
||||
|
|
|
|||
18
src/rpc.c
18
src/rpc.c
|
|
@ -1037,7 +1037,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct rpc *rpc)
|
|||
|
||||
xml_data_list_to_dm_parameter_list(&xml_list_set_param_value, &list_set_param_value);
|
||||
|
||||
if (!cwmp_transaction("start", false)) {
|
||||
if (!cwmp_transaction("start")) {
|
||||
fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
err_msg = "Failed to start new transaction";
|
||||
goto fault;
|
||||
|
|
@ -1084,7 +1084,7 @@ int cwmp_handle_rpc_cpe_set_parameter_values(struct rpc *rpc)
|
|||
goto fault;
|
||||
}
|
||||
|
||||
if (!cwmp_transaction("commit", true)) {
|
||||
if (!cwmp_transaction("commit")) {
|
||||
fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
err_msg = "Failed to commit the transaction";
|
||||
goto fault;
|
||||
|
|
@ -1100,7 +1100,7 @@ fault:
|
|||
|
||||
cwmp_free_all_list_param_fault(rpc->list_set_value_fault);
|
||||
|
||||
cwmp_transaction("abort", false);
|
||||
cwmp_transaction("abort");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1196,7 +1196,7 @@ int cwmp_handle_rpc_cpe_add_object(struct rpc *rpc)
|
|||
goto fault;
|
||||
}
|
||||
|
||||
if (!cwmp_transaction("start", false)) {
|
||||
if (!cwmp_transaction("start")) {
|
||||
err_msg = "Failed to start new transaction";
|
||||
goto fault;
|
||||
}
|
||||
|
|
@ -1241,7 +1241,7 @@ int cwmp_handle_rpc_cpe_add_object(struct rpc *rpc)
|
|||
goto fault;
|
||||
}
|
||||
|
||||
if (!cwmp_transaction("commit", false)) {
|
||||
if (!cwmp_transaction("commit")) {
|
||||
err_msg = "Failed to commit the transaction";
|
||||
goto fault;
|
||||
}
|
||||
|
|
@ -1262,7 +1262,7 @@ fault:
|
|||
if (cwmp_create_fault_message(rpc, fault_code, err_msg))
|
||||
ret = -1;
|
||||
|
||||
cwmp_transaction("abort", false);
|
||||
cwmp_transaction("abort");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -1292,7 +1292,7 @@ int cwmp_handle_rpc_cpe_delete_object(struct rpc *rpc)
|
|||
goto fault;
|
||||
}
|
||||
|
||||
if (!cwmp_transaction("start", false)) {
|
||||
if (!cwmp_transaction("start")) {
|
||||
err_msg = "Failed to start new transaction";
|
||||
goto fault;
|
||||
}
|
||||
|
|
@ -1328,7 +1328,7 @@ int cwmp_handle_rpc_cpe_delete_object(struct rpc *rpc)
|
|||
goto fault;
|
||||
}
|
||||
|
||||
if (!cwmp_transaction("commit", true)) {
|
||||
if (!cwmp_transaction("commit")) {
|
||||
fault_code = FAULT_CPE_INTERNAL_ERROR;
|
||||
err_msg = "Failed to commit the transaction";
|
||||
goto fault;
|
||||
|
|
@ -1346,7 +1346,7 @@ fault:
|
|||
if (cwmp_create_fault_message(rpc, fault_code, err_msg))
|
||||
ret = -1;
|
||||
|
||||
cwmp_transaction("abort", false);
|
||||
cwmp_transaction("abort");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,17 +110,17 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
* Test of one valid parameter
|
||||
*/
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Alias", "wifi_alias_1", NULL, 0, false);
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
|
||||
assert_int_equal(fault, 0);
|
||||
cwmp_transaction("commit", true);
|
||||
cwmp_transaction("commit");
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.ManagementServer.Username", "iopsys_user", NULL, 0, false);
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
|
||||
assert_int_equal(fault, 0);
|
||||
cwmp_transaction("commit", true);
|
||||
cwmp_transaction("commit");
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
fault = 0;
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
* Test of non valid parameter path
|
||||
*/
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Alis", "wifi_alias_1", NULL, 0, false);
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
|
||||
assert_non_null(fault);
|
||||
list_for_each_entry (param_fault, &faults_array, list) {
|
||||
|
|
@ -139,7 +139,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
assert_int_not_equal(fault, 0);
|
||||
assert_int_equal(fault_code, 9005);
|
||||
assert_non_null(fault_name);
|
||||
cwmp_transaction("abort", false);
|
||||
cwmp_transaction("abort");
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
cwmp_free_all_list_param_fault(&faults_array);
|
||||
fault_code = 0;
|
||||
|
|
@ -151,7 +151,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
* Test of non writable, valid parameter path
|
||||
*/
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.DeviceInfo.UpTime", "1234", NULL, 0, false);
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
fault = cwmp_set_multi_parameters_value(&list_set_param_value,&faults_array);
|
||||
assert_int_not_equal(fault, 0);
|
||||
list_for_each_entry (param_fault, &faults_array, list) {
|
||||
|
|
@ -162,7 +162,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
assert_int_not_equal(fault, 0);
|
||||
assert_int_equal(fault_code, 9008);
|
||||
assert_non_null(fault_name);
|
||||
cwmp_transaction("abort", false);
|
||||
cwmp_transaction("abort");
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
cwmp_free_all_list_param_fault(&faults_array);
|
||||
fault = 0;
|
||||
|
|
@ -174,7 +174,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
* Test of writable, valid parameter path wrong value
|
||||
*/
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Enable", "tre", NULL, 0, false);
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
|
||||
assert_non_null(fault);
|
||||
list_for_each_entry (param_fault, &faults_array, list) {
|
||||
|
|
@ -185,7 +185,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
assert_int_not_equal(fault, 0);
|
||||
assert_int_equal(fault_code, 9007);
|
||||
assert_non_null(fault_name);
|
||||
cwmp_transaction("abort", false);
|
||||
cwmp_transaction("abort");
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
cwmp_free_all_list_param_fault(&faults_array);
|
||||
fault_code = 0;
|
||||
|
|
@ -199,10 +199,10 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Alias", "wifi_alias1_1", NULL, 0, false);
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.SSID", "wifi_ssid_2", NULL, 0, false);
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.ManagementServer.Username", "iopsys_user_1", NULL, 0, false);
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
|
||||
assert_int_equal(fault, 0);
|
||||
cwmp_transaction("commit", true);
|
||||
cwmp_transaction("commit");
|
||||
cwmp_free_all_list_param_fault(&faults_array);
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
|
||||
|
|
@ -213,13 +213,13 @@ static void dm_set_multiple_parameter_values_test(void **state)
|
|||
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.1.Enable", "tre", NULL, 0, false);
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.WiFi.SSID.2.Alis", "wifi_2", NULL, 0, false);
|
||||
add_dm_parameter_to_list(&list_set_param_value, "Device.ATM.Link.1.Status", "Up", NULL, 0, false);
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
fault = cwmp_set_multi_parameters_value(&list_set_param_value, &faults_array);
|
||||
assert_int_not_equal(fault, 0);
|
||||
list_for_each_entry (param_fault, &faults_array, list) {
|
||||
assert_in_set(param_fault->fault_code, faults_values, 3);
|
||||
}
|
||||
cwmp_transaction("commit", true);
|
||||
cwmp_transaction("commit");
|
||||
cwmp_free_all_dm_parameter_list(&list_set_param_value);
|
||||
}
|
||||
|
||||
|
|
@ -234,11 +234,11 @@ static void dm_add_object_test(void **state)
|
|||
|
||||
memset(&res, 0, sizeof(struct object_result));
|
||||
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
status = cwmp_add_object("Device.WiFi.SSID.", &res);
|
||||
assert_non_null(res.instance);
|
||||
assert_true(status);
|
||||
cwmp_transaction("commit", false);
|
||||
cwmp_transaction("commit");
|
||||
FREE(res.instance);
|
||||
|
||||
/*
|
||||
|
|
@ -247,12 +247,12 @@ static void dm_add_object_test(void **state)
|
|||
|
||||
memset(&res, 0, sizeof(struct object_result));
|
||||
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
status = cwmp_add_object("Device.WiFi.SIDl.", &res);
|
||||
assert_false(status);
|
||||
assert_int_equal(res.fault_code, FAULT_9005);
|
||||
assert_null(res.instance);
|
||||
cwmp_transaction("commit", false);
|
||||
cwmp_transaction("commit");
|
||||
FREE(res.instance);
|
||||
|
||||
/*
|
||||
|
|
@ -261,12 +261,12 @@ static void dm_add_object_test(void **state)
|
|||
|
||||
memset(&res, 0, sizeof(struct object_result));
|
||||
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
status = cwmp_add_object("Device.DeviceInfo.Processor.", &res);
|
||||
assert_false(status);
|
||||
assert_int_equal(res.fault_code, FAULT_9005);
|
||||
assert_null(res.instance);
|
||||
cwmp_transaction("commit", false);
|
||||
cwmp_transaction("commit");
|
||||
FREE(res.instance);
|
||||
}
|
||||
|
||||
|
|
@ -281,10 +281,10 @@ static void dm_delete_object_test(void **state)
|
|||
|
||||
memset(&res, 0, sizeof(struct object_result));
|
||||
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
status = cwmp_delete_object("Device.WiFi.SSID.2.", &res);
|
||||
assert_true(status);
|
||||
cwmp_transaction("commit", true);
|
||||
cwmp_transaction("commit");
|
||||
|
||||
/*
|
||||
* Delete not valid path object
|
||||
|
|
@ -292,11 +292,11 @@ static void dm_delete_object_test(void **state)
|
|||
|
||||
memset(&res, 0, sizeof(struct object_result));
|
||||
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
status = cwmp_delete_object("Device.WiFi.SIDl.3.", &res);
|
||||
assert_false(status);
|
||||
assert_int_equal(res.fault_code, FAULT_9005);
|
||||
cwmp_transaction("commit", true);
|
||||
cwmp_transaction("commit");
|
||||
|
||||
/*
|
||||
* Delte valid path not writable object
|
||||
|
|
@ -304,11 +304,11 @@ static void dm_delete_object_test(void **state)
|
|||
|
||||
memset(&res, 0, sizeof(struct object_result));
|
||||
|
||||
cwmp_transaction("start", false);
|
||||
cwmp_transaction("start");
|
||||
status = cwmp_delete_object("Device.DeviceInfo.Processor.2.", &res);
|
||||
assert_false(status);
|
||||
assert_int_equal(res.fault_code, FAULT_9005);
|
||||
cwmp_transaction("commit", true);
|
||||
cwmp_transaction("commit");
|
||||
}
|
||||
|
||||
static void dm_get_parameter_names_test(void **state)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue