mirror of
https://github.com/systemd/systemd.git
synced 2024-11-05 06:52:22 +03:00
rfkill: Lookup device in determine_state_file
None of the callers actually need the device itself. So it makes sense to do the lookup inside determine_state_file instead.
This commit is contained in:
parent
6c1f72f626
commit
8e70766313
@ -162,18 +162,21 @@ static int wait_for_initialized(
|
|||||||
static int determine_state_file(
|
static int determine_state_file(
|
||||||
struct udev *udev,
|
struct udev *udev,
|
||||||
const struct rfkill_event *event,
|
const struct rfkill_event *event,
|
||||||
struct udev_device *d,
|
|
||||||
char **ret) {
|
char **ret) {
|
||||||
|
|
||||||
|
_cleanup_udev_device_unref_ struct udev_device *d = NULL;
|
||||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
||||||
const char *path_id, *type;
|
const char *path_id, *type;
|
||||||
char *state_file;
|
char *state_file;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
assert(event);
|
assert(event);
|
||||||
assert(d);
|
|
||||||
assert(ret);
|
assert(ret);
|
||||||
|
|
||||||
|
r = find_device(udev, event, &d);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
|
|
||||||
r = wait_for_initialized(udev, d, &device);
|
r = wait_for_initialized(udev, d, &device);
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
@ -204,7 +207,6 @@ static int load_state(
|
|||||||
struct udev *udev,
|
struct udev *udev,
|
||||||
const struct rfkill_event *event) {
|
const struct rfkill_event *event) {
|
||||||
|
|
||||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
|
||||||
_cleanup_free_ char *state_file = NULL, *value = NULL;
|
_cleanup_free_ char *state_file = NULL, *value = NULL;
|
||||||
struct rfkill_event we;
|
struct rfkill_event we;
|
||||||
ssize_t l;
|
ssize_t l;
|
||||||
@ -217,11 +219,7 @@ static int load_state(
|
|||||||
if (shall_restore_state() == 0)
|
if (shall_restore_state() == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
r = find_device(udev, event, &device);
|
r = determine_state_file(udev, event, &state_file);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = determine_state_file(udev, event, device, &state_file);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
@ -266,7 +264,6 @@ static int save_state(
|
|||||||
struct udev *udev,
|
struct udev *udev,
|
||||||
const struct rfkill_event *event) {
|
const struct rfkill_event *event) {
|
||||||
|
|
||||||
_cleanup_udev_device_unref_ struct udev_device *device = NULL;
|
|
||||||
_cleanup_free_ char *state_file = NULL;
|
_cleanup_free_ char *state_file = NULL;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
@ -274,11 +271,7 @@ static int save_state(
|
|||||||
assert(udev);
|
assert(udev);
|
||||||
assert(event);
|
assert(event);
|
||||||
|
|
||||||
r = find_device(udev, event, &device);
|
r = determine_state_file(udev, event, &state_file);
|
||||||
if (r < 0)
|
|
||||||
return r;
|
|
||||||
|
|
||||||
r = determine_state_file(udev, event, device, &state_file);
|
|
||||||
if (r < 0)
|
if (r < 0)
|
||||||
return r;
|
return r;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user