Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp127280yba; Mon, 20 May 2019 06:09:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgMrzZJQdcm+K6zApUpvt5TDeJVvyHxeb0OppG517LZgbwlSTiTE3JVZKIbXt9OjKcxKly X-Received: by 2002:a17:902:b949:: with SMTP id h9mr32516858pls.50.1558357782089; Mon, 20 May 2019 06:09:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558357782; cv=none; d=google.com; s=arc-20160816; b=FUOw49oRX0/ybpFNTzB1Ginot7l8MXyvF1Y8GDNN8ouV5i4osFoY1rl3Xcou7RSR4v 0qLRh5tjVXmZXfP3y+krSzQBv+dSOHrMKbK7AoGL9weuVWF1cFWXHX9j/RyXfwxp14V/ tnU6nZzJKne1JBHaaevho0dQl5m3/SUWQNWrTTrBcg7YmGLemZRBm6iLzh5gL+UaAkxR 0GqxzCRXH5q7gRqobgmQa74iS89ZtwjUfHnoKvhHldPPPqqbnTampg3A5jze/64Ire+7 6Ya/Botbf4Nt7LFVezBnHNsGOuUzoGsclQgYkKev9shFeqlkyfoqca3UtYuqlck4TlAi 3D9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=6ExCo8kZpI1oHvNOP5IL5x9QNEv/zomTqubLMg8qVGM=; b=x85uNrGGX03HseTbp26wLt0xlGDjRkliLrfwp5U1m3tCotr/I3/cfJeWcGLpiI8Co5 c9LfHrb8t1X4sr3tVcT40T6XSnMVX/Vh+Qw+p1MjFOj/YWeNRZe8j7z8N9xPsw04bce+ C3ZYwNzLY0L4W/9R9oaPuVLkBxxxeG20yoynSfvqOMIkpu4xET3F/na9EHthyPeEbt6H kkTPKPydbP9N0s/NBOgMLe9me8i4jB3h3Z0GBANvAWaykLE8pPVU8BzLp+bjhFenwCSY 9hyarE4dWJYmSogkXdPowkPFHyTg+YF36MB943iP1txY4UwnJ5aucYa5lnah1MIdvMTY uqHg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si17728669pgd.557.2019.05.20.06.09.24; Mon, 20 May 2019 06:09:42 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731811AbfETJGm (ORCPT + 99 others); Mon, 20 May 2019 05:06:42 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:45412 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730512AbfETJGl (ORCPT ); Mon, 20 May 2019 05:06:41 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4K93oKF011611; Mon, 20 May 2019 04:06:30 -0500 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0b-001ae601.pphosted.com with ESMTP id 2sjefmt40y-1; Mon, 20 May 2019 04:06:29 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail1.cirrus.com (Postfix) with ESMTP id 92B0C611C8B9; Mon, 20 May 2019 04:06:29 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Mon, 20 May 2019 10:06:28 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Mon, 20 May 2019 10:06:28 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 90D7745; Mon, 20 May 2019 10:06:28 +0100 (BST) From: Charles Keepax To: CC: , , , , Subject: [PATCH 1/4 RESEND] mfd: arizona: fix undefined behavior Date: Mon, 20 May 2019 10:06:25 +0100 Message-ID: <20190520090628.29061-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=927 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200066 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann When the driver is used with a subdevice that is disabled in the kernel configuration, clang gets a little confused about the control flow and fails to notice that n_subdevs is only uninitialized when subdevs is NULL, and we check for that, leading to a false-positive warning: drivers/mfd/arizona-core.c:1423:19: error: variable 'n_subdevs' is uninitialized when used here [-Werror,-Wuninitialized] subdevs, n_subdevs, NULL, 0, NULL); ^~~~~~~~~ drivers/mfd/arizona-core.c:999:15: note: initialize the variable 'n_subdevs' to silence this warning int n_subdevs, ret, i; ^ = 0 Ideally, we would rearrange the code to avoid all those early initializations and have an explicit exit in each disabled case, but it's much easier to chicken out and add one more initialization here to shut up the warning. Signed-off-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Signed-off-by: Charles Keepax --- drivers/mfd/arizona-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 27b61639cdc7e..0ca0fc9a67fd9 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -996,7 +996,7 @@ int arizona_dev_init(struct arizona *arizona) unsigned int reg, val; int (*apply_patch)(struct arizona *) = NULL; const struct mfd_cell *subdevs = NULL; - int n_subdevs, ret, i; + int n_subdevs = 0, ret, i; dev_set_drvdata(arizona->dev, arizona); mutex_init(&arizona->clk_lock); -- 2.11.0