Re: [PATCH v6] hwmon: Add sht4x Temperature and Humidity Sensor Driver

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

 



Hi Navin,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on hwmon/hwmon-next]
[also build test WARNING on v5.13-rc2 next-20210521]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Navin-Sankar-Velliangiri/hwmon-Add-sht4x-Temperature-and-Humidity-Sensor-Driver/20210522-232201
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: x86_64-randconfig-r033-20210523 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project e84a9b9bb3051c35dea993cdad7b3d2575638f85)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install x86_64 cross compiling tool for clang build
        # apt-get install binutils-x86-64-linux-gnu
        # https://github.com/0day-ci/linux/commit/a122a0f7b0de4be7208671bb4f68ee1e14a3f28e
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Navin-Sankar-Velliangiri/hwmon-Add-sht4x-Temperature-and-Humidity-Sensor-Driver/20210522-232201
        git checkout a122a0f7b0de4be7208671bb4f68ee1e14a3f28e
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> drivers/hwmon/sht4x.c:84:2: warning: variable 'ret' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
           if (!data->valid || time_after(jiffies, next_update)) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:56:28: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:58:30: note: expanded from macro '__trace_if_var'
   #define __trace_if_var(cond) (__builtin_constant_p(cond) ? (cond) : __trace_if_value(cond))
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   drivers/hwmon/sht4x.c:125:9: note: uninitialized use occurs here
           return ret;
                  ^~~
   drivers/hwmon/sht4x.c:84:2: note: remove the 'if' if its condition is always true
           if (!data->valid || time_after(jiffies, next_update)) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:56:23: note: expanded from macro 'if'
   #define if(cond, ...) if ( __trace_if_var( !!(cond , ## __VA_ARGS__) ) )
                         ^
   drivers/hwmon/sht4x.c:74:9: note: initialize the variable 'ret' to silence this warning
           int ret;
                  ^
                   = 0
   1 warning generated.


vim +84 drivers/hwmon/sht4x.c

    66	
    67	/**
    68	 * sht4x_read_values() - read and parse the raw data from the SHT4X
    69	 * @sht4x_data: the struct sht4x_data to use for the lock
    70	 * Return: 0 if succesfull, 1 if not
    71	 */
    72	static int sht4x_read_values(struct sht4x_data *data)
    73	{
    74		int ret;
    75		u16 t_ticks, rh_ticks;
    76		unsigned long next_update;
    77		struct i2c_client *client = data->client;
    78		u8 crc, raw_data[SHT4X_RESPONSE_LENGTH],
    79		cmd[] = {SHT4X_CMD_MEASURE_HPM};
    80	
    81		mutex_lock(&data->lock);
    82		next_update = data->last_updated +
    83			      msecs_to_jiffies(data->update_interval);
  > 84		if (!data->valid || time_after(jiffies, next_update)) {
    85			ret = i2c_master_send(client, cmd, SHT4X_CMD_LEN);
    86			if (ret < 0)
    87				goto unlock;
    88	
    89			usleep_range(SHT4X_MEAS_DELAY,
    90				     SHT4X_MEAS_DELAY + SHT4X_DELAY_EXTRA);
    91	
    92			ret = i2c_master_recv(client, raw_data, SHT4X_RESPONSE_LENGTH);
    93			if (ret != SHT4X_RESPONSE_LENGTH) {
    94				if (ret >= 0)
    95					ret = -ENODATA;
    96	
    97				goto unlock;
    98			}
    99	
   100			t_ticks = raw_data[0] << 8 | raw_data[1];
   101			rh_ticks = raw_data[3] << 8 | raw_data[4];
   102	
   103			crc = crc8(sht4x_crc8_table, &raw_data[0], SHT4X_WORD_LEN, CRC8_INIT_VALUE);
   104			if (crc != raw_data[2]) {
   105				dev_err(&client->dev, "data integrity check failed\n");
   106				ret = -EIO;
   107				goto unlock;
   108			}
   109	
   110			crc = crc8(sht4x_crc8_table, &raw_data[3], SHT4X_WORD_LEN, CRC8_INIT_VALUE);
   111			if (crc != raw_data[5]) {
   112				dev_err(&client->dev, "data integrity check failed\n");
   113				ret = -EIO;
   114				goto unlock;
   115			}
   116	
   117			data->temperature = ((21875 * (int32_t)t_ticks) >> 13) - 45000;
   118			data->humidity = ((15625 * (int32_t)rh_ticks) >> 13) - 6000;
   119			data->last_updated = jiffies;
   120			data->valid = true;
   121		}
   122	
   123	unlock:
   124		mutex_unlock(&data->lock);
   125		return ret;
   126	}
   127	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux