mirror of
https://github.com/systemd/systemd.git
synced 2024-11-02 02:21:44 +03:00
sd-device: make several sd_device_get_*() accepts NULL pointer for buffer of returned value
When only the existence of the value are important, then we can set NULL now.
This commit is contained in:
parent
7b32820444
commit
78ffb476f2
@ -271,7 +271,6 @@ int device_get_devnode_mode(sd_device *device, mode_t *mode) {
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(mode);
|
||||
|
||||
r = device_read_db(device);
|
||||
if (r < 0)
|
||||
@ -280,7 +279,8 @@ int device_get_devnode_mode(sd_device *device, mode_t *mode) {
|
||||
if (device->devmode == (mode_t) -1)
|
||||
return -ENOENT;
|
||||
|
||||
*mode = device->devmode;
|
||||
if (mode)
|
||||
*mode = device->devmode;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -289,7 +289,6 @@ int device_get_devnode_uid(sd_device *device, uid_t *uid) {
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(uid);
|
||||
|
||||
r = device_read_db(device);
|
||||
if (r < 0)
|
||||
@ -298,7 +297,8 @@ int device_get_devnode_uid(sd_device *device, uid_t *uid) {
|
||||
if (device->devuid == (uid_t) -1)
|
||||
return -ENOENT;
|
||||
|
||||
*uid = device->devuid;
|
||||
if (uid)
|
||||
*uid = device->devuid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -327,7 +327,6 @@ int device_get_devnode_gid(sd_device *device, gid_t *gid) {
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(gid);
|
||||
|
||||
r = device_read_db(device);
|
||||
if (r < 0)
|
||||
@ -336,7 +335,8 @@ int device_get_devnode_gid(sd_device *device, gid_t *gid) {
|
||||
if (device->devgid == (gid_t) -1)
|
||||
return -ENOENT;
|
||||
|
||||
*gid = device->devgid;
|
||||
if (gid)
|
||||
*gid = device->devgid;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -726,7 +726,6 @@ int device_get_watch_handle(sd_device *device, int *handle) {
|
||||
int r;
|
||||
|
||||
assert(device);
|
||||
assert(handle);
|
||||
|
||||
r = device_read_db(device);
|
||||
if (r < 0)
|
||||
@ -735,7 +734,8 @@ int device_get_watch_handle(sd_device *device, int *handle) {
|
||||
if (device->watch_handle < 0)
|
||||
return -ENOENT;
|
||||
|
||||
*handle = device->watch_handle;
|
||||
if (handle)
|
||||
*handle = device->watch_handle;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -572,7 +572,6 @@ _public_ int sd_device_get_ifindex(sd_device *device, int *ifindex) {
|
||||
int r;
|
||||
|
||||
assert_return(device, -EINVAL);
|
||||
assert_return(ifindex, -EINVAL);
|
||||
|
||||
r = device_read_uevent_file(device);
|
||||
if (r < 0)
|
||||
@ -581,7 +580,8 @@ _public_ int sd_device_get_ifindex(sd_device *device, int *ifindex) {
|
||||
if (device->ifindex <= 0)
|
||||
return -ENOENT;
|
||||
|
||||
*ifindex = device->ifindex;
|
||||
if (ifindex)
|
||||
*ifindex = device->ifindex;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -889,7 +889,6 @@ _public_ int sd_device_get_devnum(sd_device *device, dev_t *devnum) {
|
||||
int r;
|
||||
|
||||
assert_return(device, -EINVAL);
|
||||
assert_return(devnum, -EINVAL);
|
||||
|
||||
r = device_read_uevent_file(device);
|
||||
if (r < 0)
|
||||
@ -898,7 +897,8 @@ _public_ int sd_device_get_devnum(sd_device *device, dev_t *devnum) {
|
||||
if (major(device->devnum) <= 0)
|
||||
return -ENOENT;
|
||||
|
||||
*devnum = device->devnum;
|
||||
if (devnum)
|
||||
*devnum = device->devnum;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1677,7 +1677,6 @@ _public_ int sd_device_get_property_value(sd_device *device, const char *key, co
|
||||
|
||||
assert_return(device, -EINVAL);
|
||||
assert_return(key, -EINVAL);
|
||||
assert_return(_value, -EINVAL);
|
||||
|
||||
r = device_properties_prepare(device);
|
||||
if (r < 0)
|
||||
@ -1687,7 +1686,8 @@ _public_ int sd_device_get_property_value(sd_device *device, const char *key, co
|
||||
if (!value)
|
||||
return -ENOENT;
|
||||
|
||||
*_value = value;
|
||||
if (_value)
|
||||
*_value = value;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user