summaryrefslogtreecommitdiff
path: root/src/basic/socket-util.h
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-10-18 19:48:18 +0200
committerLennart Poettering <lennart@poettering.net>2018-10-18 19:50:29 +0200
commit2ff48e981e6cd1ccbfae49943274d9c8319a5e5d (patch)
tree10ec8200518d5d95476033dbb44df30ad7e34bf6 /src/basic/socket-util.h
parent0fef9583615435d41a7724b0c49f530433b4c572 (diff)
downloadsystemd-2ff48e981e6cd1ccbfae49943274d9c8319a5e5d.tar.gz
tree-wide: introduce setsockopt_int() helper and make use of it everywhere
As suggested by @heftig: https://github.com/systemd/systemd/commit/6d5e65f6454212cd400d0ebda34978a9f20cc26a#commitcomment-30938667
Diffstat (limited to 'src/basic/socket-util.h')
-rw-r--r--src/basic/socket-util.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/basic/socket-util.h b/src/basic/socket-util.h
index d2e00f2f64..8090e21657 100644
--- a/src/basic/socket-util.h
+++ b/src/basic/socket-util.h
@@ -190,3 +190,10 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng
int socket_ioctl_fd(void);
int sockaddr_un_set_path(struct sockaddr_un *ret, const char *path);
+
+static inline int setsockopt_int(int fd, int level, int optname, int value) {
+ if (setsockopt(fd, level, optname, &value, sizeof(value)) < 0)
+ return -errno;
+
+ return 0;
+}