Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9F664C282DE for ; Thu, 13 Mar 2025 15:30:09 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8A1D780F9C; Thu, 13 Mar 2025 16:30:07 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=gmx.de header.i=xypron.glpk@gmx.de header.b="smCyB9SE"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C1AC280FF7; Thu, 13 Mar 2025 16:30:06 +0100 (CET) Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 45E2180540 for ; Thu, 13 Mar 2025 16:30:04 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=quarantine dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmx.de; s=s31663417; t=1741879783; x=1742484583; i=xypron.glpk@gmx.de; bh=ZrXozHv2W5M1yYNWYENnk50+6mPTKA0lh14PnvtvGJ8=; h=X-UI-Sender-Class:Message-ID:Date:MIME-Version:Subject:To:Cc: References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=smCyB9SEAtq8K59tPkPkwh8L9GynUHtNAGuMUV9NCGpSprC6uq6ZMYmjUvgBfoqY ckxqZ7NZvIba90Lm7qH0UfyAhjSZUIJU2FreoivxCbF10ZAXJqN0Cvj2SuQXD0zC2 nuldoCc1ga3G9ChTOjb/bFMDrp+z47bWnCdT3R05lY2iGw7V/bnjUKWJJCwsic1gC uRR7i/o7of1NDYDXxaHzfttEm596rtmxM7fM57v3yLS7GZjcUlMFe8jfbxUzw59xO wVFifQ5iq2Xi7C9J9AX5VoQ1WYhMKAWO5wnP8jUpncp6DeqVq7vsnVJITnKPmbqqS 2qEO2q/4tXx+qEZg2g== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from [192.168.103.102] ([5.147.80.91]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1N49lD-1tAmgQ2FFJ-016smf; Thu, 13 Mar 2025 16:29:43 +0100 Message-ID: <7bee2059-2378-4d5f-a2db-ea46fd6badef@gmx.de> Date: Thu, 13 Mar 2025 16:29:42 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 08/12] fs: exfat: Fix conversion overflow errors To: Marek Vasut , Tom Rini Cc: Quentin Schulz , u-boot@lists.denx.de, Baruch Siach , Francesco Dolcini , Hiago De Franco , Ilias Apalodimas , Nam Cao , Simon Glass , Sughosh Ganu References: <20250308201533.1315951-1-marex@denx.de> <20250308201533.1315951-9-marex@denx.de> <393a7b06-402a-48b0-8ed4-5dcaa7ab9383@cherry.de> <20250310214904.GO2640854@bill-the-cat> Content-Language: en-US From: Heinrich Schuchardt In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:iI89vGbhIuxIoljBkPWSYVMlScyUoMql20w/60HqSs/D/WI5JQN tTgnt0gxUnZwSCx6HuG901l7vNh1eYTySEB7GDDaY6axeErFmJGLGpDZ40bdyBzbEe5wHgA uZbwFe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b1YAPUTLZhMTGb7Za6F7O4PnvR7heY2lS23 uEb2uu0EEOO3DuS7t4fw7vKyCjyORvaWkwwKQTBN1NP91rA+S2yylCTk2FhR3ihjCkt2y6FZF o0ENauPrrf55Znp1IaKAHkb2pf9SsgfuJIMPgSx7aaXnAo24PpdVOroownJxZlh1Lb42/bH0T qeFE08dzYmv3Mh/Kx1uFwgfJHlDdqUOF14FNpKzlyXEkI/u0DDu1oLzYyOV0eZHGKd4AbTwEh 08ccfk9QHAiw/lI0zB2FP/sFWHGm60RYBE3UQnTTMq0QU7YIst9Yr9fCFMQH4dG/FZyHno8/G 4LsxWf1u8KTDU7fx0O+gcJh++BE+eh16Dabr7D4LfZnWcu+KmM9Qloz434854TTeRZl8/JiGL te1wCHRBsmPtwYYt6ZMDjXCaE1PQvNUnaQeXU44cWzwkNNFxylC78pqGxrwaiTMiJOUHdU1lA eOcg5LQfjONuQDzoy42f1d2cwFum5lmd/74Kl8ZFLE9+d11AKlyRT3wB9LyjNbkgpqqqHljJH sVIuIVW9h/EFG5nhNPb0xT/baESo= X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 11.03.25 00:33, Marek Vasut wrote: > On 3/10/25 10:49 PM, Tom Rini wrote: >> On Mon, Mar 10, 2025 at 10:03:37PM +0100, Marek Vasut wrote: >>> On 3/10/25 12:17 PM, Quentin Schulz wrote: >>>> Hi Marek, >>> >>> Hi, >>> >>>> On 3/8/25 9:12 PM, Marek Vasut wrote: >>>>> Fix the following conversion overflow errors. The input field is >>>>> already >>>>> limited to 3/2/1 bits using the bitwise and, move the parenthesis >>>>> around >>>>> to avoid the bogus warning: >>>>> >>>>> " >>>>> fs/exfat/utf.c: In function =E2=80=98utf8_to_wchar=E2=80=99: >>>>> fs/exfat/utf.c:165:23: warning: overflow in conversion from =E2=80= =98int=E2=80=99 to >>>>> =E2=80=98wchar_t=E2=80=99 {aka =E2=80=98short unsigned int=E2=80=99}= changes value from =E2=80=98(int)(short >>>>> unsigned int)*input << 18 & 1835008=E2=80=99 to =E2=80=980=E2=80=99 = [-Woverflow] >>>>> =C2=A0=C2=A0=C2=A0 165 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *wc =3D ((wchar_t) = input[0] & 0x07) << 18; >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^ >>>>> fs/exfat/utf.c:170:23: warning: overflow in conversion from =E2=80= =98int=E2=80=99 to >>>>> =E2=80=98wchar_t=E2=80=99 {aka =E2=80=98short unsigned int=E2=80=99}= changes value from =E2=80=98(int)(short >>>>> unsigned int)*input << 24 & 50331648=E2=80=99 to =E2=80=980=E2=80=99= [-Woverflow] >>>>> =C2=A0=C2=A0=C2=A0 170 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *wc =3D ((wchar_t) = input[0] & 0x03) << 24; >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^ >>>>> fs/exfat/utf.c:175:23: warning: overflow in conversion from =E2=80= =98int=E2=80=99 to >>>>> =E2=80=98wchar_t=E2=80=99 {aka =E2=80=98short unsigned int=E2=80=99}= changes value from =E2=80=98(int)(short >>>>> unsigned int)*input << 30 & 1073741824=E2=80=99 to =E2=80=980=E2=80= =99 [-Woverflow] >>>>> =C2=A0=C2=A0=C2=A0 175 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 *wc =3D ((wchar_t) = input[0] & 0x01) << 30; >>>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ^ >>>>> " >>>>> >>>> >>>> Since this doesn't seem to be U-Boot-specific, any chance to open a >>>> Pull >>>> Request on the project so we may be able to not carry this patch when >>>> upgrading (yes, the last commit in the branch was two years ago, but = it >>>> seems the maintainer is still active on issues). >>>> >>>> Considering that wchar_t is an unsigned short int and that USHRT_MAX = is >>>> 0xffff (so 2B or 16b)... >>> In fact, this error does not even appear in upstream , because >>> upstream does >>> not use -fshort-wchar compiler flag . U-Boot does use this compiler >>> flags >>> since 4a85663ec7ed ("kbuild: Enable -fshort-wchar") . >>> >>> So I wonder if this might be the right fix here instead: >>> >>> diff --git a/fs/exfat/Makefile b/fs/exfat/Makefile >>> index 550c0683d65..8ca112cf0e9 100644 >>> --- a/fs/exfat/Makefile >>> +++ b/fs/exfat/Makefile >>> @@ -1,6 +1,9 @@ >>> =C2=A0 # SPDX-License-Identifier: GPL-2.0+ >>> =C2=A0 # >>> >>> +# The utf.o does really need 32bit wchar_t >>> +CFLAGS_REMOVE_utf.o :=3D -fshort-wchar >>> + >>> =C2=A0 obj-$(CONFIG_FS_EXFAT) +=3D \ >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 cluster.o \ >>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 io.o \ >> >> Your initial approach is right I think, I'm not sure it's a good idea >> to mix and match that flag throughout the codebase. > > The -fshort-wchar is needed only because of EFI , so I wonder if we > should somehow isolate the EFI code which needs this stuff instead, and > drop the flag throughout the codebase instead ? Heinrich ? > > Or maybe EFI should switch to something else that is not wchar_t , so > other users can use wchar_t unrestricted ? We already changed all L"" strings to u"". But the compiler complains about printf("%ls\n", (u16 *)buf); without -fshort-wchar. So we cannot do without the flag. In fs/exfat/Makefile you should be able to disable the flag with CFLAGS_REMOVE_* and AFLAGS_REMOVE_* Best regards Heinrich