summaryrefslogtreecommitdiff
path: root/src/udev/udev-ctrl.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-15 19:21:37 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-15 19:40:51 +0200
commit6d5e65f6454212cd400d0ebda34978a9f20cc26a (patch)
tree844cd4d517956481a0963598edf586ae454524a0 /src/udev/udev-ctrl.c
parent8e8132c6b849a0aa34dbe8d97027beb50f71f1e3 (diff)
downloadsystemd-6d5e65f6454212cd400d0ebda34978a9f20cc26a.tar.gz
tree-wide: add a single version of "static const int one = 1"
All over the place we define local variables for the various sockopts that take a bool-like "int" value. Sometimes they are const, sometimes static, sometimes both, sometimes neither. Let's clean this up, introduce a common const variable "const_int_one" (as well as one matching "const_int_zero") and use it everywhere, all acorss the codebase.
Diffstat (limited to 'src/udev/udev-ctrl.c')
-rw-r--r--src/udev/udev-ctrl.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 84909b3e15..312c0b2ae8 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -73,7 +73,6 @@ struct udev_ctrl_connection {
struct udev_ctrl *udev_ctrl_new_from_fd(int fd) {
struct udev_ctrl *uctrl;
- const int on = 1;
int r;
uctrl = new0(struct udev_ctrl, 1);
@@ -97,7 +96,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(int fd) {
* FIXME: remove it as soon as we can depend on this:
* http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=90c6bd34f884cd9cee21f1d152baf6c18bcac949
*/
- r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
if (r < 0)
log_warning_errno(errno, "could not set SO_PASSCRED: %m");
@@ -164,7 +163,6 @@ int udev_ctrl_get_fd(struct udev_ctrl *uctrl) {
struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
struct udev_ctrl_connection *conn;
struct ucred ucred = {};
- const int on = 1;
int r;
conn = new(struct udev_ctrl_connection, 1);
@@ -192,7 +190,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
}
/* enable receiving of the sender credentials in the messages */
- r = setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
+ r = setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
if (r < 0)
log_warning_errno(errno, "could not set SO_PASSCRED: %m");