X-Git-Url: http://pilppa.org/gitweb/?p=libplp.git;a=blobdiff_plain;f=src_test%2Ftest_config2.c;h=32e1d931a467592e3e71afba11444f6de8f104c8;hp=2bf367b0d62e864c043dae1d3d7dced058200ac6;hb=45dab65b4663bd3a4115d62effd430441e43fa23;hpb=e637096f7b0a1d73c07ff08d342a6eb2fda2b92e diff --git a/src_test/test_config2.c b/src_test/test_config2.c index 2bf367b..32e1d93 100644 --- a/src_test/test_config2.c +++ b/src_test/test_config2.c @@ -61,12 +61,14 @@ static int uci_create_named_section(struct uci_context *ctx, const char *conf_fi len = len + strlen(section_name); len = len + 1; cmd_data = malloc(len); - snprintf(cmd_data, len, "%s.%s=%s", conf_file_name, section_name, section_type); - if (uci_lookup_ptr(ctx, &ptr, cmd_data, true) == UCI_OK) { - ret_val = uci_set(ctx, &ptr); - if (ret_val == UCI_OK) { - //ret_val = uci_save(ctx, ptr.p); + if (cmd_data != NULL) { + snprintf(cmd_data, len, "%s.%s=%s", conf_file_name, section_name, section_type); + if (uci_lookup_ptr(ctx, &ptr, cmd_data, true) == UCI_OK) { + ret_val = uci_set(ctx, &ptr); + if (ret_val == UCI_OK) { + } } + free(cmd_data); } } return ret_val; @@ -149,7 +151,7 @@ bool set_config_value2(const char *conf_dir_name, ptr.option = key; if (uci_lookup_ptr(ctx, &ptr, NULL, false) == UCI_OK) { - ptr.value = strdup(value); + ptr.value = value; uci_set(ctx, &ptr); save = true; }