From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 31504 invoked from network); 16 Feb 2022 18:04:14 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 16 Feb 2022 18:04:14 -0000 Received: (qmail 12161 invoked by uid 550); 16 Feb 2022 18:04:10 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 12122 invoked from network); 16 Feb 2022 18:04:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=0Fjy/Nn6pujDSuiQR6sluvps0413QholB3fya5cKZXg=; b=CdutpFVDk9u13Hdfg7/x7W3o9VEnCbl7RppqcoNdSgFGxqVdOtKcfZ/ZHxWf5BjgWk qXmG6veXLogLaFZwJ22A6QT3kgJGkiRyKbee1tlqmDS3wJ7QaNiv7KqrjShXiJ0qqDL6 XFo7ib6QEvpd74BGPseoPHCJE16kAOT+MAvgL5ZzxjqtSKo0NYZhLHAs+TR9APD2T1BD q0fJhucu5krUjLS2+uaaQshRWeZVZEgfCvlhZ6zydd+tSzv8Ue8JTLfy6qgJ77Mf3gZd XHr2nXDy2EjP8nqeszeCPxkSg/9LX7T1P+zephUfG5Hc9KqI8lSsY2lfPUyEM3hD48Zs unVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=0Fjy/Nn6pujDSuiQR6sluvps0413QholB3fya5cKZXg=; b=Z50RoNArmlvhTFke3PgxL8xCIgqi2VbOXgJK8hz/hZiVGdfEOFAHqaDGqxXeWKUxgS qcV0lBAL4N+Ru8rOf023t2FvuxZtZAf6SCLxjHVZrFRXbVXwfEiD5Da169iJHOqg7cUs UbpLh76HLyfhc258hgNEMSyxNPqFfv4bH5pnVKxH41wEYEQa9BC0DWIopT2BtCkEJe0+ IHkWxiSbnyVJ+6duIhRKv5CHAEsKmnOQQJ1E/z/EowUUFn67asmXV206zJeTl+dOQbcq CJCNrz0G5Oa/9mUflQGP/Iujwev9+C87WDTZhZXErjvB92hQAqQZXvP7y5SZ+HOIT1Ii v4zQ== X-Gm-Message-State: AOAM5301fbeY9UPEds6G0jYrmOA86xohT7oO/ILDZGC5Q3LZH7crLV+1 6N2RgeYnkQD55to14CslURtXvNCx/YSVbh8sZ8kfEBmnizHTPw== X-Google-Smtp-Source: ABdhPJzgT7oZisT18otYBIRN8x3POiK9Mvcku0Usea+RCP0D3YzuuhwS7wNSX+YDg+DC7MoiiRlWBk8nGOhJ2ywTJuY= X-Received: by 2002:a05:622a:1046:b0:2dc:eb87:afd0 with SMTP id f6-20020a05622a104600b002dceb87afd0mr2892097qte.229.1645034637574; Wed, 16 Feb 2022 10:03:57 -0800 (PST) MIME-Version: 1.0 References: <13391677.RDIVbhacDa@localhost.localdomain> In-Reply-To: <13391677.RDIVbhacDa@localhost.localdomain> From: Khem Raj Date: Wed, 16 Feb 2022 10:03:30 -0800 Message-ID: To: musl@lists.openwall.com Content-Type: multipart/related; boundary="00000000000037ca2405d82679d1" Subject: Re: [musl] -Wsign-conversion warning on ARM when using CMSG_NXTHDR --00000000000037ca2405d82679d1 Content-Type: multipart/alternative; boundary="00000000000037ca2305d82679d0" --00000000000037ca2305d82679d0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Feb 16, 2022 at 4:42 AM Christian Eggers 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=3Dsign-conversion] > | 193 | header =3D 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=3Dsign-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=3Dsign-conversion] > | 213 | header =3D 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=3Dsign-conversion] > > Note: libcapi uses the '-Werror' and '-Wconversion' flags. > > For testing, I created a minimal code snipset (cmsg.c): > > #include > #include > > void foo(void) > { > struct msghdr msg =3D {0}; > struct cmsghdr *header =3D NULL; > > header =3D CMSG_FIRSTHDR(&msg); > header =3D CMSG_NXTHDR(&msg, header); > } > > # arm-poky-linux-musleabi-gcc --sysroot=3D<...> -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 unsigne= d > int' changes value from '-4' to '4294967292' [-Werror=3Dsign-conversion] > 10 | header =3D CMSG_NXTHDR(&msg, header); > | ^~~~~~~~~~~ > cmsg.c:10:18: error: unsigned conversion from 'long int' to 'long unsigne= d > int' changes value from '-4' to '4294967292' [-Werror=3Dsign-conversion] > > > When replace CMSG_NXTHDR() by the expanded macro code, I get the followin= g > errors: > > cmsg.c: In function 'foo': > cmsg.c:12:46: error: unsigned conversion from 'long int' to 'long unsigne= d > int' changes value from '-4' to '4294967292' [-Werror=3Dsign-conversion] > 12 | (((header)->cmsg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)= ) > + sizeof(struct cmsghdr) >=3D ((unsigned char *)(&msg)->msg_control + > (&msg)->msg_controllen) - (unsigned char *)(header) \ > | ^ > cmsg.c:13:99: error: unsigned conversion from 'long int' to 'long unsigne= d > int' changes value from '-4' to '4294967292' [-Werror=3Dsign-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-crypt= o/libkcapi?h=3Dmaster > [2] > https://github.com/smuellerDD/libkcapi/tree/2936ecd060c299157ac880650ba2c= 9fd94d27bb1 > > > > _______________________________________________________ > Christian > Eggers > Software Engineer > ARRI > Arnold & Richter Cine Technik GmbH & Co. Betriebs KG > Arriweg 17 , > 83071 > Stephanskirchen > > > *www.arri.com * > *+49 8036 3009-3118* <+49%208036%203009-3118> > *CEggers@arri.de* > > [image: Orbiter Docking Ring] > > Get all the latest information from *www.arri.com* > , *Facebook* , *Twitter* > , *Instagram* > and *YouTube* . > > Arnold & Richter Cine Technik GmbH & Co. Betriebs KG > > Sitz: M=C3=BCnchen =E2=80=91 Registergericht: Amtsgericht M=C3=BCnchen = =E2=80=91 Handelsregisternummer: HRA 57918 > Pers=C3=B6nlich haftender Gesellschafter: Arnold & Richter Cine Technik G= mbH > > Sitz: M=C3=BCnchen =E2=80=91 Registergericht: Amtsgericht M=C3=BCnchen = =E2=80=91 Handelsregisternummer: HRB 54477 > > Gesch=C3=A4ftsf=C3=BChrer: Dr. Michael Neuh=C3=A4user; Stephan Schenk; Wa= lter Trauninger; Markus Zeiler > > > --00000000000037ca2305d82679d0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


