diff mbox series

[1/2] iwpan: fix clang compiler warning on absolute-value

Message ID 20181206202602.22176-1-stefan@datenfreihafen.org
State Accepted
Headers show
Series [1/2] iwpan: fix clang compiler warning on absolute-value | expand

Commit Message

Stefan Schmidt Dec. 6, 2018, 8:26 p.m. UTC
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(-)

Comments

Stefan Schmidt Dec. 19, 2018, 1:33 p.m. UTC | #1
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
diff mbox series

Patch

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++;