Re: Odd smatch issue?

John Levon <[email protected]>
Newsgroups org.kernel.vger.smatch
Message-ID <[email protected]>
On Mon, Jan 14, 2019 at 01:18:04PM +0300, Dan Carpenter wrote:

> > static long
> > lx_cap_update_priv(void)
> > {
> >         const int lx_cap_mapping[4] = { 0, 0, 0 };
> >         int i = 63;
> >         /* enabling the below line disables the warning */
> >         //int cap_set = i == 0;
> >         lx_cap_mapping[i];
> > }
> > 
> 
> Thanks John,
> 
> I am testing this patch:
> 
> [PATCH] extra: preserve hard_max after comparisons to zero

Thanks for taking a look. Unfortunately this still doesn't seem to cover
the original case which the above was boiled down from. This does:

 76 #define LX_CAP_CAPISSET(id, cap) \                                               
 77         (((id < 32) && (((0x1 << id) & cap[0]) != 0)) || \                       
 78         ((id >= 32) && (((0x1 << (id - 32) & cap[1]) != 0))))                    


221         for (i = 0; i <= LX_CAP_MAX_CHECK; i++) {                                
222                 cap_set = LX_CAP_CAPISSET(i, cap);                               
223                 if (lx_cap_mapping[i] == NULL || i > LX_CAP_MAX_VALID) {         

(The code is bug is on line :223 where we need to reverse the order of the checks.)

regards
john
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.