On Wed, Feb 16, 2022 at 4:42 AM Chr= istian Eggers <ceggers@arri.de>= ; wrote:
Toolchain: Yocto Linux with poky-tiny
Host platform: openSUSE 15.3 x8= 6_64
Target platform: arm-poky-linux-musleabi (armv7, 32 bit)

Whe= n I try to compile libkcapi [1] [2] with current
Yocto/Openembedded mast= er branch, I get the following compiler error:

| ../git/lib/kcapi-ke= rnel-if.c: In function '_kcapi_common_send_meta':
| ../git/lib/k= capi-kernel-if.c:193:26: error: unsigned conversion from 'long int'= to 'long unsigned int' changes value from '-4' to '429= 4967292' [-Werror=3Dsign-conversion]
| 193 | heade= r =3D CMSG_NXTHDR(&msg, header);
| | = ^~~~~~~~~~~
| ../git/lib/kcapi-kernel-if.c:193:26: error: unsigned conve= rsion from 'long int' to 'long unsigned int' changes value = from '-4' to '4294967292' [-Werror=3Dsign-conversion]
| = ../git/lib/kcapi-kernel-if.c:213:26: error: unsigned conversion from 'l= ong int' to 'long unsigned int' changes value from '-4'= to '4294967292' [-Werror=3Dsign-conversion]
| 213 | = header =3D CMSG_NXTHDR(&msg, header);
| | = ^~~~~~~~~~~
| ../git/lib/kcapi-kernel-if.c:213:26: error: un= signed conversion from 'long int' to 'long unsigned int' ch= anges value from '-4' to '4294967292' [-Werror=3Dsign-conve= rsion]

Note: libcapi uses the '-Werror' and '-Wconversi= on' flags.

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

#include <stddef.h>
#include <sys/socket.h>
void foo(void)
{
struct msghdr msg =3D {0};
struc= t cmsghdr *header =3D NULL;

header =3D CMSG_FIRSTHDR(&ms= g);
header =3D CMSG_NXTHDR(&msg, header);
}

# arm-= poky-linux-musleabi-gcc --sysroot=3D<...> -Werror -Wconversion -c= -o cmsg.o cmsg.c
cmsg.c: In function 'foo&= #39;:
cmsg.c:10:18: error: unsigned conversion from 'long int' t= o 'long unsigned int' changes value from '-4' to '42949= 67292' [-Werror=3Dsign-conversion]
10 | header =3D CMSG_N= XTHDR(&msg, header);
| ^~~~~~~~~~~
cmsg.c:= 10:18: error: unsigned conversion from 'long int' to 'long unsi= gned int' changes value from '-4' to '4294967292' [-Wer= ror=3Dsign-conversion]


When replace CMSG_NXTHDR() by the expande= d macro code, I get the following errors:

cmsg.c: In function 'f= oo':
cmsg.c:12:46: error: unsigned conversion from 'long int'= ; to 'long unsigned int' changes value from '-4' to '42= 94967292' [-Werror=3Dsign-conversion]
12 | (((header)->cms= g_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1)) + sizeof(struct = cmsghdr) >=3D ((unsigned char *)(&msg)->msg_control + (&msg)-= >msg_controllen) - (unsigned char *)(header) \
| = ^
cmsg.c:13:99: error: unsigned conversio= n from 'long int' to 'long unsigned int' changes value from= '-4' to '4294967292' [-Werror=3Dsign-conversion]
13 = | ? 0 : (struct cmsghdr *)((unsigned char *)(header) + (((header)->c= msg_len + sizeof(long) - 1) & ~(long)(sizeof(long) - 1))));
| = = ^

libkcapi has dropped using -Wer= ror=C2=A0
_______________________________________________________
Christian=C2=A0
=
Eggers
Software=C2=A0Engineer
ARRI
Arnold=C2=A0&=C2=A0Ri= chter=C2=A0Cine=C2=A0Technik=C2=A0GmbH=C2=A0&=C2=A0Co.=C2=A0Betriebs=C2= =A0KG=C2=A0
<= /tr>
Arriweg=C2=A017,=C2=A0
83071=C2=A0
Stephanskirchen
<= tbody>
www.arri.com=C2=A0

3D""+49=C2= =A08036=C2=A03009-3118
3D""CEggers@arri.de

3D"Orbiter
Get= =C2=A0all=C2=A0the=C2=A0latest=C2=A0information=C2=A0from=C2=A0www.arri.com,=C2=A0Facebook,=C2=A0Twitter,=C2=A0Instagram=C2=A0and=C2= =A0YouTube.

Arnold=C2=A0&=C2=A0Rich= ter=C2=A0Cine=C2=A0Technik=C2=A0GmbH=C2=A0&=C2=A0Co.=C2=A0Betriebs=C2= =A0KG
Sitz:=C2=A0M=C3=BCnchen=C2=A0=E2=80=91=C2=A0Registergericht:=C2=A0= Amtsgericht=C2=A0M=C3=BCnchen=C2=A0=E2=80=91=C2=A0Handelsregisternummer:=C2= =A0HRA=C2=A057918
Pers=C3=B6nlich=C2=A0haftender=C2=A0Gesellschafter:=C2= =A0Arnold=C2=A0&=C2=A0Richter=C2=A0Cine=C2=A0Technik=C2=A0GmbH
Sitz:= =C2=A0M=C3=BCnchen=C2=A0=E2=80=91=C2=A0Registergericht:=C2=A0Amtsgericht=C2= =A0M=C3=BCnchen=C2=A0=E2=80=91=C2=A0Handelsregisternummer:=C2=A0HRB=C2=A054= 477
Gesch=C3=A4ftsf=C3=BChrer:=C2=A0Dr.=C2=A0Michael=C2=A0Neuh=C3=A4user= ;=C2=A0Stephan=C2=A0Schenk;=C2=A0Walter=C2=A0Trauninger;=C2=A0Markus=C2=A0Z= eiler


