daandemeyer / rpms / systemd

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