Re: [PATCH] Staging/comedi: Fixes static analysis warning raised by sparse

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

 



Let's forward this to the Sparse mailing list.

We're seeing a Sparse false positive testing
drivers/staging/comedi/drivers/ni_pcimio.c.

  CHECK   drivers/staging/comedi/drivers/ni_pcimio.c
drivers/staging/comedi/drivers/ni_stc.h:720:26: warning: shift too big (4294967295) for type int
drivers/staging/comedi/drivers/ni_stc.h:720:26: warning: shift too big (4294967295) for type int
drivers/staging/comedi/drivers/ni_stc.h:720:26: warning: shift too big (4294967295) for type int
drivers/staging/comedi/drivers/ni_stc.h:720:26: warning: shift too big (4294967295) for type int

I have created some test code to demonstrate the problem (attached).

The check_shift_count() warning is only supposed to be printed for
number literals but because of the way inline functions are expanded it
still complains even though channel is a variable.

regards,
dan carpenter

#include <stdio.h>
#include <limits.h>
#include <string.h>

static inline unsigned ni_stc_dma_channel_select_bitfield(unsigned channel)
{
	if (channel < 4)
		return 1 << channel;
	return 0;
}

static inline void filter(int channel)
{
	if (channel < 0)
		return;
	ni_stc_dma_channel_select_bitfield(channel);
}

int main(void)
{
	filter(-1);

	return 0;
}

[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux