@@ -95,7 +95,7 @@ int edit_node_data_tree_list(struct lysc_node *y_node, int edit_type,
9595 }
9696
9797 sprintf (xpath , "%s" , get_relative_path (y_node ));
98- struct lyd_node * curr_parent , * new_parent = NULL ;
98+ struct lyd_node * curr_parent = NULL , * new_parent = NULL ;
9999 // set current parent and xpath based on the list location in the tree.
100100 if (parent_data == NULL ) {
101101 lysc_path (y_node , LYSC_PATH_DATA , xpath , 256 );
@@ -124,22 +124,19 @@ int edit_node_data_tree_list(struct lysc_node *y_node, int edit_type,
124124 struct lyd_node * next = NULL ;
125125 struct lyd_node * orderd_nodes = lyd_first_sibling (new_parent );
126126
127- LY_LIST_FOR (orderd_nodes , next )
128- {
127+ LY_LIST_FOR (orderd_nodes , next ) {
129128 if (index < curr_indx ) {
130129 ret = lyd_insert_before (next , new_parent );
131130 if (ret != LY_SUCCESS ) {
132131 lyd_free_tree (new_parent );
133132 goto done ;
134133 }
135134 break ;
136-
137135 }
138136 curr_indx += 10 ;
139137 }
140138 }
141139 if (edit_type == EDIT_DATA_ADD ) {
142-
143140 if (!item_found ) {
144141 ret = sr_set_item (sysrepo_get_session (), all_xpath , NULL , 0 );
145142 if (ret != SR_ERR_OK )
@@ -152,14 +149,13 @@ int edit_node_data_tree_list(struct lysc_node *y_node, int edit_type,
152149 ret = sr_delete_item (sysrepo_get_session (), all_xpath , 0 );
153150 if (ret != SR_ERR_OK )
154151 goto done ;
155- }
156- else
152+ } else
157153 cli_print (cli , " item not found in datastore!" );
158154 lyd_free_tree (new_parent );
159155 }
160156
161157
162- done :
158+ done :
163159 if (ret != LY_SUCCESS ) {
164160 print_ly_err (ly_err_first (sysrepo_ctx ), "data_factory.c" , cli );
165161 }
@@ -175,8 +171,7 @@ int add_data_node_list(struct lysc_node *y_node, int index, struct cli_def *cli,
175171}
176172
177173int delete_data_node_list (struct lysc_node * y_node , struct cli_def * cli ) {
178- return edit_node_data_tree_list (y_node , EDIT_DATA_DEL , 0 , cli , 0 );// no index use key for delete
179-
174+ return edit_node_data_tree_list (y_node , EDIT_DATA_DEL , 0 , cli , 0 ); // no index use key for delete
180175}
181176
182177
@@ -185,7 +180,7 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
185180 char xpath [256 ];
186181 memset (xpath , '\0' , 256 );
187182 struct ly_ctx * sysrepo_ctx = (struct ly_ctx * ) sysrepo_get_ctx ();
188-
183+ char all_xpath [ 1024 ] = { 0 };
189184
190185 if (!sysrepo_ctx ) {
191186 LOG_ERROR (" add_data_node(): Failure: failed to get sysrepo_ctx" );
@@ -225,7 +220,6 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
225220 else {
226221 lyd_free_tree (new_parent );
227222 if (item_found ) {
228- char all_xpath [1024 ] = {0 };
229223 lyd_path (parent_data , LYD_PATH_STD , all_xpath , 1024 );
230224 strlcat (all_xpath , "/" , sizeof (all_xpath ));
231225 strlcat (all_xpath , xpath , sizeof (all_xpath ));
@@ -237,7 +231,7 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
237231 break ;
238232 }
239233 }
240- break ;
234+ break ;
241235
242236 case LYS_LEAF :
243237 case LYS_LEAFLIST :
@@ -248,7 +242,6 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
248242
249243 struct lyd_node * new_leaf = NULL ;
250244 int item_found = 1 ;
251- char all_xpath [1024 ] = {0 };
252245 lyd_path (parent_data , LYD_PATH_STD , all_xpath , 1024 );
253246 strlcat (all_xpath , "/" , sizeof (all_xpath ));
254247 strlcat (all_xpath , xpath , sizeof (all_xpath ));
@@ -270,7 +263,6 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
270263 if (ret != SR_ERR_OK )
271264 break ;
272265 }
273-
274266 } else {
275267 lyd_free_tree (new_leaf );
276268 if (item_found ) {
@@ -281,7 +273,6 @@ static int edit_node_data_tree(struct lysc_node *y_node, char *value, int edit_t
281273 cli_print (cli , " item not found in datastore!" );
282274 }
283275 break ;
284-
285276 }
286277 if (ret != LY_SUCCESS )
287278 print_ly_err (ly_err_first (sysrepo_ctx ), "data_factory.c" , cli );
0 commit comments