linux-wpan.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] iwpan: fix clang compiler warning on absolute-value
@ 2018-12-06 20:26 Stefan Schmidt
  2018-12-06 20:26 ` [PATCH 2/2] examples: fix wrongly used unsigned attribute Stefan Schmidt
  2018-12-19 13:33 ` [PATCH 1/2] iwpan: fix clang compiler warning on absolute-value Stefan Schmidt
  0 siblings, 2 replies; 4+ messages in thread
From: Stefan Schmidt @ 2018-12-06 20:26 UTC (permalink / raw)
  To: linux-wpan; +Cc: aring, Stefan Schmidt

Our CI found this when building with clang (seems to have
the option on by deafult)

iwpan.c:469:13: warning: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
        cmd_size = abs((long)&__section_set - (long)&__section_get);
                   ^
iwpan.c:469:13: note: use function 'labs' instead
        cmd_size = abs((long)&__section_set - (long)&__section_get);
                   ^~~
                   labs

This also follows a change in iw, where we derived from.

Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
---
 src/iwpan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/iwpan.c b/src/iwpan.c
index e7781fd..fb7bef1 100644
--- a/src/iwpan.c
+++ b/src/iwpan.c
@@ -466,7 +466,7 @@ int main(int argc, char **argv)
 	int err;
 
 	/* calculate command size including padding */
-	cmd_size = abs((long)&__section_set - (long)&__section_get);
+	cmd_size = labs((long)&__section_set - (long)&__section_get);
 	/* strip off self */
 	argc--;
 	argv0 = *argv++;
-- 
2.17.2

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

* [PATCH 2/2] examples: fix wrongly used unsigned attribute
  2018-12-06 20:26 [PATCH 1/2] iwpan: fix clang compiler warning on absolute-value Stefan Schmidt
@ 2018-12-06 20:26 ` Stefan Schmidt
  2018-12-19 13:33   ` Stefan Schmidt
  2018-12-19 13:33 ` [PATCH 1/2] iwpan: fix clang compiler warning on absolute-value Stefan Schmidt
  1 sibling, 1 reply; 4+ messages in thread
From: Stefan Schmidt @ 2018-12-06 20:26 UTC (permalink / raw)
  To: linux-wpan; +Cc: aring, Stefan Schmidt

We are passing this buffer into sprintf later which
expects signed. Its a constant string anyway, so
it does not matter for us. Fixes -Wpointer-sign values
spotted by our CI system.

Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
---
 examples/af_ieee802154_tx.c | 2 +-
 examples/af_inet6_tx.c      | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/af_ieee802154_tx.c b/examples/af_ieee802154_tx.c
index e85a109..faad17e 100644
--- a/examples/af_ieee802154_tx.c
+++ b/examples/af_ieee802154_tx.c
@@ -55,7 +55,7 @@ int main(int argc, char *argv[]) {
 	int sd;
 	ssize_t len;
 	struct sockaddr_ieee802154 dst;
-	unsigned char buf[MAX_PACKET_LEN + 1];
+	char buf[MAX_PACKET_LEN + 1];
 	/* IEEE 802.15.4 extended send address, adapt to your setup */
 	uint8_t long_addr[IEEE802154_ADDR_LEN] = {0xd6, 0x55, 0x2c, 0xd6, 0xe4, 0x1c, 0xeb, 0x57};
 
diff --git a/examples/af_inet6_tx.c b/examples/af_inet6_tx.c
index 9fe7491..a62f730 100644
--- a/examples/af_inet6_tx.c
+++ b/examples/af_inet6_tx.c
@@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
 	int ret, sd;
 	struct sockaddr_in6 dst;
 	struct ifreq ifr;
-	unsigned char buf[MAX_PACKET_LEN + 1];
+	char buf[MAX_PACKET_LEN + 1];
 
 	/* Create IPv6 address family socket for the SOCK_DGRAM type */
 	sd = socket(PF_INET6, SOCK_DGRAM, 0);
-- 
2.17.2

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

* Re: [PATCH 1/2] iwpan: fix clang compiler warning on absolute-value
  2018-12-06 20:26 [PATCH 1/2] iwpan: fix clang compiler warning on absolute-value Stefan Schmidt
  2018-12-06 20:26 ` [PATCH 2/2] examples: fix wrongly used unsigned attribute Stefan Schmidt
