mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: kbuild test robot <lkp@intel.com>
To: Tomasz Duszynski <tduszyns@gmail.com>
Cc: kbuild-all@01.org, linux-kernel@vger.kernel.org,
	Jonathan Cameron <Jonathan.Cameron@huawei.com>
Subject: drivers/iio/chemical/sps30.c:122:30: sparse: sparse: cast truncates bits from constant value (8004 becomes 4)
Date: Tue, 23 Apr 2019 14:57:57 +0800	[thread overview]
Message-ID: <201904231456.G27oroy1%lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   7142eaa58b49d9de492ccc16d48df7c488a5fbb6
commit: 62129a0849d27cc94ced832bcf9dcde283dcbe08 iio: chemical: sps30: allow changing self cleaning period
date:   3 months ago
reproduce:
        # apt-get install sparse
        git checkout 62129a0849d27cc94ced832bcf9dcde283dcbe08
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>



sparse warnings: (new ones prefixed by >>)

>> drivers/iio/chemical/sps30.c:122:30: sparse: sparse: cast truncates bits from constant value (8004 becomes 4)

vim +122 drivers/iio/chemical/sps30.c

    91	
    92	static int sps30_do_cmd(struct sps30_state *state, u16 cmd, u8 *data, int size)
    93	{
    94		/*
    95		 * Internally sensor stores measurements in a following manner:
    96		 *
    97		 * PM1: upper two bytes, crc8, lower two bytes, crc8
    98		 * PM2P5: upper two bytes, crc8, lower two bytes, crc8
    99		 * PM4: upper two bytes, crc8, lower two bytes, crc8
   100		 * PM10: upper two bytes, crc8, lower two bytes, crc8
   101		 *
   102		 * What follows next are number concentration measurements and
   103		 * typical particle size measurement which we omit.
   104		 */
   105		u8 buf[SPS30_MAX_READ_SIZE] = { cmd >> 8, cmd };
   106		int i, ret = 0;
   107	
   108		switch (cmd) {
   109		case SPS30_START_MEAS:
   110			buf[2] = 0x03;
   111			buf[3] = 0x00;
   112			buf[4] = crc8(sps30_crc8_table, &buf[2], 2, CRC8_INIT_VALUE);
   113			ret = sps30_write_then_read(state, buf, 5, NULL, 0);
   114			break;
   115		case SPS30_STOP_MEAS:
   116		case SPS30_RESET:
   117		case SPS30_START_FAN_CLEANING:
   118			ret = sps30_write_then_read(state, buf, 2, NULL, 0);
   119			break;
   120		case SPS30_READ_AUTO_CLEANING_PERIOD:
   121			buf[0] = SPS30_AUTO_CLEANING_PERIOD >> 8;
 > 122			buf[1] = (u8)SPS30_AUTO_CLEANING_PERIOD;
   123		case SPS30_READ_DATA_READY_FLAG:
   124		case SPS30_READ_DATA:
   125		case SPS30_READ_SERIAL:
   126			/* every two data bytes are checksummed */
   127			size += size / 2;
   128			ret = sps30_write_then_read(state, buf, 2, buf, size);
   129			break;
   130		case SPS30_AUTO_CLEANING_PERIOD:
   131			buf[2] = data[0];
   132			buf[3] = data[1];
   133			buf[4] = crc8(sps30_crc8_table, &buf[2], 2, CRC8_INIT_VALUE);
   134			buf[5] = data[2];
   135			buf[6] = data[3];
   136			buf[7] = crc8(sps30_crc8_table, &buf[5], 2, CRC8_INIT_VALUE);
   137			ret = sps30_write_then_read(state, buf, 8, NULL, 0);
   138			break;
   139		}
   140	
   141		if (ret)
   142			return ret;
   143	
   144		/* validate received data and strip off crc bytes */
   145		for (i = 0; i < size; i += 3) {
   146			u8 crc = crc8(sps30_crc8_table, &buf[i], 2, CRC8_INIT_VALUE);
   147	
   148			if (crc != buf[i + 2]) {
   149				dev_err(&state->client->dev,
   150					"data integrity check failed\n");
   151				return -EIO;
   152			}
   153	
   154			*data++ = buf[i];
   155			*data++ = buf[i + 1];
   156		}
   157	
   158		return 0;
   159	}
   160	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

                 reply	other threads:[~2019-04-23  6:58 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201904231456.G27oroy1%lkp@intel.com \
    --to=lkp@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=kbuild-all@01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tduszyns@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®