dump_token(rules, &rules->tokens[i]);
}
#else
-static inline const char *operation_str(enum operation_type type) { return NULL; }
-static inline const char *token_str(enum token_type type) { return NULL; }
static inline void dump_token(struct udev_rules *rules, struct token *token) {}
static inline void dump_rules(struct udev_rules *rules) {}
#endif /* DEBUG */
struct token *token = &rule_tmp->token[rule_tmp->token_cur];
const char *attr = NULL;
- memset(token, 0x00, sizeof(struct token));
+ memzero(token, sizeof(struct token));
switch (type) {
case TK_M_ACTION:
case TK_A_GOTO:
case TK_M_TAG:
case TK_A_TAG:
+ case TK_A_STATIC_NODE:
token->key.value_off = rules_add_string(rule_tmp->rules, value);
break;
case TK_M_IMPORT_BUILTIN:
case TK_A_MODE_ID:
token->key.mode = *(mode_t *)data;
break;
- case TK_A_STATIC_NODE:
- token->key.value_off = rules_add_string(rule_tmp->rules, value);
- break;
case TK_M_EVENT_TIMEOUT:
token->key.event_timeout = *(int *)data;
break;
}
if (attr != NULL) {
- /* check if property/attribut name has substitution chars */
+ /* check if property/attribute name has substitution chars */
if (attr[0] == '[')
token->key.attrsubst = SB_SUBSYS;
else if (strchr(attr, '%') != NULL || strchr(attr, '$') != NULL)
const char *attr;
struct rule_tmp rule_tmp;
- memset(&rule_tmp, 0x00, sizeof(struct rule_tmp));
+ memzero(&rule_tmp, sizeof(struct rule_tmp));
rule_tmp.rules = rules;
rule_tmp.rule.type = TK_RULE;
/* the offset in the rule is limited to unsigned short */
char **files, **f;
int r;
- rules = calloc(1, sizeof(struct udev_rules));
+ rules = new0(struct udev_rules, 1);
if (rules == NULL)
return NULL;
rules->udev = udev;
strv_free(files);
- memset(&end_token, 0x00, sizeof(struct token));
+ memzero(&end_token, sizeof(struct token));
end_token.type = TK_END;
add_token(rules, &end_token);
log_debug("rules contain %zu bytes tokens (%u * %zu bytes), %zu bytes strings",
/* we assure, that the permissions tokens are sorted before the static token */
if (mode == 0 && uid == 0 && gid == 0 && tags == NULL)
goto next;
+
strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL);
- if (stat(device_node, &stats) != 0)
- goto next;
- if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
- goto next;
+ /* export the tags to a directory as symlinks, allowing otherwise dead nodes to be tagged */
if (tags) {
- /* Export the tags to a directory as symlinks, allowing otherwise dead nodes to be tagged */
-
STRV_FOREACH(t, tags) {
_cleanup_free_ char *unescaped_filename = NULL;
/* don't touch the permissions if only the tags were set */
if (mode == 0 && uid == 0 && gid == 0)
- goto next;
+ break;
+
+ if (stat(device_node, &stats) != 0)
+ break;
+ if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
+ break;
if (mode == 0) {
if (gid > 0)