summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-09-30 22:33:50 +0200
committerLennart Poettering <lennart@poettering.net>2015-09-30 22:33:50 +0200
commit32c6d387bf8bef65edab442d521c2f93bbf2cd2d (patch)
tree26f650e6d6e3c51c748c2b4c545f3a87dbe67696 /src
parent23a749f2857088547c8ef3966e96b37c71510a1b (diff)
parent0260d1d542da73b3358fa659fb1fa634badbf00e (diff)
Merge pull request #1422 from keszybz/sd-daemon-mq-badf
sd-daemon: fix return value for sd_is_mq
Diffstat (limited to 'src')
-rw-r--r--src/libsystemd/sd-daemon/sd-daemon.c9
-rw-r--r--src/systemctl/systemctl.c2
2 files changed, 8 insertions, 3 deletions
diff --git a/src/libsystemd/sd-daemon/sd-daemon.c b/src/libsystemd/sd-daemon/sd-daemon.c
index ba7b8da85f..5fb0b73d02 100644
--- a/src/libsystemd/sd-daemon/sd-daemon.c
+++ b/src/libsystemd/sd-daemon/sd-daemon.c
@@ -310,10 +310,15 @@ _public_ int sd_is_socket_unix(int fd, int type, int listening, const char *path
_public_ int sd_is_mq(int fd, const char *path) {
struct mq_attr attr;
- assert_return(fd >= 0, -EBADF);
+ /* Check that the fd is valid */
+ assert_return(fcntl(fd, F_GETFD) >= 0, -errno);
- if (mq_getattr(fd, &attr) < 0)
+ if (mq_getattr(fd, &attr) < 0) {
+ if (errno == EBADF)
+ /* A non-mq fd (or an invalid one, but we ruled that out above) */
+ return 0;
return -errno;
+ }
if (path) {
char fpath[PATH_MAX];
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index b8ffcdadec..6d33badba4 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3110,7 +3110,7 @@ static int start_special(int argc, char *argv[], void *userdata) {
return r;
} else if (a == ACTION_EXIT && argc > 1) {
- uint8_t code = 0;
+ uint8_t code;
/* If the exit code is not given on the command line,
* don't reset it to zero: just keep it as it might