@ 2018-12-19 13:33 ` Stefan Schmidt
  1 sibling, 0 replies; 4+ messages in thread
From: Stefan Schmidt @ 2018-12-19 13:33 UTC (permalink / raw)
  To: linux-wpan; +Cc: aring

Hello.

On 06.12.18 21:26, Stefan Schmidt wrote:
> Our CI found this when building with clang (seems to have
> the option on by deafult)
> 
> iwpan.c:469:13: warning: absolute value function 'abs' given an argument of type 'long' but has parameter of type 'int' which may cause truncation of value [-Wabsolute-value]
>         cmd_size = abs((long)&__section_set - (long)&__section_get);
>                    ^
> iwpan.c:469:13: note: use function 'labs' instead
>         cmd_size = abs((long)&__section_set - (long)&__section_get);
>                    ^~~
>                    labs
> 
> This also follows a change in iw, where we derived from.
> 
> Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
> ---
>  src/iwpan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/iwpan.c b/src/iwpan.c
> index e7781fd..fb7bef1 100644
> --- a/src/iwpan.c
> +++ b/src/iwpan.c
> @@ -466,7 +466,7 @@ int main(int argc, char **argv)
>  	int err;
>  
>  	/* calculate command size including padding */
> -	cmd_size = abs((long)&__section_set - (long)&__section_get);
> +	cmd_size = labs((long)&__section_set - (long)&__section_get);
>  	/* strip off self */
>  	argc--;
>  	argv0 = *argv++;
> 

This patch has now been applied to wpan-tools.

regards
Stefan Schmidt

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

* Re: [PATCH 2/2] examples: fix wrongly used unsigned attribute
  2018-12-06 20:26 ` [PATCH 2/2] examples: fix wrongly used unsigned attribute Stefan Schmidt
@ 2018-12-19 13:33   ` Stefan Schmidt
  0 siblings, 0 replies; 4+ messages in thread
From: Stefan Schmidt @ 2018-12-19 13:33 UTC (permalink / raw)
  To: linux-wpan; +Cc: aring

Hello.

On 06.12.18 21:26, Stefan Schmidt wrote:
> We are passing this buffer into sprintf later which
> expects signed. Its a constant string anyway, so
> it does not matter for us. Fixes -Wpointer-sign values
> spotted by our CI system.
> 
> Signed-off-by: Stefan Schmidt <stefan@datenfreihafen.org>
> ---
>  examples/af_ieee802154_tx.c | 2 +-
>  examples/af_inet6_tx.c      | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/examples/af_ieee802154_tx.c b/examples/af_ieee802154_tx.c
> index e85a109..faad17e 100644
> --- a/examples/af_ieee802154_tx.c
> +++ b/examples/af_ieee802154_tx.c
> @@ -55,7 +55,7 @@ int main(int argc, char *argv[]) {
>  	int sd;
>  	ssize_t len;
>  	struct sockaddr_ieee802154 dst;
> -	unsigned char buf[MAX_PACKET_LEN + 1];
> +	char buf[MAX_PACKET_LEN + 1];
>  	/* IEEE 802.15.4 extended send address, adapt to your setup */
>  	uint8_t long_addr[IEEE802154_ADDR_LEN] = {0xd6, 0x55, 0x2c, 0xd6, 0xe4, 0x1c, 0xeb, 0x57};
>  
> diff --git a/examples/af_inet6_tx.c b/examples/af_inet6_tx.c
> index 9fe7491..a62f730 100644
> --- a/examples/af_inet6_tx.c
> +++ b/examples/af_inet6_tx.c
> @@ -35,7 +35,7 @@ int main(int argc, char *argv[]) {
>  	int ret, sd;
>  	struct sockaddr_in6 dst;
>  	struct ifreq ifr;
> -	unsigned char buf[MAX_PACKET_LEN + 1];
> +	char buf[MAX_PACKET_LEN + 1];
>  
>  	/* Create IPv6 address family socket for the SOCK_DGRAM type */
>  	sd = socket(PF_INET6, SOCK_DGRAM, 0);
> 

This patch has now been applied to wpan-tools.

regards
Stefan Schmidt

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

end of thread, other threads:[~2018-12-19 13:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-06 20:26 [PATCH 1/2] iwpan: fix clang compiler warning on absolute-value Stefan Schmidt
2018-12-06 20:26 ` [PATCH 2/2] examples: fix wrongly used unsigned attribute Stefan Schmidt
2018-12-19 13:33   ` Stefan Schmidt
2018-12-19 13:33 ` [PATCH 1/2] iwpan: fix clang compiler warning on absolute-value Stefan Schmidt

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).