drm/nouveau: fan:

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

 



Hi,

static analysis with cppcheck has detected an issue in function nvkm_fan_update() in drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c as follows:

        /* schedule next fan update, if not at target speed already */
        if (target != duty) {
                u16 bump_period = fan->bios.bump_period;
                u16 slow_down_period = fan->bios.slow_down_period;
                u64 delay;

                if (duty > target)
                        delay = slow_down_period;
                else if (duty == target)
                        delay = min(bump_period, slow_down_period) ;
                else
                        delay = bump_period;

                nvkm_timer_alarm(tmr, delay * 1000 * 1000, &fan->alarm);
        }

Checking drivers/gpu/drm/nouveau/nvkm/subdev/therm/gm107.c ...
drivers/gpu/drm/nouveau/nvkm/subdev/therm/fan.c:93:17: warning: Opposite inner 'if' condition leads to a dead code block. [oppositeInnerCondition]
  else if (duty == target)
                ^

The first if statement checks if target != duty, however inside the code block there is a check if duty == target which can never be true. Either the logic is wrong, or the duty == target can be safely removed.

Colin



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux