bd1529
From 8cff80d7fc28ca04bd6c8e2257b46d96bea338ce Mon Sep 17 00:00:00 2001
bd1529
From: Lennart Poettering <lennart@poettering.net>
bd1529
Date: Thu, 18 Oct 2018 19:48:18 +0200
bd1529
Subject: [PATCH] introduce setsockopt_int() helper
bd1529
bd1529
As suggested by @heftig:
bd1529
bd1529
https://github.com/systemd/systemd/commit/6d5e65f6454212cd400d0ebda34978a9f20cc26a#commitcomment-30938667
bd1529
(cherry picked from commit 2ff48e981e6cd1ccbfae49943274d9c8319a5e5d)
bd1529
bd1529
Related: #1887181
bd1529
---
bd1529
 src/basic/socket-util.h | 7 +++++++
bd1529
 1 file changed, 7 insertions(+)
bd1529
bd1529
diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h
bd1529
index 82781a0de1..616f2e0d05 100644
bd1529
--- a/src/basic/socket-util.h
bd1529
+++ b/src/basic/socket-util.h
bd1529
@@ -183,3 +183,10 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng
bd1529
         })
bd1529
 
bd1529
 int socket_ioctl_fd(void);
bd1529
+
bd1529
+static inline int setsockopt_int(int fd, int level, int optname, int value) {
bd1529
+        if (setsockopt(fd, level, optname, &value, sizeof(value)) < 0)
bd1529
+                return -errno;
bd1529
+
bd1529
+        return 0;
bd1529
+}