chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
gcc: make a couple of gcc warnings go away
[elogind.git]
/
device.c
diff --git
a/device.c
b/device.c
index e51d2f3ddb73b0e82a1d0efe6d1cb57970441d36..6de7d518c718cfc30496f7a5fb45f9824a25ad2e 100644
(file)
--- a/
device.c
+++ b/
device.c
@@
-87,7
+87,7
@@
static UnitActiveState device_active_state(Unit *u) {
return state_translation_table[DEVICE(u)->state];
}
return state_translation_table[DEVICE(u)->state];
}
-static int device_add_escaped_name(Unit *u, const char *
prefix, const char *
dn, bool make_id) {
+static int device_add_escaped_name(Unit *u, const char *dn, bool make_id) {
char *e;
int r;
char *e;
int r;
@@
-95,7
+95,7
@@
static int device_add_escaped_name(Unit *u, const char *prefix, const char *dn,
assert(dn);
assert(dn[0] == '/');
assert(dn);
assert(dn[0] == '/');
- if (!(e = unit_name_escape_path(
prefix,
dn+1, ".device")))
+ if (!(e = unit_name_escape_path(dn+1, ".device")))
return -ENOMEM;
r = unit_add_name(u, e);
return -ENOMEM;
r = unit_add_name(u, e);
@@
-137,7
+137,7
@@
static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
return -ENOMEM;
assert(sysfs[0] == '/');
return -ENOMEM;
assert(sysfs[0] == '/');
- if (!(e = unit_name_escape_path(
"sysfs-",
sysfs+1, ".device")))
+ if (!(e = unit_name_escape_path(sysfs+1, ".device")))
return -ENOMEM;
if (!(u = manager_get_unit(m, e))) {
return -ENOMEM;
if (!(u = manager_get_unit(m, e))) {
@@
-162,9
+162,12
@@
static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
}
if ((model = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE")) ||
}
if ((model = udev_device_get_property_value(dev, "ID_MODEL_FROM_DATABASE")) ||
- (model = udev_device_get_property_value(dev, "ID_MODEL")))
+ (model = udev_device_get_property_value(dev, "ID_MODEL")))
{
if ((r = unit_set_description(u, model)) < 0)
goto fail;
if ((r = unit_set_description(u, model)) < 0)
goto fail;
+ } else if (dn)
+ if ((r = unit_set_description(u, dn)) < 0)
+ goto fail;
unit_add_to_load_queue(u);
} else {
unit_add_to_load_queue(u);
} else {
@@
-173,18
+176,20
@@
static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
}
if (dn)
}
if (dn)
- if ((r = device_add_escaped_name(u,
"node-",
dn, true)) < 0)
+ if ((r = device_add_escaped_name(u, dn, true)) < 0)
goto fail;
first = udev_device_get_devlinks_list_entry(dev);
udev_list_entry_foreach(item, first)
goto fail;
first = udev_device_get_devlinks_list_entry(dev);
udev_list_entry_foreach(item, first)
- if ((r = device_add_escaped_name(u,
"node-",
udev_list_entry_get_name(item), false)) < 0)
+ if ((r = device_add_escaped_name(u, udev_list_entry_get_name(item), false)) < 0)
goto fail;
if (names) {
FOREACH_WORD(w, l, names, state) {
goto fail;
if (names) {
FOREACH_WORD(w, l, names, state) {
- if (!(e = strndup(w, l)))
+ if (!(e = strndup(w, l))) {
+ r = -ENOMEM;
goto fail;
goto fail;
+ }
r = unit_add_name(u, e);
free(e);
r = unit_add_name(u, e);
free(e);
@@
-196,8
+201,10
@@
static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
if (wants) {
FOREACH_WORD(w, l, wants, state) {
if (wants) {
FOREACH_WORD(w, l, wants, state) {
- if (!(e = strndup(w, l)))
+ if (!(e = strndup(w, l))) {
+ r = -ENOMEM;
goto fail;
goto fail;
+ }
r = unit_add_dependency_by_name(u, UNIT_WANTS, e);
free(e);
r = unit_add_dependency_by_name(u, UNIT_WANTS, e);
free(e);
@@
-212,6
+219,8
@@
static int device_process_new_device(Manager *m, struct udev_device *dev, bool u
device_set_state(DEVICE(u), DEVICE_AVAILABLE);
}
device_set_state(DEVICE(u), DEVICE_AVAILABLE);
}
+ unit_add_to_dbus_queue(u);
+
return 0;
fail:
return 0;
fail:
@@
-250,7
+259,7
@@
static int device_process_removed_device(Manager *m, struct udev_device *dev) {
return -ENOMEM;
assert(sysfs[0] == '/');
return -ENOMEM;
assert(sysfs[0] == '/');
- if (!(e = unit_name_escape_path(
"sysfs-",
sysfs+1, ".device")))
+ if (!(e = unit_name_escape_path(sysfs+1, ".device")))
return -ENOMEM;
u = manager_get_unit(m, e);
return -ENOMEM;
u = manager_get_unit(m, e);