Content-Type: multipart/mixed; boundary="===============2618832715192040580==" MIME-Version: 1.0 From: Miquel Raynal To: kbuild-all@lists.01.org Subject: Re: drivers/mtd/maps/physmap-bt1-rom.c:78:18: sparse: sparse: cast removes address space '__iomem' of expression Date: Thu, 12 Nov 2020 16:43:01 +0100 Message-ID: <20201112164301.60032276@xps13> In-Reply-To: <20201112152739.r4673zyeixkcwukx@mobilestation> List-Id: --===============2618832715192040580== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Hi Serge, Serge Semin wrote on Thu, 12 Nov 2020 18:27:39 +0300: > Hello Vignesh > = > On Thu, Nov 12, 2020 at 08:30:42PM +0530, Vignesh Raghavendra wrote: > > = > > = > > On 11/12/20 1:57 PM, Miquel Raynal wrote: = > > > Hi Sergey, > > > = > > > Serge Semin wrote on Wed, 11 Nov > > > 2020 22:22:59 +0300: > > > = > > >> On Tue, Nov 10, 2020 at 04:35:56PM +0100, Miquel Raynal wrote: = > > >>> Hi Serge, > > >>> > > >>> Serge Semin wrote on Tue, 10 = Nov > > >>> 2020 14:38:27 +0300: > > >>> = > > >>>> Hello Miquel, > > >>>> > > >>>> A situation noted by the warning below won't cause any problem bec= ause > > >>>> the casting is done to a non-dereferenced variable. It is utilized > > >>>> as a pointer bias later in that function. Shall we just ignore the > > >>>> warning or still fix it somehow? = > > >>> = > > >> = > > >>> Do you think the cast to a !__iomem value is mandatory here? = > > >> > > >> It's not mandatory to have the casting with no __iomem, but wouldn't > > >> doing like this: > > >> + shift =3D (ssize_t __iomem)src & 0x3; > > >> be looking weird? Really, is there a good way to somehow extract the= first > > >> two bits of a __iomem pointer without getting the sparse warning? = > > > = > > > I asked around me, what about trying uintptr_t? > > > = > > = > = > > One more way is to use __force to tell sparse that this casting is > > intentional: > > = > > shift =3D (__force ssize_t)src & 0x3; = > = > Oh, great! That solution is actually much better than using some > currently unexplained sparse peculiarity! I was thinking about applying > some other attribute, but __force just didn't come to my mind. Thank > you very much for the suggestion. I'll post the fix with the solution > suggested by you. Is the ssize_t cast the right one btw? I would definitely prefer an unsigned type here. Thanks, Miqu=C3=A8l --===============2618832715192040580==--