@@ -105,12 +105,10 @@ static struct trie_node *node_lookup(const struct trie_node *node, uint8_t c) {
105105}
106106
107107static void trie_node_cleanup (struct trie_node * node ) {
108- size_t i ;
109-
110108 if (!node )
111109 return ;
112110
113- for (i = 0 ; i < node -> children_count ; i ++ )
111+ for (size_t i = 0 ; i < node -> children_count ; i ++ )
114112 trie_node_cleanup (node -> children [i ].child );
115113 free (node -> children );
116114 free (node -> values );
@@ -191,10 +189,9 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
191189static int trie_insert (struct trie * trie , struct trie_node * node , const char * search ,
192190 const char * key , const char * value ,
193191 const char * filename , uint16_t file_priority , uint32_t line_number , bool compat ) {
194- size_t i = 0 ;
195192 int r = 0 ;
196193
197- for (;; ) {
194+ for (size_t i = 0 ;; i ++ ) {
198195 size_t p ;
199196 uint8_t c ;
200197 struct trie_node * child ;
@@ -273,7 +270,6 @@ static int trie_insert(struct trie *trie, struct trie_node *node, const char *se
273270 }
274271
275272 node = child ;
276- i ++ ;
277273 }
278274}
279275
@@ -289,20 +285,17 @@ struct trie_f {
289285
290286/* calculate the storage space for the nodes, children arrays, value arrays */
291287static void trie_store_nodes_size (struct trie_f * trie , struct trie_node * node , bool compat ) {
292- uint64_t i ;
293-
294- for (i = 0 ; i < node -> children_count ; i ++ )
288+ for (uint64_t i = 0 ; i < node -> children_count ; i ++ )
295289 trie_store_nodes_size (trie , node -> children [i ].child , compat );
296290
297291 trie -> strings_off += sizeof (struct trie_node_f );
298- for (i = 0 ; i < node -> children_count ; i ++ )
292+ for (uint64_t i = 0 ; i < node -> children_count ; i ++ )
299293 trie -> strings_off += sizeof (struct trie_child_entry_f );
300- for (i = 0 ; i < node -> values_count ; i ++ )
294+ for (uint64_t i = 0 ; i < node -> values_count ; i ++ )
301295 trie -> strings_off += compat ? sizeof (struct trie_value_entry_f ) : sizeof (struct trie_value_entry2_f );
302296}
303297
304298static int64_t trie_store_nodes (struct trie_f * trie , struct trie_node * node , bool compat ) {
305- uint64_t i ;
306299 struct trie_node_f n = {
307300 .prefix_off = htole64 (trie -> strings_off + node -> prefix_off ),
308301 .children_count = node -> children_count ,
@@ -318,7 +311,7 @@ static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node, boo
318311 }
319312
320313 /* post-order recursion */
321- for (i = 0 ; i < node -> children_count ; i ++ ) {
314+ for (uint64_t i = 0 ; i < node -> children_count ; i ++ ) {
322315 int64_t child_off ;
323316
324317 child_off = trie_store_nodes (trie , node -> children [i ].child , compat );
@@ -343,7 +336,7 @@ static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node, boo
343336 }
344337
345338 /* append values array */
346- for (i = 0 ; i < node -> values_count ; i ++ ) {
339+ for (uint64_t i = 0 ; i < node -> values_count ; i ++ ) {
347340 struct trie_value_entry2_f v = {
348341 .key_off = htole64 (trie -> strings_off + node -> values [i ].key_off ),
349342 .value_off = htole64 (trie -> strings_off + node -> values [i ].value_off ),
@@ -447,7 +440,7 @@ static int insert_data(struct trie *trie, char **match_list, char *line, const c
447440 value = strchr (line , '=' );
448441 if (!value )
449442 return log_syntax (NULL , LOG_WARNING , filename , line_number , SYNTHETIC_ERRNO (EINVAL ),
450- "Key-value pair expected but got \"%s\", ignoring" , line );
443+ "Key-value pair expected but got \"%s\", ignoring. " , line );
451444
452445 value [0 ] = '\0' ;
453446 value ++ ;
@@ -456,10 +449,9 @@ static int insert_data(struct trie *trie, char **match_list, char *line, const c
456449 while (isblank (line [0 ]) && isblank (line [1 ]))
457450 line ++ ;
458451
459- if (isempty (line + 1 ) || isempty ( value ) )
452+ if (isempty (line + 1 ))
460453 return log_syntax (NULL , LOG_WARNING , filename , line_number , SYNTHETIC_ERRNO (EINVAL ),
461- "Empty %s in \"%s=%s\", ignoring" ,
462- isempty (line + 1 ) ? "key" : "value" ,
454+ "Empty key in \"%s=%s\", ignoring." ,
463455 line , value );
464456
465457 STRV_FOREACH (entry , match_list )
@@ -494,7 +486,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
494486 if (r == 0 )
495487 break ;
496488
497- ++ line_number ;
489+ line_number ++ ;
498490
499491 /* comment line */
500492 if (line [0 ] == '#' )
@@ -518,7 +510,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
518510
519511 if (line [0 ] == ' ' ) {
520512 r = log_syntax (NULL , LOG_WARNING , filename , line_number , SYNTHETIC_ERRNO (EINVAL ),
521- "Match expected but got indented property \"%s\", ignoring line" , line );
513+ "Match expected but got indented property \"%s\", ignoring line. " , line );
522514 break ;
523515 }
524516
@@ -534,7 +526,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
534526 case HW_MATCH :
535527 if (len == 0 ) {
536528 r = log_syntax (NULL , LOG_WARNING , filename , line_number , SYNTHETIC_ERRNO (EINVAL ),
537- "Property expected, ignoring record with no properties" );
529+ "Property expected, ignoring record with no properties. " );
538530 state = HW_NONE ;
539531 match_list = strv_free (match_list );
540532 break ;
@@ -566,7 +558,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
566558
567559 if (line [0 ] != ' ' ) {
568560 r = log_syntax (NULL , LOG_WARNING , filename , line_number , SYNTHETIC_ERRNO (EINVAL ),
569- "Property or empty line expected, got \"%s\", ignoring record" , line );
561+ "Property or empty line expected, got \"%s\", ignoring record. " , line );
570562 state = HW_NONE ;
571563 match_list = strv_free (match_list );
572564 break ;
@@ -581,7 +573,7 @@ static int import_file(struct trie *trie, const char *filename, uint16_t file_pr
581573
582574 if (state == HW_MATCH )
583575 log_syntax (NULL , LOG_WARNING , filename , line_number , 0 ,
584- "Property expected, ignoring record with no properties" );
576+ "Property expected, ignoring record with no properties. " );
585577
586578 return r ;
587579}
0 commit comments