[systemd-devel] [PATCH] sd-daemon: fix cppcheck warnings
Sami Kerola
kerolasa at iki.fi
Mon Oct 15 13:05:27 PDT 2012
Found with 'cppcheck --enable=all --inconclusive --std=posix' while
working with util-linux, which has a copy of this file.
[misc-utils/sd-daemon.c:91]: (style) Checking if unsigned variable 'l' is \
less than zero.
[misc-utils/sd-daemon.c:254]: (warning) Comparison of a boolean \
expression with an integer.
[misc-utils/sd-daemon.c:363]: (style) Checking if unsigned variable \
'length' is less than zero.
[misc-utils/sd-daemon.c:366]: (style) Checking if unsigned variable \
'length' is less than zero.
CC: Dave Reisner <d at falconindy.com>
References: http://www.spinics.net/lists/util-linux-ng/msg07031.html
Signed-off-by: Sami Kerola <kerolasa at iki.fi>
---
src/libsystemd-daemon/sd-daemon.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/libsystemd-daemon/sd-daemon.c b/src/libsystemd-daemon/sd-daemon.c
index 863ac75..03cde39 100644
--- a/src/libsystemd-daemon/sd-daemon.c
+++ b/src/libsystemd-daemon/sd-daemon.c
@@ -88,7 +88,7 @@ _sd_export_ int sd_listen_fds(int unset_environment) {
goto finish;
}
- if (!p || *p || l <= 0) {
+ if (!p || *p || l == 0) {
r = -EINVAL;
goto finish;
}
@@ -249,7 +249,7 @@ static int sd_is_socket_internal(int fd, int type, int listening) {
if (l != sizeof(accepting))
return -EINVAL;
- if (!accepting != !listening)
+ if ((!accepting) != (!listening))
return 0;
}
@@ -358,10 +358,10 @@ _sd_export_ int sd_is_socket_unix(int fd, int type, int listening, const char *p
return 0;
if (path) {
- if (length <= 0)
+ if (length == 0)
length = strlen(path);
- if (length <= 0)
+ if (length == 0)
/* Unnamed socket */
return l == offsetof(struct sockaddr_un, sun_path);
--
1.7.12.3
More information about the systemd-devel
mailing list