connman.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/3] Fixup clang error messages
@ 2021-10-12  7:06 Daniel Wagner
  2021-10-12  7:06 ` [PATCH v1 1/3] build: Only enable -Wcast-align for gcc Daniel Wagner
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Daniel Wagner @ 2021-10-12  7:06 UTC (permalink / raw)
  To: connman; +Cc: Daniel Wagner

Based on Emmanuel's patches[1] I tried to get clang to compile
ConnMan.  -Wcast-align seems a bit too much for clang so I disabled it
for clang.  The rest are couple of fallouts. Nothing serious. Though I
was not able to reproduce the maybe-unitialized warnings.

[1] https://lore.kernel.org/all/MRZP264MB15449CB6E42AF281B16F54FE93D99@MRZP264MB1544.FRAP264.PROD.OUTLOOK.COM/

Daniel Wagner (3):
  build: Only enable -Wcast-align for gcc
  inet: Remove unused ipv6_addr_advert_mult
  gsupplicant: Fix error return type

 acinclude.m4             | 4 +++-
 gsupplicant/supplicant.c | 4 ++--
 src/inet.c               | 7 -------
 3 files changed, 5 insertions(+), 10 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 1/3] build: Only enable -Wcast-align for gcc
  2021-10-12  7:06 [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
@ 2021-10-12  7:06 ` Daniel Wagner
  2021-10-12  7:06 ` [PATCH v1 2/3] inet: Remove unused ipv6_addr_advert_mult Daniel Wagner
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2021-10-12  7:06 UTC (permalink / raw)
  To: connman; +Cc: Daniel Wagner

clang -Wcast-align is very unhappy with various alignments of external
data structures and access helper such as CMSG_DATA. While its
worthwhile to fix these in the long run, let's disable the cast-align
warning for the time. This aligns it with iwd.
---
 acinclude.m4 | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 9e8e0dc5e8b2..262465d8085d 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -21,7 +21,9 @@ AC_DEFUN([COMPILER_FLAGS], [
 		CFLAGS+=" -Wdeclaration-after-statement"
 		CFLAGS+=" -Wmissing-declarations"
 		CFLAGS+=" -Wredundant-decls"
-		CFLAGS+=" -Wcast-align"
+                if ( $CC -v 2>/dev/null | grep "gcc version" ); then
+                        CFLAGS+=" -Wcast-align"
+                fi
 		CFLAGS="$CFLAGS -DG_DISABLE_DEPRECATED"
 	fi
 ])
-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 2/3] inet: Remove unused ipv6_addr_advert_mult
  2021-10-12  7:06 [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
  2021-10-12  7:06 ` [PATCH v1 1/3] build: Only enable -Wcast-align for gcc Daniel Wagner
@ 2021-10-12  7:06 ` Daniel Wagner
  2021-10-12  7:06 ` [PATCH v1 3/3] gsupplicant: Fix error return type Daniel Wagner
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2021-10-12  7:06 UTC (permalink / raw)
  To: connman; +Cc: Daniel Wagner

clang complains with

