chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
resolved: remove unused variable
[elogind.git]
/
src
/
udev
/
udev-rules.c
diff --git
a/src/udev/udev-rules.c
b/src/udev/udev-rules.c
index 0a326044126d8ca08f8adc72849abcbb17bdd53f..9864016d1447c1ab041ead6ed0d515d22f73d5a8 100644
(file)
--- a/
src/udev/udev-rules.c
+++ b/
src/udev/udev-rules.c
@@
-440,8
+440,6
@@
static void dump_rules(struct udev_rules *rules)
dump_token(rules, &rules->tokens[i]);
}
#else
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 */
static inline void dump_token(struct udev_rules *rules, struct token *token) {}
static inline void dump_rules(struct udev_rules *rules) {}
#endif /* DEBUG */
@@
-1144,7
+1142,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "ATTR{")) {
}
if (startswith(key, "ATTR{")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("ATTR")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("ATTR")
);
if (attr == NULL) {
log_error("error parsing ATTR attribute");
goto invalid;
if (attr == NULL) {
log_error("error parsing ATTR attribute");
goto invalid;
@@
-1158,7
+1156,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "SECLABEL{")) {
}
if (startswith(key, "SECLABEL{")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("SECLABEL")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("SECLABEL")
);
if (!attr) {
log_error("error parsing SECLABEL attribute");
goto invalid;
if (!attr) {
log_error("error parsing SECLABEL attribute");
goto invalid;
@@
-1200,7
+1198,7
@@
static int add_rule(struct udev_rules *rules, char *line,
log_error("invalid ATTRS operation");
goto invalid;
}
log_error("invalid ATTRS operation");
goto invalid;
}
- attr = get_key_attribute(rules->udev, key + s
izeof("ATTRS")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("ATTRS")
);
if (attr == NULL) {
log_error("error parsing ATTRS attribute");
goto invalid;
if (attr == NULL) {
log_error("error parsing ATTRS attribute");
goto invalid;
@@
-1225,7
+1223,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "ENV{")) {
}
if (startswith(key, "ENV{")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("ENV")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("ENV")
);
if (attr == NULL) {
log_error("error parsing ENV attribute");
goto invalid;
if (attr == NULL) {
log_error("error parsing ENV attribute");
goto invalid;
@@
-1284,7
+1282,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "IMPORT")) {
}
if (startswith(key, "IMPORT")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("IMPORT")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("IMPORT")
);
if (attr == NULL) {
log_error("IMPORT{} type missing, ignoring IMPORT %s:%u", filename, lineno);
continue;
if (attr == NULL) {
log_error("IMPORT{} type missing, ignoring IMPORT %s:%u", filename, lineno);
continue;
@@
-1330,7
+1328,7
@@
static int add_rule(struct udev_rules *rules, char *line,
log_error("invalid TEST operation");
goto invalid;
}
log_error("invalid TEST operation");
goto invalid;
}
- attr = get_key_attribute(rules->udev, key + s
izeof("TEST")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("TEST")
);
if (attr != NULL) {
mode = strtol(attr, NULL, 8);
rule_add_key(&rule_tmp, TK_M_TEST, op, value, &mode);
if (attr != NULL) {
mode = strtol(attr, NULL, 8);
rule_add_key(&rule_tmp, TK_M_TEST, op, value, &mode);
@@
-1341,7
+1339,7
@@
static int add_rule(struct udev_rules *rules, char *line,
}
if (startswith(key, "RUN")) {
}
if (startswith(key, "RUN")) {
- attr = get_key_attribute(rules->udev, key + s
izeof("RUN")-1
);
+ attr = get_key_attribute(rules->udev, key + s
trlen("RUN")
);
if (attr == NULL)
attr = "program";
if (attr == NULL)
attr = "program";
@@
-1535,15
+1533,19
@@
static int parse_file(struct udev_rules *rules, const char *filename)
int line_nr = 0;
unsigned int i;
int line_nr = 0;
unsigned int i;
- if (null_or_empty_path(filename)) {
- log_debug("skip empty file: %s", filename);
- return 0;
+ f = fopen(filename, "re");
+ if (!f) {
+ if (errno == ENOENT)
+ return 0;
+ else
+ return -errno;
}
}
- log_debug("read rules file: %s", filename);
- f = fopen(filename, "re");
- if (f == NULL)
- return -1;
+ if (null_or_empty_fd(fileno(f))) {
+ log_debug("Skipping empty file: %s", filename);
+ return 0;
+ } else
+ log_debug("Reading rules file: %s", filename);
first_token = rules->token_cur;
filename_off = rules_add_string(rules, filename);
first_token = rules->token_cur;
filename_off = rules_add_string(rules, filename);
@@
-2029,7
+2031,7
@@
int udev_rules_apply_to_event(struct udev_rules *rules, struct udev_event *event
case TK_M_PROGRAM: {
char program[UTIL_PATH_SIZE];
char **envp;
case TK_M_PROGRAM: {
char program[UTIL_PATH_SIZE];
char **envp;
- char result[UTIL_
PATH
_SIZE];
+ char result[UTIL_
LINE
_SIZE];
free(event->program_result);
event->program_result = NULL;
free(event->program_result);
event->program_result = NULL;
@@
-2557,10
+2559,15
@@
int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
struct stat stats;
/* we assure, that the permissions tokens are sorted before the static token */
struct stat stats;
/* 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 (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)
+ break;
+ if (!S_ISBLK(stats.st_mode) && !S_ISCHR(stats.st_mode))
+ break;
/* 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 */
if (tags) {
@@
-2590,11
+2597,6
@@
int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
if (mode == 0 && uid == 0 && gid == 0)
break;
if (mode == 0 && uid == 0 && gid == 0)
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)
mode = 0660;
if (mode == 0) {
if (gid > 0)
mode = 0660;