Merge pull request #11594 from yuwata/udev-rule-cleanups
udev-rule, ethtool: several coding style cleanups
This commit is contained in:
commit
683a1e7fd9
|
@ -358,7 +358,7 @@ static int find_feature_index(struct ethtool_gstrings *strings, const char *feat
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -ENODATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ethtool_set_features(int *fd, const char *ifname, int *features) {
|
int ethtool_set_features(int *fd, const char *ifname, int *features) {
|
||||||
|
|
|
@ -458,7 +458,7 @@ static int add_token(UdevRules *rules, struct token *token) {
|
||||||
|
|
||||||
tokens = reallocarray(rules->tokens, rules->token_max + add, sizeof(struct token));
|
tokens = reallocarray(rules->tokens, rules->token_max + add, sizeof(struct token));
|
||||||
if (!tokens)
|
if (!tokens)
|
||||||
return -1;
|
return -ENOMEM;
|
||||||
rules->tokens = tokens;
|
rules->tokens = tokens;
|
||||||
rules->token_max += add;
|
rules->token_max += add;
|
||||||
}
|
}
|
||||||
|
@ -483,10 +483,8 @@ static uid_t add_uid(UdevRules *rules, const char *owner) {
|
||||||
/* lookup, if we know it already */
|
/* lookup, if we know it already */
|
||||||
for (i = 0; i < rules->uids_cur; i++) {
|
for (i = 0; i < rules->uids_cur; i++) {
|
||||||
off = rules->uids[i].name_off;
|
off = rules->uids[i].name_off;
|
||||||
if (streq(rules_str(rules, off), owner)) {
|
if (streq(rules_str(rules, off), owner))
|
||||||
uid = rules->uids[i].uid;
|
return rules->uids[i].uid;
|
||||||
return uid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
r = get_user_creds(&owner, &uid, NULL, NULL, NULL, USER_CREDS_ALLOW_MISSING);
|
r = get_user_creds(&owner, &uid, NULL, NULL, NULL, USER_CREDS_ALLOW_MISSING);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -526,10 +524,8 @@ static gid_t add_gid(UdevRules *rules, const char *group) {
|
||||||
/* lookup, if we know it already */
|
/* lookup, if we know it already */
|
||||||
for (i = 0; i < rules->gids_cur; i++) {
|
for (i = 0; i < rules->gids_cur; i++) {
|
||||||
off = rules->gids[i].name_off;
|
off = rules->gids[i].name_off;
|
||||||
if (streq(rules_str(rules, off), group)) {
|
if (streq(rules_str(rules, off), group))
|
||||||
gid = rules->gids[i].gid;
|
return rules->gids[i].gid;
|
||||||
return gid;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
r = get_group_creds(&group, &gid, USER_CREDS_ALLOW_MISSING);
|
r = get_group_creds(&group, &gid, USER_CREDS_ALLOW_MISSING);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
|
@ -720,7 +716,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
|
|
||||||
linepos = *line;
|
linepos = *line;
|
||||||
if (!linepos || linepos[0] == '\0')
|
if (!linepos || linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* skip whitespace */
|
/* skip whitespace */
|
||||||
while (isspace(linepos[0]) || linepos[0] == ',')
|
while (isspace(linepos[0]) || linepos[0] == ',')
|
||||||
|
@ -728,13 +724,13 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
|
|
||||||
/* get the key */
|
/* get the key */
|
||||||
if (linepos[0] == '\0')
|
if (linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
*key = linepos;
|
*key = linepos;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
linepos++;
|
linepos++;
|
||||||
if (linepos[0] == '\0')
|
if (linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
if (isspace(linepos[0]))
|
if (isspace(linepos[0]))
|
||||||
break;
|
break;
|
||||||
if (linepos[0] == '=')
|
if (linepos[0] == '=')
|
||||||
|
@ -751,7 +747,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
while (isspace(linepos[0]))
|
while (isspace(linepos[0]))
|
||||||
linepos++;
|
linepos++;
|
||||||
if (linepos[0] == '\0')
|
if (linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* get operation type */
|
/* get operation type */
|
||||||
if (linepos[0] == '=' && linepos[1] == '=') {
|
if (linepos[0] == '=' && linepos[1] == '=') {
|
||||||
|
@ -773,7 +769,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
*op = OP_ASSIGN_FINAL;
|
*op = OP_ASSIGN_FINAL;
|
||||||
linepos += 2;
|
linepos += 2;
|
||||||
} else
|
} else
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* terminate key */
|
/* terminate key */
|
||||||
temp[0] = '\0';
|
temp[0] = '\0';
|
||||||
|
@ -782,13 +778,13 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
while (isspace(linepos[0]))
|
while (isspace(linepos[0]))
|
||||||
linepos++;
|
linepos++;
|
||||||
if (linepos[0] == '\0')
|
if (linepos[0] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* get the value */
|
/* get the value */
|
||||||
if (linepos[0] == '"')
|
if (linepos[0] == '"')
|
||||||
linepos++;
|
linepos++;
|
||||||
else
|
else
|
||||||
return -1;
|
return -EINVAL;
|
||||||
*value = linepos;
|
*value = linepos;
|
||||||
|
|
||||||
/* terminate */
|
/* terminate */
|
||||||
|
@ -798,7 +794,7 @@ static int get_key(char **line, char **key, enum operation_type *op, char **valu
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (linepos[i] == '\0')
|
if (linepos[i] == '\0')
|
||||||
return -1;
|
return -EINVAL;
|
||||||
|
|
||||||
/* double quotes can be escaped */
|
/* double quotes can be escaped */
|
||||||
if (linepos[i] == '\\')
|
if (linepos[i] == '\\')
|
||||||
|
@ -980,6 +976,7 @@ static int sort_token(UdevRules *rules, struct rule_tmp *rule_tmp) {
|
||||||
unsigned i;
|
unsigned i;
|
||||||
unsigned start = 0;
|
unsigned start = 0;
|
||||||
unsigned end = rule_tmp->token_cur;
|
unsigned end = rule_tmp->token_cur;
|
||||||
|
int r;
|
||||||
|
|
||||||
for (i = 0; i < rule_tmp->token_cur; i++) {
|
for (i = 0; i < rule_tmp->token_cur; i++) {
|
||||||
enum token_type next_val = TK_UNSET;
|
enum token_type next_val = TK_UNSET;
|
||||||
|
@ -997,8 +994,9 @@ static int sort_token(UdevRules *rules, struct rule_tmp *rule_tmp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* add token and mark done */
|
/* add token and mark done */
|
||||||
if (add_token(rules, &rule_tmp->token[next_idx]) != 0)
|
r = add_token(rules, &rule_tmp->token[next_idx]);
|
||||||
return -1;
|
if (r < 0)
|
||||||
|
return r;
|
||||||
rule_tmp->token[next_idx].type = TK_UNSET;
|
rule_tmp->token[next_idx].type = TK_UNSET;
|
||||||
|
|
||||||
/* shrink range */
|
/* shrink range */
|
||||||
|
@ -1038,7 +1036,7 @@ static void add_rule(UdevRules *rules, char *line,
|
||||||
char *value;
|
char *value;
|
||||||
enum operation_type op;
|
enum operation_type op;
|
||||||
|
|
||||||
if (get_key(&linepos, &key, &op, &value) != 0) {
|
if (get_key(&linepos, &key, &op, &value) < 0) {
|
||||||
/* Avoid erroring on trailing whitespace. This is probably rare
|
/* Avoid erroring on trailing whitespace. This is probably rare
|
||||||
* so save the work for the error case instead of always trying
|
* so save the work for the error case instead of always trying
|
||||||
* to strip the trailing whitespace with strstrip(). */
|
* to strip the trailing whitespace with strstrip(). */
|
||||||
|
@ -1496,7 +1494,7 @@ static void add_rule(UdevRules *rules, char *line,
|
||||||
|
|
||||||
/* add rule token and sort tokens */
|
/* add rule token and sort tokens */
|
||||||
rule_tmp.rule.rule.token_count = 1 + rule_tmp.token_cur;
|
rule_tmp.rule.rule.token_count = 1 + rule_tmp.token_cur;
|
||||||
if (add_token(rules, &rule_tmp.rule) != 0 || sort_token(rules, &rule_tmp) != 0)
|
if (add_token(rules, &rule_tmp.rule) < 0 || sort_token(rules, &rule_tmp) < 0)
|
||||||
LOG_RULE_ERROR("Failed to add rule token");
|
LOG_RULE_ERROR("Failed to add rule token");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1666,7 +1664,7 @@ bool udev_rules_check_timestamp(UdevRules *rules) {
|
||||||
return paths_check_timestamp(rules_dirs, &rules->dirs_ts_usec, true);
|
return paths_check_timestamp(rules_dirs, &rules->dirs_ts_usec, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int match_key(UdevRules *rules, struct token *token, const char *val) {
|
static bool match_key(UdevRules *rules, struct token *token, const char *val) {
|
||||||
char *key_value = rules_str(rules, token->key.value_off);
|
char *key_value = rules_str(rules, token->key.value_off);
|
||||||
char *pos;
|
char *pos;
|
||||||
bool match = false;
|
bool match = false;
|
||||||
|
@ -1676,7 +1674,7 @@ static int match_key(UdevRules *rules, struct token *token, const char *val) {
|
||||||
|
|
||||||
switch (token->key.glob) {
|
switch (token->key.glob) {
|
||||||
case GL_PLAIN:
|
case GL_PLAIN:
|
||||||
match = (streq(key_value, val));
|
match = streq(key_value, val);
|
||||||
break;
|
break;
|
||||||
case GL_GLOB:
|
case GL_GLOB:
|
||||||
match = (fnmatch(key_value, val, 0) == 0);
|
match = (fnmatch(key_value, val, 0) == 0);
|
||||||
|
@ -1699,7 +1697,7 @@ static int match_key(UdevRules *rules, struct token *token, const char *val) {
|
||||||
if (match)
|
if (match)
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
match = (streq(s, val));
|
match = streq(s, val);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
s = &next[1];
|
s = &next[1];
|
||||||
|
@ -1729,17 +1727,13 @@ static int match_key(UdevRules *rules, struct token *token, const char *val) {
|
||||||
match = (val[0] != '\0');
|
match = (val[0] != '\0');
|
||||||
break;
|
break;
|
||||||
case GL_UNSET:
|
case GL_UNSET:
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match && (token->key.op == OP_MATCH))
|
return token->key.op == (match ? OP_MATCH : OP_NOMATCH);
|
||||||
return 0;
|
|
||||||
if (!match && (token->key.op == OP_NOMATCH))
|
|
||||||
return 0;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int match_attr(UdevRules *rules, sd_device *dev, UdevEvent *event, struct token *cur) {
|
static bool match_attr(UdevRules *rules, sd_device *dev, UdevEvent *event, struct token *cur) {
|
||||||
char nbuf[UTIL_NAME_SIZE], vbuf[UTIL_NAME_SIZE];
|
char nbuf[UTIL_NAME_SIZE], vbuf[UTIL_NAME_SIZE];
|
||||||
const char *name, *value;
|
const char *name, *value;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -1752,15 +1746,15 @@ static int match_attr(UdevRules *rules, sd_device *dev, UdevEvent *event, struct
|
||||||
_fallthrough_;
|
_fallthrough_;
|
||||||
case SB_NONE:
|
case SB_NONE:
|
||||||
if (sd_device_get_sysattr_value(dev, name, &value) < 0)
|
if (sd_device_get_sysattr_value(dev, name, &value) < 0)
|
||||||
return -1;
|
return false;
|
||||||
break;
|
break;
|
||||||
case SB_SUBSYS:
|
case SB_SUBSYS:
|
||||||
if (util_resolve_subsys_kernel(name, vbuf, sizeof(vbuf), true) != 0)
|
if (util_resolve_subsys_kernel(name, vbuf, sizeof(vbuf), true) < 0)
|
||||||
return -1;
|
return false;
|
||||||
value = vbuf;
|
value = vbuf;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return -1;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove trailing whitespace, if not asked to match for it */
|
/* remove trailing whitespace, if not asked to match for it */
|
||||||
|
@ -1828,19 +1822,19 @@ int udev_rules_apply_to_event(
|
||||||
esc = ESCAPE_UNSET;
|
esc = ESCAPE_UNSET;
|
||||||
break;
|
break;
|
||||||
case TK_M_ACTION:
|
case TK_M_ACTION:
|
||||||
if (match_key(rules, cur, action) != 0)
|
if (!match_key(rules, cur, action))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
case TK_M_DEVPATH:
|
case TK_M_DEVPATH:
|
||||||
if (sd_device_get_devpath(dev, &val) < 0)
|
if (sd_device_get_devpath(dev, &val) < 0)
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
if (match_key(rules, cur, val) != 0)
|
if (!match_key(rules, cur, val))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
case TK_M_KERNEL:
|
case TK_M_KERNEL:
|
||||||
if (sd_device_get_sysname(dev, &val) < 0)
|
if (sd_device_get_sysname(dev, &val) < 0)
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
if (match_key(rules, cur, val) != 0)
|
if (!match_key(rules, cur, val))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
case TK_M_DEVLINK: {
|
case TK_M_DEVLINK: {
|
||||||
|
@ -1848,7 +1842,7 @@ int udev_rules_apply_to_event(
|
||||||
bool match = false;
|
bool match = false;
|
||||||
|
|
||||||
FOREACH_DEVICE_DEVLINK(dev, devlink)
|
FOREACH_DEVICE_DEVLINK(dev, devlink)
|
||||||
if (match_key(rules, cur, devlink + STRLEN("/dev/")) == 0) {
|
if (match_key(rules, cur, devlink + STRLEN("/dev/"))) {
|
||||||
match = true;
|
match = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1858,7 +1852,7 @@ int udev_rules_apply_to_event(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_M_NAME:
|
case TK_M_NAME:
|
||||||
if (match_key(rules, cur, event->name) != 0)
|
if (!match_key(rules, cur, event->name))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
case TK_M_ENV: {
|
case TK_M_ENV: {
|
||||||
|
@ -1872,7 +1866,7 @@ int udev_rules_apply_to_event(
|
||||||
val = NULL;
|
val = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match_key(rules, cur, strempty(val)))
|
if (!match_key(rules, cur, strempty(val)))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1894,17 +1888,17 @@ int udev_rules_apply_to_event(
|
||||||
case TK_M_SUBSYSTEM:
|
case TK_M_SUBSYSTEM:
|
||||||
if (sd_device_get_subsystem(dev, &val) < 0)
|
if (sd_device_get_subsystem(dev, &val) < 0)
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
if (match_key(rules, cur, val) != 0)
|
if (!match_key(rules, cur, val))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
case TK_M_DRIVER:
|
case TK_M_DRIVER:
|
||||||
if (sd_device_get_driver(dev, &val) < 0)
|
if (sd_device_get_driver(dev, &val) < 0)
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
if (match_key(rules, cur, val) != 0)
|
if (!match_key(rules, cur, val))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
case TK_M_ATTR:
|
case TK_M_ATTR:
|
||||||
if (match_attr(rules, dev, event, cur) != 0)
|
if (!match_attr(rules, dev, event, cur))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
case TK_M_SYSCTL: {
|
case TK_M_SYSCTL: {
|
||||||
|
@ -1920,7 +1914,7 @@ int udev_rules_apply_to_event(
|
||||||
len = strlen(value);
|
len = strlen(value);
|
||||||
while (len > 0 && isspace(value[--len]))
|
while (len > 0 && isspace(value[--len]))
|
||||||
value[len] = '\0';
|
value[len] = '\0';
|
||||||
if (match_key(rules, cur, value) != 0)
|
if (!match_key(rules, cur, value))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1948,23 +1942,23 @@ int udev_rules_apply_to_event(
|
||||||
case TK_M_KERNELS:
|
case TK_M_KERNELS:
|
||||||
if (sd_device_get_sysname(event->dev_parent, &val) < 0)
|
if (sd_device_get_sysname(event->dev_parent, &val) < 0)
|
||||||
goto try_parent;
|
goto try_parent;
|
||||||
if (match_key(rules, key, val) != 0)
|
if (!match_key(rules, key, val))
|
||||||
goto try_parent;
|
goto try_parent;
|
||||||
break;
|
break;
|
||||||
case TK_M_SUBSYSTEMS:
|
case TK_M_SUBSYSTEMS:
|
||||||
if (sd_device_get_subsystem(event->dev_parent, &val) < 0)
|
if (sd_device_get_subsystem(event->dev_parent, &val) < 0)
|
||||||
goto try_parent;
|
goto try_parent;
|
||||||
if (match_key(rules, key, val) != 0)
|
if (!match_key(rules, key, val))
|
||||||
goto try_parent;
|
goto try_parent;
|
||||||
break;
|
break;
|
||||||
case TK_M_DRIVERS:
|
case TK_M_DRIVERS:
|
||||||
if (sd_device_get_driver(event->dev_parent, &val) < 0)
|
if (sd_device_get_driver(event->dev_parent, &val) < 0)
|
||||||
goto try_parent;
|
goto try_parent;
|
||||||
if (match_key(rules, key, val) != 0)
|
if (!match_key(rules, key, val))
|
||||||
goto try_parent;
|
goto try_parent;
|
||||||
break;
|
break;
|
||||||
case TK_M_ATTRS:
|
case TK_M_ATTRS:
|
||||||
if (match_attr(rules, event->dev_parent, event, key) != 0)
|
if (!match_attr(rules, event->dev_parent, event, key))
|
||||||
goto try_parent;
|
goto try_parent;
|
||||||
break;
|
break;
|
||||||
case TK_M_TAGS: {
|
case TK_M_TAGS: {
|
||||||
|
@ -1998,7 +1992,7 @@ int udev_rules_apply_to_event(
|
||||||
int match;
|
int match;
|
||||||
|
|
||||||
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), filename, sizeof(filename), false);
|
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), filename, sizeof(filename), false);
|
||||||
if (util_resolve_subsys_kernel(filename, filename, sizeof(filename), false) != 0) {
|
if (util_resolve_subsys_kernel(filename, filename, sizeof(filename), false) < 0) {
|
||||||
if (filename[0] != '/') {
|
if (filename[0] != '/') {
|
||||||
char tmp[UTIL_PATH_SIZE];
|
char tmp[UTIL_PATH_SIZE];
|
||||||
|
|
||||||
|
@ -2052,7 +2046,7 @@ int udev_rules_apply_to_event(
|
||||||
char import[UTIL_PATH_SIZE];
|
char import[UTIL_PATH_SIZE];
|
||||||
|
|
||||||
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), import, sizeof(import), false);
|
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), import, sizeof(import), false);
|
||||||
if (import_file_into_properties(dev, import) != 0)
|
if (import_file_into_properties(dev, import) < 0)
|
||||||
if (cur->key.op != OP_NOMATCH)
|
if (cur->key.op != OP_NOMATCH)
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
|
@ -2066,7 +2060,7 @@ int udev_rules_apply_to_event(
|
||||||
rules_str(rules, rule->rule.filename_off),
|
rules_str(rules, rule->rule.filename_off),
|
||||||
rule->rule.filename_line);
|
rule->rule.filename_line);
|
||||||
|
|
||||||
if (import_program_into_properties(event, timeout_usec, import) != 0)
|
if (import_program_into_properties(event, timeout_usec, import) < 0)
|
||||||
if (cur->key.op != OP_NOMATCH)
|
if (cur->key.op != OP_NOMATCH)
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
|
@ -2146,13 +2140,13 @@ int udev_rules_apply_to_event(
|
||||||
char import[UTIL_PATH_SIZE];
|
char import[UTIL_PATH_SIZE];
|
||||||
|
|
||||||
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), import, sizeof(import), false);
|
udev_event_apply_format(event, rules_str(rules, cur->key.value_off), import, sizeof(import), false);
|
||||||
if (import_parent_into_properties(dev, import) != 0)
|
if (import_parent_into_properties(dev, import) < 0)
|
||||||
if (cur->key.op != OP_NOMATCH)
|
if (cur->key.op != OP_NOMATCH)
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TK_M_RESULT:
|
case TK_M_RESULT:
|
||||||
if (match_key(rules, cur, event->program_result) != 0)
|
if (!match_key(rules, cur, event->program_result))
|
||||||
goto nomatch;
|
goto nomatch;
|
||||||
break;
|
break;
|
||||||
case TK_A_STRING_ESCAPE_NONE:
|
case TK_A_STRING_ESCAPE_NONE:
|
||||||
|
@ -2440,7 +2434,7 @@ int udev_rules_apply_to_event(
|
||||||
const char *key_name;
|
const char *key_name;
|
||||||
|
|
||||||
key_name = rules_str(rules, cur->key.attr_off);
|
key_name = rules_str(rules, cur->key.attr_off);
|
||||||
if (util_resolve_subsys_kernel(key_name, attr, sizeof(attr), false) != 0 &&
|
if (util_resolve_subsys_kernel(key_name, attr, sizeof(attr), false) < 0 &&
|
||||||
sd_device_get_syspath(dev, &val) >= 0)
|
sd_device_get_syspath(dev, &val) >= 0)
|
||||||
strscpyl(attr, sizeof(attr), val, "/", key_name, NULL);
|
strscpyl(attr, sizeof(attr), val, "/", key_name, NULL);
|
||||||
attr_subst_subdir(attr, sizeof(attr));
|
attr_subst_subdir(attr, sizeof(attr));
|
||||||
|
@ -2581,7 +2575,7 @@ int udev_rules_apply_static_dev_perms(UdevRules *rules) {
|
||||||
goto next;
|
goto next;
|
||||||
|
|
||||||
strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL);
|
strscpyl(device_node, sizeof(device_node), "/dev/", rules_str(rules, cur->key.value_off), NULL);
|
||||||
if (stat(device_node, &stats) != 0)
|
if (stat(device_node, &stats) < 0)
|
||||||
break;
|
break;
|
||||||
if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
|
if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue