Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1211115ybl; Wed, 29 Jan 2020 17:42:50 -0800 (PST) X-Google-Smtp-Source: APXvYqz06R8gWaxYhEn90FfYD6g90/tUVUOzrxuY+JFQeHPoNXoABK+ZW40XBalQ19EHXwlaeX0M X-Received: by 2002:aca:d483:: with SMTP id l125mr1298080oig.124.1580348570736; Wed, 29 Jan 2020 17:42:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580348570; cv=none; d=google.com; s=arc-20160816; b=rRSa4vzwjD+bmKn929eORDsWKDMgRBzrikwC6ZyCSZEoY83c51XZIDsJ9txBZCq+GH zKRX+C3Zlfceo16FHA8Y9rsdp4EGiPXvvlIkB0A8ZS5JbkviwooyGwyN5xDSFb2fd4A3 wSPsbZnVILAbtZWcxGkg7ARFqnMAHWMZ76oX6YeBSqjqW8Nq1cbn5dRRq/wfrF+AT9bw RZXq1UTt9ugUFochVpNc7WLLYNh9epFEjx7AH6zOZnqsbXi6pc+BkHAvuNSRUMTEujzl bUG2kwMGX0Lj5SEO3V8ehzka9QAPF/hC3FS2UraKmibgQIAmOQzEo2Txw1GzQX7CJwUo R4IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2P8mIQM2+gpGwwpWHO7MIWsL+16CozNLtmz3AeK6KJA=; b=OsMoca71Zsr9eAMWiEda5UTIFd4ObhNhziFQRBN8tTTsj5RZTbXQqGzBCdoSbn8Pz0 UhNIYdxfcWf1OOBGV6AvzIVshdYCxpICbESXX0Fw8nDes6CbM0XTlpWhoKrAWv4bMQ84 a3ooTeDsOK0HWtHtFeq0N5IcXz+j//EGMuHxC3kl9YsHAqsGbe9COiJsR3oQOU6KyUG4 04luUurZZS3cXmXtc4hIMUiQGlxbSS+ZdhH4H5jHBt1JlxTM7zrkZ+P7RX+zn/gKYgAb 2GCwFJEy0/40QdSZrKqvSbrc7P/ozSW4gGnoocYZFkSXAtwowWnNTrhJOnY6/WnQX9lG Ha2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sh4KnuZP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5si2139839otp.108.2020.01.29.17.42.36; Wed, 29 Jan 2020 17:42:50 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=sh4KnuZP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727224AbgA3Blg (ORCPT + 99 others); Wed, 29 Jan 2020 20:41:36 -0500 Received: from mail-ot1-f66.google.com ([209.85.210.66]:46069 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726618AbgA3Blg (ORCPT ); Wed, 29 Jan 2020 20:41:36 -0500 Received: by mail-ot1-f66.google.com with SMTP id 59so1579333otp.12; Wed, 29 Jan 2020 17:41:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2P8mIQM2+gpGwwpWHO7MIWsL+16CozNLtmz3AeK6KJA=; b=sh4KnuZPnRoQwLcdY0e21qeGh/RWA9KkP9Xk6BJa9lr+DwN0U5HxoXsVrMTKefUF2z xwCqC9eiI+Qy/ZyiVxzhWNmb1faaD9Xpv+8eUaRcq1F3y+CmuIpE/RT4Tzv70wMzTY/4 4H3m1olAIjuotpPfb0MQyMYNnFPO8bhpxH0rIJPZV1J3od0WRmrIJj9hvo+R6wfP4FHS y5hqf0Ty2PyndwVfeQkzHspDrb9II6JQj/IrNY+gDfHDSiq7T1pWwBe/+yqWcN2KKQSp dkspeeCwD9+l/kO0PffVUSyHijvVdI8lsEV/dGHJu49spPpLVWzwehLRfREsvZuNa97e 7aAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2P8mIQM2+gpGwwpWHO7MIWsL+16CozNLtmz3AeK6KJA=; b=V2Tqqnd8qGZC0+cNER460B7wi8zq+03LgnQappyhSjTvBuDjI+crbn4LMdC5QNTJHM 95wIEQLo1MgJy3iz9GQQU/K6k5un9aYOnl7iLWesFDm4DGUmRJwhZVxYLdzNKKyZS/k/ D0ePb+iaID6GP9PS71Iuy3FNtvGmixzkJESbtC+a4uH2n8a0LfTxfrAqYAlCAE+YUoGv nCBuoeSj58NcgTZSybqOTkXDjrONYRR+vr3pSA2IEcr+axK247A0V7q4CaVT+cvYANln aE7GY9Aec9B5n8QePqhNZAeqYBhtJ+leAY09LjdxXvIZ132gR/OPktkC5t0YjAomdtis a3TA== X-Gm-Message-State: APjAAAVbYSwkZR3B/IEx7Z16oQmltiw+fKSE+evtYbdACYhH9Jg7oPN+ eEcU4juny069OU4tAcipOSE= X-Received: by 2002:a9d:8f1:: with SMTP id 104mr1637192otf.107.1580348495040; Wed, 29 Jan 2020 17:41:35 -0800 (PST) Received: from localhost.localdomain ([2604:1380:4111:8b00::1]) by smtp.gmail.com with ESMTPSA id j45sm1313526ota.59.2020.01.29.17.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Jan 2020 17:41:33 -0800 (PST) From: Nathan Chancellor To: Niklas Cassel Cc: Andy Gross , Bjorn Andersson , Kevin Hilman , Nishanth Menon , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Nathan Chancellor Subject: [PATCH] power: avs: qcom-cpr: Avoid clang -Wsometimes-uninitialized in cpr_scale Date: Wed, 29 Jan 2020 18:41:30 -0700 Message-Id: <20200130014130.51313-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clang warns (trimmed for brevity): ../drivers/power/avs/qcom-cpr.c:570:13: warning: variable 'reg_mask' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] ../drivers/power/avs/qcom-cpr.c:520:13: warning: variable 'new_uV' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized] Due to the fact that Clang's static analysis happens before any optimization passes are taken into account, it cannot see that both branches in the if statement must be taken because dir cannot be something other than UP or DOWN due to the check at the top of this function. Change the else if condition to else to fix this false positive. Fixes: bf6910abf548 ("power: avs: Add support for CPR (Core Power Reduction)") Link: https://github.com/ClangBuiltLinux/linux/issues/840 Signed-off-by: Nathan Chancellor --- drivers/power/avs/qcom-cpr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/power/avs/qcom-cpr.c b/drivers/power/avs/qcom-cpr.c index 9192fb747653..e8831e4aee05 100644 --- a/drivers/power/avs/qcom-cpr.c +++ b/drivers/power/avs/qcom-cpr.c @@ -517,7 +517,7 @@ static int cpr_scale(struct cpr_drv *drv, enum voltage_change_dir dir) dev_dbg(drv->dev, "UP: -> new_uV: %d last_uV: %d perf state: %u\n", new_uV, last_uV, cpr_get_cur_perf_state(drv)); - } else if (dir == DOWN) { + } else { if (desc->clamp_timer_interval && error_steps < desc->down_threshold) { /* @@ -567,7 +567,7 @@ static int cpr_scale(struct cpr_drv *drv, enum voltage_change_dir dir) /* Disable auto nack down */ reg_mask = RBCPR_CTL_SW_AUTO_CONT_NACK_DN_EN; val = 0; - } else if (dir == DOWN) { + } else { /* Restore default threshold for UP */ reg_mask = RBCPR_CTL_UP_THRESHOLD_MASK; reg_mask <<= RBCPR_CTL_UP_THRESHOLD_SHIFT; -- 2.25.0