:::::: 
:::::: Manual check reason: "low confidence static check warning: 
drivers/thermal/k3_j72xx_bandgap.c:83:12: warning: Parameter 'ref_table' can be 
declared with const [constParameter]"
:::::: 

BCC: [email protected]
CC: [email protected]
CC: [email protected]
TO: Keerthy <[email protected]>
CC: Daniel Lezcano <[email protected]>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 
master
head:   3245cb65fd91cd514801bf91f5a3066d562f0ac4
commit: ffcb2fc86eb7ebc9f5524525fb57e1cccfbd1fc0 thermal: k3_j72xx_bandgap: Add 
the bandgap driver support
date:   4 months ago
:::::: branch date: 2 days ago
:::::: commit date: 4 months ago
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (cppcheck warning):
        # apt-get install cppcheck
        git checkout ffcb2fc86eb7ebc9f5524525fb57e1cccfbd1fc0
        cppcheck --quiet --enable=style,performance,portability --template=gcc 
FILE

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>

cppcheck warnings: (new ones prefixed by >>)
>> drivers/thermal/thermal_sysfs.c:613:6: warning: %ld in format string (no. 1) 
>> requires 'long *' but the argument type is 'unsigned long *'. 
>> [invalidScanfArgType_int]
    if (sscanf(buf, "%ldn", &state) != 1)
        ^

cppcheck possible warnings: (new ones prefixed by >>, may not real problems)

>> drivers/thermal/thermal_hwmon.c:100:11: warning: Uninitialized variables: 
>> hwmon.device, hwmon.count, hwmon.tz_list, hwmon.node [uninitvar]
      return hwmon;
             ^
--
>> drivers/thermal/rcar_gen3_thermal.c:146:45: warning: Shifting a negative 
>> value is technically undefined behaviour [shiftNegativeLHS]
          / (priv->ptat[0] - priv->ptat[2])) + FIXPT_INT(TJ_3);
                                               ^
   drivers/thermal/rcar_gen3_thermal.c:148:17: warning: Shifting a negative 
