mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] -Wsign-conversion warning on ARM when using CMSG_NXTHDR
@ 2022-02-16 10:35 Christian Eggers
  2022-02-16 18:03 ` Khem Raj
  2022-02-17 12:37 ` [musl] " Christian Eggers
  0 siblings, 2 replies; 3+ messages in thread
From: Christian Eggers @ 2022-02-16 10:35 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 3988 bytes --]

Toolchain: Yocto Linux with poky-tiny
Host platform: openSUSE 15.3 x86_64
Target platform: arm-poky-linux-musleabi (armv7, 32 bit)

When I try to compile libkcapi [1] [2] with current
Yocto/Openembedded master branch, I get the following compiler error:

| ../git/lib/kcapi-kernel-if.c: In function '_kcapi_common_send_meta':
| ../git/lib/kcapi-kernel-if.c:193:26: error: unsigned conversion from 'long int' to 'long unsigned int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
|   193 |                 header = CMSG_NXTHDR(&msg, header);
|       |                          ^~~~~~~~~~~
| ../git/lib/kcapi-kernel-if.c:193:26: error: unsigned conversion from 'long int' to 'long unsigned int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
| ../git/lib/kcapi-kernel-if.c:213:26: error: unsigned conversion from 'long int' to 'long unsigned int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
|   213 |                 header = CMSG_NXTHDR(&msg, header);
|       |                          ^~~~~~~~~~~
| ../git/lib/kcapi-kernel-if.c:213:26: error: unsigned conversion from 'long int' to 'long unsigned int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]

Note: libcapi uses the '-Werror' and  '-Wconversion' flags.

For testing, I created a minimal code snipset (cmsg.c):

#include <stddef.h>
#include <sys/socket.h>

void foo(void)
{
        struct msghdr msg = {0};
        struct cmsghdr *header = NULL;

        header = CMSG_FIRSTHDR(&msg);
        header = CMSG_NXTHDR(&msg, header);
}

# arm-poky-linux-musleabi-gcc   --sysroot=<...> -Werror -Wconversion   -c -o cmsg.o cmsg.c
cmsg.c: In function 'foo':
cmsg.c:10:18: error: unsigned conversion from 'long int' to 'long unsigned int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
   10 |         header = CMSG_NXTHDR(&msg, header);
      |                  ^~~~~~~~~~~
cmsg.c:10:18: error: unsigned conversion from 'long int' to 'long unsigned int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]


When replace CMSG_NXTHDR() by the expanded macro code, I get the following errors:

cmsg.c: In function 'foo':
cmsg.c:12:46: error: unsigned conversion from 'long int' to 'long unsigned int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
   12 |     (((header)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)) + sizeof(struct cmsghdr) >= ((unsigned char *)(&msg)->msg_control + (&msg)->msg_controllen) - (unsigned char *)(header) \
      |                                              ^
cmsg.c:13:99: error: unsigned conversion from 'long int' to 'long unsigned int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
   13 |     ? 0 : (struct cmsghdr *)((unsigned char *)(header) + (((header)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))));
      |                                                                                                   ^


[1] https://git.openembedded.org/meta-openembedded/tree/meta-oe/recipes-crypto/libkcapi?h=master
[2] https://github.com/smuellerDD/libkcapi/tree/2936ecd060c299157ac880650ba2c9fd94d27bb1




_______________________________________________________
Christian
Eggers
Software Engineer
​
ARRI
Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Arriweg 17,
83071
Stephanskirchen
www.arri.com

+49 8036 3009-3118
CEggers@arri.de

​
Get all the latest information from www.arri.com, Facebook, Twitter, Instagram and YouTube.

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRA 57918
Persönlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRB 54477
Geschäftsführer: Dr. Michael Neuhäuser; Stephan Schenk; Walter Trauninger; Markus Zeiler

​

