Re: [systemd-devel] [PATCH] fix compiler warning
On Sun, Mar 15, 2015 at 4:53 AM, Ronny Chevalier chevalier.ro...@gmail.com wrote: 2015-03-14 17:54 GMT+01:00 Shawn Landden sh...@churchofgit.com: On Sat, Mar 14, 2015 at 6:31 AM, Ronny Chevalier chevalier.ro...@gmail.com wrote: 2015-03-11 4:42 GMT+01:00 Shawn Landden sh...@churchofgit.com: warning: pointer/integer type mismatch in conditional expression --- src/shared/socket-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 5820279..73e1177 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -475,8 +475,8 @@ int sockaddr_port(const struct sockaddr *_sa) { return -EAFNOSUPPORT; return ntohs(sa-sa.sa_family == AF_INET6 ? - sa-in6.sin6_port : - sa-in.sin_port); + (uint16_t)sa-in6.sin6_port : + (uint16_t)sa-in.sin_port); } Hi, I don't see any warning, and the man (man netinet_in.h) says that sin_port and sin6_port are of type in_port_t which is equivalent to uint16_t. in_port_t and in6_port_t. If the type returned by a ternary operator is not identical gcc-5 warns, even though they are both backed by uint16_t and thus there is no violation. netinet/in.h does not provide in6_port_t according to the manpage. I even check with the glibc and on master there is no mention of in6_port_t. Maybe you are using another libc? You are right, but has been a bug in an early gcc-5, which quite a few incorrect warnings. Maybe I'm missing something? Ronny ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Shawn Landden ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Shawn Landden ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] fix compiler warning
2015-03-14 17:54 GMT+01:00 Shawn Landden sh...@churchofgit.com: On Sat, Mar 14, 2015 at 6:31 AM, Ronny Chevalier chevalier.ro...@gmail.com wrote: 2015-03-11 4:42 GMT+01:00 Shawn Landden sh...@churchofgit.com: warning: pointer/integer type mismatch in conditional expression --- src/shared/socket-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 5820279..73e1177 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -475,8 +475,8 @@ int sockaddr_port(const struct sockaddr *_sa) { return -EAFNOSUPPORT; return ntohs(sa-sa.sa_family == AF_INET6 ? - sa-in6.sin6_port : - sa-in.sin_port); + (uint16_t)sa-in6.sin6_port : + (uint16_t)sa-in.sin_port); } Hi, I don't see any warning, and the man (man netinet_in.h) says that sin_port and sin6_port are of type in_port_t which is equivalent to uint16_t. in_port_t and in6_port_t. If the type returned by a ternary operator is not identical gcc-5 warns, even though they are both backed by uint16_t and thus there is no violation. netinet/in.h does not provide in6_port_t according to the manpage. I even check with the glibc and on master there is no mention of in6_port_t. Maybe you are using another libc? Maybe I'm missing something? Ronny ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Shawn Landden ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] fix compiler warning
On Sat, Mar 14, 2015 at 6:31 AM, Ronny Chevalier chevalier.ro...@gmail.com wrote: 2015-03-11 4:42 GMT+01:00 Shawn Landden sh...@churchofgit.com: warning: pointer/integer type mismatch in conditional expression --- src/shared/socket-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 5820279..73e1177 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -475,8 +475,8 @@ int sockaddr_port(const struct sockaddr *_sa) { return -EAFNOSUPPORT; return ntohs(sa-sa.sa_family == AF_INET6 ? - sa-in6.sin6_port : - sa-in.sin_port); + (uint16_t)sa-in6.sin6_port : + (uint16_t)sa-in.sin_port); } Hi, I don't see any warning, and the man (man netinet_in.h) says that sin_port and sin6_port are of type in_port_t which is equivalent to uint16_t. in_port_t and in6_port_t. If the type returned by a ternary operator is not identical gcc-5 warns, even though they are both backed by uint16_t and thus there is no violation. Maybe I'm missing something? Ronny ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel -- Shawn Landden ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
[systemd-devel] [PATCH] fix compiler warning
warning: pointer/integer type mismatch in conditional expression --- src/shared/socket-util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 5820279..73e1177 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -475,8 +475,8 @@ int sockaddr_port(const struct sockaddr *_sa) { return -EAFNOSUPPORT; return ntohs(sa-sa.sa_family == AF_INET6 ? - sa-in6.sin6_port : - sa-in.sin_port); + (uint16_t)sa-in6.sin6_port : + (uint16_t)sa-in.sin_port); } int sockaddr_pretty(const struct sockaddr *_sa, socklen_t salen, bool translate_ipv6, bool include_port, char **ret) { -- 2.2.1.209.g41e5f3a ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel
Re: [systemd-devel] [PATCH] fix compiler warning
On Tue, Dec 16, 2014 at 08:48:34AM +0530, Susant Sahani wrote: src/shared/utf8.c:268:13: warning: unused variable 'd' [-Wunused-variable] int d; Applied. Zbyszek ___ systemd-devel mailing list systemd-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/systemd-devel