value is technically undefined behaviour [shiftNegativeLHS]
    tsc->coef.a1 = FIXPT_DIV(FIXPT_INT(tsc->thcode[1] - tsc->thcode[2]),
                   ^
--
>> drivers/thermal/thermal_sysfs.c:589:9: warning: %ld in format string (no. 1) 
>> requires 'long' but the argument type is 'unsigned long'. 
>> [invalidPrintfArgType_sint]
    return sprintf(buf, "%ldn", state);
           ^
   drivers/thermal/thermal_sysfs.c:602:9: warning: %ld in format string (no. 1) 
requires 'long' but the argument type is 'unsigned long'. 
[invalidPrintfArgType_sint]
    return sprintf(buf, "%ldn", state);
           ^
>> drivers/thermal/thermal_sysfs.c:891:9: warning: %d in format string (no. 1) 
>> requires 'int' but the argument type is 'unsigned int'. 
>> [invalidPrintfArgType_sint]
    return sprintf(buf, "%dn", instance->weight);
           ^
>> drivers/thermal/thermal_sysfs.c:721:10: warning: %u in format string (no. 1) 
>> requires 'unsigned int' but the argument type is 'signed int'. 
>> [invalidPrintfArgType_uint]
     len += sprintf(buf + len, "state%ut%llun", i,
            ^
   drivers/thermal/thermal_sysfs.c:765:10: warning: %u in format string (no. 1) 
requires 'unsigned int' but the argument type is 'signed int'. 
[invalidPrintfArgType_uint]
     len += snprintf(buf + len, PAGE_SIZE - len, "state%2u  ", i);
            ^
   drivers/thermal/thermal_sysfs.c:776:10: warning: %u in format string (no. 1) 
requires 'unsigned int' but the argument type is 'signed int'. 
[invalidPrintfArgType_uint]
     len += snprintf(buf + len, PAGE_SIZE - len, "state%2u:", i);
            ^
--
>> drivers/thermal/k3_j72xx_bandgap.c:83:12: warning: Parameter 'ref_table' can 
>> be declared with const [constParameter]
         int *ref_table)
              ^
--
>> drivers/thermal/rcar_thermal.c:409:32: warning: Uninitialized variables: 
>> priv.common, priv.zone, priv.chip, priv.work, priv.lock, priv.list, priv.id 
>> [uninitvar]
     if (rcar_thermal_had_changed(priv, status)) {
                                  ^
   drivers/thermal/rcar_thermal.c:429:3: warning: Uninitialized variables: 
priv.common, priv.zone, priv.chip, priv.work, priv.lock, priv.list, priv.id 
[uninitvar]
     rcar_thermal_irq_disable(priv);
     ^

vim +/ref_table +83 drivers/thermal/k3_j72xx_bandgap.c

ffcb2fc86eb7eb Keerthy 2022-05-17   81  
ffcb2fc86eb7eb Keerthy 2022-05-17   82  static void 
create_table_segments(struct err_values *err_vals, int seg,
ffcb2fc86eb7eb Keerthy 2022-05-17  @83                                    int 
*ref_table)
ffcb2fc86eb7eb Keerthy 2022-05-17   84  {
ffcb2fc86eb7eb Keerthy 2022-05-17   85          int m = 0, c, num, den, i, err, 
idx1, idx2, err1, err2, ref1, ref2;
ffcb2fc86eb7eb Keerthy 2022-05-17   86  
ffcb2fc86eb7eb Keerthy 2022-05-17   87          if (seg == 0)
ffcb2fc86eb7eb Keerthy 2022-05-17   88                  idx1 = 0;
ffcb2fc86eb7eb Keerthy 2022-05-17   89          else
ffcb2fc86eb7eb Keerthy 2022-05-17   90                  idx1 = 
err_vals->refs[seg];
ffcb2fc86eb7eb Keerthy 2022-05-17   91  
ffcb2fc86eb7eb Keerthy 2022-05-17   92          idx2 = err_vals->refs[seg + 1];
ffcb2fc86eb7eb Keerthy 2022-05-17   93          err1 = err_vals->errs[seg];
ffcb2fc86eb7eb Keerthy 2022-05-17   94          err2 = err_vals->errs[seg + 1];
ffcb2fc86eb7eb Keerthy 2022-05-17   95          ref1 = err_vals->refs[seg];
ffcb2fc86eb7eb Keerthy 2022-05-17   96          ref2 = err_vals->refs[seg + 1];
ffcb2fc86eb7eb Keerthy 2022-05-17   97  
ffcb2fc86eb7eb Keerthy 2022-05-17   98          /*
ffcb2fc86eb7eb Keerthy 2022-05-17   99           * Calculate the slope with adc 
values read from the register
ffcb2fc86eb7eb Keerthy 2022-05-17  100           * as the y-axis param and err 
in adc value as x-axis param
ffcb2fc86eb7eb Keerthy 2022-05-17  101           */
ffcb2fc86eb7eb Keerthy 2022-05-17  102          num = ref2 - ref1;
ffcb2fc86eb7eb Keerthy 2022-05-17  103          den = err2 - err1;
ffcb2fc86eb7eb Keerthy 2022-05-17  104          if (den)
ffcb2fc86eb7eb Keerthy 2022-05-17  105                  m = num / den;
ffcb2fc86eb7eb Keerthy 2022-05-17  106          c = ref2 - m * err2;
ffcb2fc86eb7eb Keerthy 2022-05-17  107  
ffcb2fc86eb7eb Keerthy 2022-05-17  108          /*
ffcb2fc86eb7eb Keerthy 2022-05-17  109           * Take care of divide by zero 
error if error values are same
ffcb2fc86eb7eb Keerthy 2022-05-17  110           * Or when the slope is 0
ffcb2fc86eb7eb Keerthy 2022-05-17  111           */
ffcb2fc86eb7eb Keerthy 2022-05-17  112          if (den != 0 && m != 0) {
ffcb2fc86eb7eb Keerthy 2022-05-17  113                  for (i = idx1; i <= 
idx2; i++) {
ffcb2fc86eb7eb Keerthy 2022-05-17  114                          err = (i - c) / 
m;
ffcb2fc86eb7eb Keerthy 2022-05-17  115                          if (((i + err) 
< 0) || ((i + err) >= TABLE_SIZE))
ffcb2fc86eb7eb Keerthy 2022-05-17  116                                  
continue;
ffcb2fc86eb7eb Keerthy 2022-05-17  117                          
derived_table[i] = ref_table[i + err];
ffcb2fc86eb7eb Keerthy 2022-05-17  118                  }
ffcb2fc86eb7eb Keerthy 2022-05-17  119          } else { /* Constant error take 
care of divide by zero */
ffcb2fc86eb7eb Keerthy 2022-05-17  120                  for (i = idx1; i <= 
idx2; i++) {
ffcb2fc86eb7eb Keerthy 2022-05-17  121                          if (((i + err1) 
< 0) || ((i + err1) >= TABLE_SIZE))
ffcb2fc86eb7eb Keerthy 2022-05-17  122                                  
continue;
ffcb2fc86eb7eb Keerthy 2022-05-17  123                          
derived_table[i] = ref_table[i + err1];
ffcb2fc86eb7eb Keerthy 2022-05-17  124                  }
ffcb2fc86eb7eb Keerthy 2022-05-17  125          }
ffcb2fc86eb7eb Keerthy 2022-05-17  126  }
ffcb2fc86eb7eb Keerthy 2022-05-17  127  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to