[-- Attachment #1.2: Type: text/html, Size: 13143 bytes --]

[-- Attachment #2: image092396.png --]
[-- Type: image/png, Size: 528 bytes --]

[-- Attachment #3: image623061.png --]
[-- Type: image/png, Size: 824 bytes --]

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

* Re: [musl] -Wsign-conversion warning on ARM when using CMSG_NXTHDR
  2022-02-16 10:35 [musl] -Wsign-conversion warning on ARM when using CMSG_NXTHDR Christian Eggers
@ 2022-02-16 18:03 ` Khem Raj
  2022-02-17 12:37 ` [musl] " Christian Eggers
  1 sibling, 0 replies; 3+ messages in thread
From: Khem Raj @ 2022-02-16 18:03 UTC (permalink / raw)
  To: musl


[-- Attachment #1.1: Type: text/plain, Size: 4400 bytes --]

On Wed, Feb 16, 2022 at 4:42 AM Christian Eggers <ceggers@arri.de> wrote:

> Toolchain: Yocto Linux with poky-tiny
> Host platform: openSUSE 15.3 x86_64
> Target platform: arm-poky-linux-musleabi (armv7, 32 bit)
>
> When I try to compile libkcapi [1] [2] with current
> Yocto/Openembedded master branch, I get the following compiler error:
>
> | ../git/lib/kcapi-kernel-if.c: In function '_kcapi_common_send_meta':
> | ../git/lib/kcapi-kernel-if.c:193:26: error: unsigned conversion from
> 'long int' to 'long unsigned int' changes value from '-4' to '4294967292'
> [-Werror=sign-conversion]
> | 193 | header = CMSG_NXTHDR(&msg, header);
> | | ^~~~~~~~~~~
> | ../git/lib/kcapi-kernel-if.c:193:26: error: unsigned conversion from
> 'long int' to 'long unsigned int' changes value from '-4' to '4294967292'
> [-Werror=sign-conversion]
> | ../git/lib/kcapi-kernel-if.c:213:26: error: unsigned conversion from
> 'long int' to 'long unsigned int' changes value from '-4' to '4294967292'
> [-Werror=sign-conversion]
> | 213 | header = CMSG_NXTHDR(&msg, header);
> | | ^~~~~~~~~~~
> | ../git/lib/kcapi-kernel-if.c:213:26: error: unsigned conversion from
> 'long int' to 'long unsigned int' changes value from '-4' to '4294967292'
> [-Werror=sign-conversion]
>
> Note: libcapi uses the '-Werror' and '-Wconversion' flags.
>
> For testing, I created a minimal code snipset (cmsg.c):
>
> #include <stddef.h>
> #include <sys/socket.h>
>
> void foo(void)
> {
> struct msghdr msg = {0};
> struct cmsghdr *header = NULL;
>
> header = CMSG_FIRSTHDR(&msg);
> header = CMSG_NXTHDR(&msg, header);
> }
>
> # arm-poky-linux-musleabi-gcc --sysroot=<...> -Werror -Wconversion -c -o
> cmsg.o cmsg.c
> cmsg.c: In function 'foo':
> cmsg.c:10:18: error: unsigned conversion from 'long int' to 'long unsigned
> int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
> 10 | header = CMSG_NXTHDR(&msg, header);
> | ^~~~~~~~~~~
> cmsg.c:10:18: error: unsigned conversion from 'long int' to 'long unsigned
> int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
>
>
> When replace CMSG_NXTHDR() by the expanded macro code, I get the following
> errors:
>
> cmsg.c: In function 'foo':
> cmsg.c:12:46: error: unsigned conversion from 'long int' to 'long unsigned
> int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
> 12 | (((header)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))
> + sizeof(struct cmsghdr) >= ((unsigned char *)(&msg)->msg_control +
> (&msg)->msg_controllen) - (unsigned char *)(header) \
> | ^
> cmsg.c:13:99: error: unsigned conversion from 'long int' to 'long unsigned
> int' changes value from '-4' to '4294967292' [-Werror=sign-conversion]
> 13 | ? 0 : (struct cmsghdr *)((unsigned char *)(header) +
> (((header)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))));
> | ^
>
> check https://github.com/smuellerDD/libkcapi/pull/131
libkcapi has dropped using -Werror

>
> [1]
> https://git.openembedded.org/meta-openembedded/tree/meta-oe/recipes-crypto/libkcapi?h=master
> [2]
> https://github.com/smuellerDD/libkcapi/tree/2936ecd060c299157ac880650ba2c9fd94d27bb1
>
>
>
> _______________________________________________________
> Christian
> Eggers
> Software Engineer
> ARRI
> Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
> Arriweg 17 ,
> 83071
> Stephanskirchen
>
>
> *www.arri.com * <http://www.arri.com/>
> *+49 8036 3009-3118* <+49%208036%203009-3118>
> *CEggers@arri.de* <CEggers@arri.de>
>
> [image: Orbiter Docking Ring]
> <https://www.arri.com/en/lighting/led/orbiter-accessories/orbiter-dockingring/>
> Get all the latest information from *www.arri.com* <http://www.arri.com/>
> , *Facebook* <https://www.facebook.com/TeamARRI>, *Twitter*
> <https://twitter.com/ARRIChannel>, *Instagram* <http://instagram.com/arri>
>  and *YouTube* <http://www.youtube.com/user/ARRIChannel>.
>
> Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
>
> Sitz: München ‑ Registergericht: Amtsgericht München ‑ Handelsregisternummer: HRA 57918
> Persönlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
>
> Sitz: München ‑ Registergericht: Amtsgericht München ‑ Handelsregisternummer: HRB 54477
>
> Geschäftsführer: Dr. Michael Neuhäuser; Stephan Schenk; Walter Trauninger; Markus Zeiler
>
>
>

[-- Attachment #1.2: Type: text/html, Size: 14149 bytes --]

[-- Attachment #2: image092396.png --]
[-- Type: image/png, Size: 528 bytes --]

[-- Attachment #3: image623061.png --]
[-- Type: image/png, Size: 824 bytes --]

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

* [musl] Re: -Wsign-conversion warning on ARM when using CMSG_NXTHDR
  2022-02-16 10:35 [musl] -Wsign-conversion warning on ARM when using CMSG_NXTHDR Christian Eggers
  2022-02-16 18:03 ` Khem Raj
@ 2022-02-17 12:37 ` Christian Eggers
  1 sibling, 0 replies; 3+ messages in thread
From: Christian Eggers @ 2022-02-17 12:37 UTC (permalink / raw)
  To: musl; +Cc: raj.khem


[-- Attachment #1.1: Type: text/plain, Size: 1288 bytes --]

On Wednesday, 16 February 2022, 10:03:30 -0800, Khem Raj wrote:

> check https://github.com/smuellerDD/libkcapi/pull/131
> libkcapi has dropped using -Werror

Not in master...

https://github.com/smuellerDD/libkcapi/pull/132#issuecomment-1003694101
> smuellerDD commented on 2 Jan:
> > Thanks for spotting it, but dropping -Werror is not the right way. The
> > solution is mentioned in a comment to issue #131 by adding a type
> > conversion. I would be happy to apply such a patch.

regards,
Christian




_______________________________________________________
Christian
Eggers
Software Engineer
​
ARRI
Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Arriweg 17,
83071
Stephanskirchen
www.arri.com

+49 8036 3009-3118
CEggers@arri.de

​
Get all the latest information from www.arri.com, Facebook, Twitter, Instagram and YouTube.

Arnold & Richter Cine Technik GmbH & Co. Betriebs KG
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRA 57918
Persönlich haftender Gesellschafter: Arnold & Richter Cine Technik GmbH
Sitz: München - Registergericht: Amtsgericht München - Handelsregisternummer: HRB 54477
Geschäftsführer: Dr. Michael Neuhäuser; Stephan Schenk; Walter Trauninger; Markus Zeiler

​

[-- Attachment #1.2: Type: text/html, Size: 9925 bytes --]

[-- Attachment #2: image511377.png --]
[-- Type: image/png, Size: 528 bytes --]

[-- Attachment #3: image785483.png --]
[-- Type: image/png, Size: 824 bytes --]

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

end of thread, other threads:[~2022-02-17 12:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-16 10:35 [musl] -Wsign-conversion warning on ARM when using CMSG_NXTHDR Christian Eggers
2022-02-16 18:03 ` Khem Raj
2022-02-17 12:37 ` [musl] " Christian Eggers

Code repositories for project(s) associated with this inbox:

	https://git.vuxu.org/mirror/musl/

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