--00000000000037ca2305d82679d0-- --00000000000037ca2405d82679d1 Content-Type: image/png; name="image092396.png" Content-Disposition: inline; filename="image092396.png" Content-Transfer-Encoding: base64 Content-ID: <17f03b3b18645f53dfd1> X-Attachment-Id: 17f03b3b18645f53dfd1 iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACx jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGlSURBVDhP1ZOxSgNBEIZ3o6QSSWGRwiJFCl9A iCDEIqKFgo2FYGHjA1hYRZ0sGrURgq0WgkoqEUHQShJMYWFhmcLCwsIHsJBEs/5zmTvvJIE9sPGD Zf7Zu/tvdndW/TVaogcRDSWVKlilMhvGVGQ6FoEhzAaTWt9AFji31q7C9Jh1HBISFSpbQPDMGK31 NlcsqTOBIRxmRPmkUTGJdubHUKmsxDA5ic6EDV8k+jRa1i6KdiYw/LL2QiTzDrNpY8yb5M4EhlvG XKNdniXl9pkTHYvwkrlXDkTxIR3tEWUkcyZi2FbqBOGxm6lUR+tT7k/JnYgYYs8+sHfzkP7eTaJ1 LmGaktyjTDSGsSxphMjV89khyqGx7yG96rC3r7g5S5vGNHaJsrb7LI3RwPw6btQDv8f0NGRwTWYT Wlch/eo+Mc5gPoWPfu9tpVgqrbGIHkoIVHOLQ5qAQVOmuNqVHma8guDK9jVkisY029aOQ/JhcYU9 wbLPRaoBiX2p1+utu1rtqpDPV9FKHVQziiqH5fETzMr40yHe68hcfPaJRnHyI5L+K5T6BsZ9gKi6 xb3hAAAAAElFTkSuQmCC --00000000000037ca2405d82679d1 Content-Type: image/png; name="image623061.png" Content-Disposition: inline; filename="image623061.png" Content-Transfer-Encoding: base64 Content-ID: <17f03b3b187b598576a2> X-Attachment-Id: 17f03b3b187b598576a2 iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAAXNSR0IArs4c6QAAAARnQU1BAACx jwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAALNSURBVDhPtZQ/SNVRFMfv1Z/S4PCGBoeg1Uih oaFB8j1wMGgweBJBgUNRUQ2BQaH2e79SaKipwcGhlkioQEiooT++7RUOBkYODg0GgiIOLyi1bp/v /d3fL8U31hfuO/ec3z3nfM895z7zr2GDbIg4jgutxvQ6Yw5IRy5uGzOfJMmKP9AADQMSaH+LtQ/5 WEaNUutfEHj5t3OXbyfJTDDl2BNwPI7LxtoJthFOD5A1WM0hf7QY04FDB98vohdZjzeduwbjOnuP piA9QrBnMJjl4KHRJBmD3hJlF5HdW8Z8HU6SqeFKpeScu4BLmUoepd4pcoYqs9XaLwo2UqkMoEfo YjrIysreNs6dI+kk515b516wf4ptgETPdSBnqDtDRFuUIJ1g0s/jOE3pJ7TQZ30AY9pg4tmyn8E2 AYE29mlmdVMNwInrSFbG4vgq5kvY7lHeLZ0ROFcj0SrbCFYfZNM9N1n7XveLOucZajQQCl6TTsYr MFv66dyo1wNItoFQg4QF/dAwL0GnfnxAnP2cqZu6S3WSD1MEwLQbnFVpdcpdlM6ZNcSatfaw9Cyg 2Ml5G7bd3ubcJ8md0D2RTEzmU0uOPLEPyM8yIiLqEYIXZMtY7wTJhsI2K1tJ2hHtEPgs3QfcVPdS HGP5UijhtGSGO3F8EuOw9pmzGNOkSbYbkHkjGxWkGK9UXsGqk7Hp4tBLTN3oU2RcQvahH0VO49DP XgxF4iyr8Is5zJ6hZyg08TY5XCDY3WbnzgTnMnKEz5FeBgN/ijG5gW1fSKLh7tr5pnOGguaPUjXQ 93l6GhlddlsYl13gmfZzVTXNbTB5NAfp8a5a/Vjq6flO0JsM6yD3sspaf1utruu77qy3WDzeWyo9 4T6HKO8bPunsBuximIHs+kfRo1eThA1KrHM46/w8pV/nzyNrZo6GATNwBRqjPtgeRK2H7i6MJEk+ Nv8ZxvwBPgIhrepF7fMAAAAASUVORK5CYII= --00000000000037ca2405d82679d1--