src/inet.c:1839:20: error: unused function 'ipv6_addr_advert_mult' [-Werror,-Wunused-function]
static inline void ipv6_addr_advert_mult(const struct in6_addr *addr,
                   ^
Remove the ipv6_addr_advert_mult function.
---
 src/inet.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/src/inet.c b/src/inet.c
index df94d1eebaa7..4039a73ca498 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -1836,13 +1836,6 @@ int __connman_inet_ipv6_send_rs(int index, int timeout,
 	return 0;
 }
 
-static inline void ipv6_addr_advert_mult(const struct in6_addr *addr,
-					struct in6_addr *advert)
-{
-	ipv6_addr_set(advert, htonl(0xFF020000), 0, htonl(0x2),
-			htonl(0xFF000000) | addr->s6_addr32[3]);
-}
-
 #define MSG_SIZE_SEND 1452
 
 static int inc_len(int len, int inc)
-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v1 3/3] gsupplicant: Fix error return type
  2021-10-12  7:06 [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
  2021-10-12  7:06 ` [PATCH v1 1/3] build: Only enable -Wcast-align for gcc Daniel Wagner
  2021-10-12  7:06 ` [PATCH v1 2/3] inet: Remove unused ipv6_addr_advert_mult Daniel Wagner
@ 2021-10-12  7:06 ` Daniel Wagner
  2021-10-15  7:03 ` [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
  2021-10-15  8:55 ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2021-10-12  7:06 UTC (permalink / raw)
  To: connman; +Cc: Daniel Wagner

clang complains with:

gsupplicant/supplicant.c:1220:10: error: expression which evaluates to zero treated as a null pointer constant of type 'const char *' [-Werror,-Wnon-literal-null-conversion]
                return G_SUPPLICANT_MODE_UNKNOWN;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
gsupplicant/supplicant.c:1228:10: error: expression which evaluates to zero treated as a null pointer constant of type 'const char *' [-Werror,-Wnon-literal-null-conversion]
                return G_SUPPLICANT_SECURITY_UNKNOWN;
                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Return NULL instead of the enum. In both cases the enum is 0, so there
is no change.
---
 gsupplicant/supplicant.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gsupplicant/supplicant.c b/gsupplicant/supplicant.c
index 8316f48ae0bf..470d99eb36b1 100644
--- a/gsupplicant/supplicant.c
+++ b/gsupplicant/supplicant.c
@@ -1217,7 +1217,7 @@ const char *g_supplicant_network_get_path(GSupplicantNetwork *network)
 const char *g_supplicant_network_get_mode(GSupplicantNetwork *network)
 {
 	if (!network)
-		return G_SUPPLICANT_MODE_UNKNOWN;
+		return NULL;
 
 	return mode2string(network->mode);
 }
@@ -1225,7 +1225,7 @@ const char *g_supplicant_network_get_mode(GSupplicantNetwork *network)
 const char *g_supplicant_network_get_security(GSupplicantNetwork *network)
 {
 	if (!network)
-		return G_SUPPLICANT_SECURITY_UNKNOWN;
+		return NULL;
 
 	return security2string(network->security);
 }
-- 
2.33.0


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/3] Fixup clang error messages
  2021-10-12  7:06 [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
                   ` (2 preceding siblings ...)
  2021-10-12  7:06 ` [PATCH v1 3/3] gsupplicant: Fix error return type Daniel Wagner
@ 2021-10-15  7:03 ` Daniel Wagner
  2021-10-15  8:55 ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  4 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2021-10-15  7:03 UTC (permalink / raw)
  To: connman

On Tue, Oct 12, 2021 at 09:06:45AM +0200, Daniel Wagner wrote:
> Based on Emmanuel's patches[1] I tried to get clang to compile
> ConnMan.  -Wcast-align seems a bit too much for clang so I disabled it
> for clang.  The rest are couple of fallouts. Nothing serious. Though I
> was not able to reproduce the maybe-unitialized warnings.

Patches applied

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v1 0/3] Fixup clang error messages
  2021-10-12  7:06 [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
                   ` (3 preceding siblings ...)
  2021-10-15  7:03 ` [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
@ 2021-10-15  8:55 ` VAUTRIN Emmanuel (Canal Plus Prestataire)
  2021-10-15  9:25   ` Daniel Wagner
  4 siblings, 1 reply; 7+ messages in thread
From: VAUTRIN Emmanuel (Canal Plus Prestataire) @ 2021-10-15  8:55 UTC (permalink / raw)
  To: Daniel Wagner, connman

Hi Daniel
 
> Based on Emmanuel's patches[1] I tried to get clang to compile
> ConnMan.  -Wcast-align seems a bit too much for clang so I disabled it
> for clang.  The rest are couple of fallouts. Nothing serious. Though I
> was not able to reproduce the maybe-unitialized warnings.
Strange that you have not faced the same compilation issues.
Maybe it is related to the Yocto integration I am using.
Have you tried to activate maybe-uninitialized warning or do you think it is
not necessary to check this one before providing patches?


Best Regards,

Emmanuel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v1 0/3] Fixup clang error messages
  2021-10-15  8:55 ` VAUTRIN Emmanuel (Canal Plus Prestataire)
@ 2021-10-15  9:25   ` Daniel Wagner
  0 siblings, 0 replies; 7+ messages in thread
From: Daniel Wagner @ 2021-10-15  9:25 UTC (permalink / raw)
  To: VAUTRIN Emmanuel (Canal Plus Prestataire); +Cc: connman

On Fri, Oct 15, 2021 at 08:55:10AM +0000, VAUTRIN Emmanuel (Canal Plus Prestataire) wrote:
> > Based on Emmanuel's patches[1] I tried to get clang to compile
> > ConnMan.  -Wcast-align seems a bit too much for clang so I disabled it
> > for clang.  The rest are couple of fallouts. Nothing serious. Though I
> > was not able to reproduce the maybe-unitialized warnings.
> Strange that you have not faced the same compilation issues.

This is way it's good not all have the same toolchain running. So I am
not completely surprised I don't see it.

> Maybe it is related to the Yocto integration I am using.

I am using the clang from my distro (Tubmleweed). Maybe clang can be
configured to behave differently. No idea.

> Have you tried to activate maybe-uninitialized warning or do you think it is
> not necessary to check this one before providing patches?

Yes, I added maybe-uninitialized but still no report from clang. It's
totally fine to use different compile flags. But make sure you add them
to your commit message. For example the align-cast errors reported by
clang is something I'd likely be ignoring. Some of them make sense to
address but some are not in our hands, e.g. system include headers.

IIRC, your patch fixes a real problem. I was unhappy on the commit
message and all in on patch.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-10-15  9:25 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-12  7:06 [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
2021-10-12  7:06 ` [PATCH v1 1/3] build: Only enable -Wcast-align for gcc Daniel Wagner
2021-10-12  7:06 ` [PATCH v1 2/3] inet: Remove unused ipv6_addr_advert_mult Daniel Wagner
2021-10-12  7:06 ` [PATCH v1 3/3] gsupplicant: Fix error return type Daniel Wagner
2021-10-15  7:03 ` [PATCH v1 0/3] Fixup clang error messages Daniel Wagner
2021-10-15  8:55 ` VAUTRIN Emmanuel (Canal Plus Prestataire)
2021-10-15  9:25   ` Daniel Wagner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).