Re: [PATCH 2/4] kselftest/arm64: Fix printf() warning in the arm64 MTE prctl() test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Nov 08, 2024 at 03:10:59PM +0000, Mark Brown wrote:
> On Fri, Nov 08, 2024 at 01:49:18PM +0000, Catalin Marinas wrote:
> > While prctl() returns an 'int', the PR_MTE_TCF_MASK is defined as
> > unsigned long which results in the larger type following a bitwise 'and'
> > operation. Cast the printf() argument to 'int'.
> 
> >  	} else {
> >  		ksft_print_msg("Got %x, expected %x\n",
> > -			       (ret & PR_MTE_TCF_MASK), mask);
> > +			       (int)(ret & PR_MTE_TCF_MASK), mask);
> 
> Shouldn't we just use a %lx here?  Casts tend to be suspicious...

It's more like the ret is actually 32-bit and should stay like that when
bits are masked out. But the bitwise op 'upgrades' it to a long (in
hindsight, we should not have used UL for the TCF bits and mask).

-- 
Catalin




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux