[rafael-pm:bleeding-edge 74/80] drivers/thermal/thermal_core.c:1230:13: warning: the comparison will always evaluate as 'true' for the address of 'trips' will never be NULL

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

 



tree:   https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git bleeding-edge
head:   1cc7a914a31bd41feb404b644539a007f99b4f00
commit: 888085f258b2e617bfc4548a9907b09f935efcbb [74/80] thermal: core: Store zone trips table in struct thermal_zone_device
config: sh-allmodconfig (https://download.01.org/0day-ci/archive/20240211/202402111655.cJxMGZeM-lkp@xxxxxxxxx/config)
compiler: sh4-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240211/202402111655.cJxMGZeM-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402111655.cJxMGZeM-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

   drivers/thermal/thermal_core.c: In function 'thermal_zone_get_crit_temp':
>> drivers/thermal/thermal_core.c:1230:13: warning: the comparison will always evaluate as 'true' for the address of 'trips' will never be NULL [-Waddress]
    1230 |         if (!tz->trips)
         |             ^
   In file included from drivers/thermal/thermal_core.c:18:
   include/linux/thermal.h:205:29: note: 'trips' declared here
     205 |         struct thermal_trip trips[] __counted_by(num_trips);
         |                             ^~~~~
--
   drivers/thermal/thermal_trip.c: In function '__thermal_zone_get_trip':
>> drivers/thermal/thermal_trip.c:125:20: warning: the comparison will always evaluate as 'true' for the address of 'trips' will never be NULL [-Waddress]
     125 |         if (!tz || !tz->trips || trip_id < 0 || trip_id >= tz->num_trips || !trip)
         |                    ^
   In file included from drivers/thermal/thermal_core.h:13,
                    from drivers/thermal/thermal_trip.c:10:
   include/linux/thermal.h:205:29: note: 'trips' declared here
     205 |         struct thermal_trip trips[] __counted_by(num_trips);
         |                             ^~~~~


vim +1230 drivers/thermal/thermal_core.c

e5f2cda61d068e Daniel Lezcano 2022-07-22  1222  
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1223  int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp)
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1224  {
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1225  	int i, ret = -EINVAL;
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1226  
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1227  	if (tz->ops->get_crit_temp)
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1228  		return tz->ops->get_crit_temp(tz, temp);
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1229  
7c3d5c20dc169e Daniel Lezcano 2022-10-03 @1230  	if (!tz->trips)
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1231  		return -EINVAL;
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1232  
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1233  	mutex_lock(&tz->lock);
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1234  
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1235  	for (i = 0; i < tz->num_trips; i++) {
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1236  		if (tz->trips[i].type == THERMAL_TRIP_CRITICAL) {
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1237  			*temp = tz->trips[i].temperature;
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1238  			ret = 0;
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1239  			break;
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1240  		}
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1241  	}
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1242  
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1243  	mutex_unlock(&tz->lock);
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1244  
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1245  	return ret;
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1246  }
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1247  EXPORT_SYMBOL_GPL(thermal_zone_get_crit_temp);
7c3d5c20dc169e Daniel Lezcano 2022-10-03  1248  

:::::: The code at line 1230 was first introduced by commit
:::::: 7c3d5c20dc169e55064f7f38c1c56cfbc39ee5b2 thermal/core: Add a generic thermal_zone_get_trip() function

:::::: TO: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>
:::::: CC: Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux