}
static void trie_node_cleanup(struct trie_node *node) {
- size_t i;
-
if (!node)
return;
- for (i = 0; i < node->children_count; i++)
+ for (size_t i = 0; i < node->children_count; i++)
trie_node_cleanup(node->children[i].child);
free(node->children);
free(node->values);
static int trie_insert(struct trie *trie, struct trie_node *node, const char *search,
const char *key, const char *value,
const char *filename, uint16_t file_priority, uint32_t line_number, bool compat) {
- size_t i = 0;
int r = 0;
- for (;;) {
+ for (size_t i = 0;; i++) {
size_t p;
uint8_t c;
struct trie_node *child;
}
node = child;
- i++;
}
}
/* calculate the storage space for the nodes, children arrays, value arrays */
static void trie_store_nodes_size(struct trie_f *trie, struct trie_node *node, bool compat) {
- uint64_t i;
-
- for (i = 0; i < node->children_count; i++)
+ for (uint64_t i = 0; i < node->children_count; i++)
trie_store_nodes_size(trie, node->children[i].child, compat);
trie->strings_off += sizeof(struct trie_node_f);
- for (i = 0; i < node->children_count; i++)
+ for (uint64_t i = 0; i < node->children_count; i++)
trie->strings_off += sizeof(struct trie_child_entry_f);
- for (i = 0; i < node->values_count; i++)
+ for (uint64_t i = 0; i < node->values_count; i++)
trie->strings_off += compat ? sizeof(struct trie_value_entry_f) : sizeof(struct trie_value_entry2_f);
}
static int64_t trie_store_nodes(struct trie_f *trie, struct trie_node *node, bool compat) {
- uint64_t i;
struct trie_node_f n = {
.prefix_off = htole64(trie->strings_off + node->prefix_off),
.children_count = node->children_count,
}
/* post-order recursion */
- for (i = 0; i < node->children_count; i++) {
+ for (uint64_t i = 0; i < node->children_count; i++) {
int64_t child_off;
child_off = trie_store_nodes(trie, node->children[i].child, compat);
}
/* append values array */
- for (i = 0; i < node->values_count; i++) {
+ for (uint64_t i = 0; i < node->values_count; i++) {
struct trie_value_entry2_f v = {
.key_off = htole64(trie->strings_off + node->values[i].key_off),
.value_off = htole64(trie->strings_off + node->values[i].value_off),
value = strchr(line, '=');
if (!value)
return log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
- "Key-value pair expected but got \"%s\", ignoring", line);
+ "Key-value pair expected but got \"%s\", ignoring.", line);
value[0] = '\0';
value++;
if (isempty(line + 1))
return log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
- "Empty key in \"%s=%s\", ignoring",
+ "Empty key in \"%s=%s\", ignoring.",
line, value);
STRV_FOREACH(entry, match_list)
if (r == 0)
break;
- ++line_number;
+ line_number ++;
/* comment line */
if (line[0] == '#')
if (line[0] == ' ') {
r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
- "Match expected but got indented property \"%s\", ignoring line", line);
+ "Match expected but got indented property \"%s\", ignoring line.", line);
break;
}
case HW_MATCH:
if (len == 0) {
r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
- "Property expected, ignoring record with no properties");
+ "Property expected, ignoring record with no properties.");
state = HW_NONE;
match_list = strv_free(match_list);
break;
if (line[0] != ' ') {
r = log_syntax(NULL, LOG_WARNING, filename, line_number, SYNTHETIC_ERRNO(EINVAL),
- "Property or empty line expected, got \"%s\", ignoring record", line);
+ "Property or empty line expected, got \"%s\", ignoring record.", line);
state = HW_NONE;
match_list = strv_free(match_list);
break;
if (state == HW_MATCH)
log_syntax(NULL, LOG_WARNING, filename, line_number, 0,
- "Property expected, ignoring record with no properties");
+ "Property expected, ignoring record with no properties.");
return r;
}