Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1510051pxk; Fri, 4 Sep 2020 11:09:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBvQSsJKgeoQspCMhtzbs1oIvuDzmyD4AUdUCalxejh95lgErsQ0IntzuTXjchvi0gUK2s X-Received: by 2002:a17:906:a2d9:: with SMTP id by25mr8893354ejb.326.1599242949841; Fri, 04 Sep 2020 11:09:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599242949; cv=none; d=google.com; s=arc-20160816; b=nVMSncXkAte62KNCPUGj5wKBcJ7W4I3UCi0Bt8hOaf7RBCaBMSNBzGn0ZKMBxhJfPn 5oWgZkotumDXmeXdpk+rvPhVLvSgLixAiml/gCKhwrC6vuv3yuBNLRqHMDZgQ3I/AuKR w5TlE8vDthkaxHMGZUZSO/+u7Hld8u7q1dukRHAwL2AlXAcXMS5F9UpILGMxalzHVp83 GljvpLCq+gWbukYKkT+InWiCKi7wNBsirAXDgI4xRMxeb+PkYUhNhWw8WelhTdNqxDgl ujAzLxKHOeLlUOkSGFSnCiOQVMvZDJZKekfQ8WYaaNoUF27r8cLZ4DqhbaltWGK/U0Sc DBuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=ZgNkYrXayCXVqunlsQHYlfke0k0uTa2/dq5wz4jdf0U=; b=WC+e0Wmwwf3hGr8gp+aGdJPIFKxoUhm1UDC+ALUEQwnj4j8bIjXO1KtNdR5JEsuy3+ 06Ef7w2DTf+YQm754KdyUT5UOzpASHvt3edDKEUOGzQ7V8nj83k/fe4xH2LP42IWmuFa EJ7qJbTuhgksTPHGLuhiUU9sAqs094Xyrh4jjzITQAlPkeC+r+x0voZQhb6SgwTQzVQ0 iND73bmQxOn7rMv0LA38K//1ovMsg2KLonui4celyCwNPQDFUuocoWr5728XR2gr+At5 6qaGEezJw18TNvr9hmmNYrkZfC2mVtFELlgDy8c6Qu/oMg6LKB3uQ4gSd8qbxYknseCb 6JkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JWXp42iJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x21si437242ejb.137.2020.09.04.11.08.46; Fri, 04 Sep 2020 11:09:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JWXp42iJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726618AbgIDSHA (ORCPT + 99 others); Fri, 4 Sep 2020 14:07:00 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:25303 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726047AbgIDSG6 (ORCPT ); Fri, 4 Sep 2020 14:06:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599242817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc; bh=ZgNkYrXayCXVqunlsQHYlfke0k0uTa2/dq5wz4jdf0U=; b=JWXp42iJ5jirKaEb8/Zc3Cxaen3f/Q6n/BFMoQ+9qBU1J16QSWXlP3ROqMmGtqllfLxfzA GeDlath/UrdZKDBHgXZzg/HYsOyBKDyOstLEGp0HVp9e3XYsbR2X+SoFpvUzTnTHFNVopW 1hplOU9veUkJ8aMpw7LJx2jdEnoVoz4= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-539-UhS_OZuCM4q7k8E4RWxZLQ-1; Fri, 04 Sep 2020 14:06:53 -0400 X-MC-Unique: UhS_OZuCM4q7k8E4RWxZLQ-1 Received: by mail-qt1-f200.google.com with SMTP id e14so4877249qtm.5 for ; Fri, 04 Sep 2020 11:06:53 -0700 (PDT) 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; bh=ZgNkYrXayCXVqunlsQHYlfke0k0uTa2/dq5wz4jdf0U=; b=l24ESA4gaat2iUqh8SbV2CBswPGKmMJ4270AIQFO89ATLu1KDHgplvWh7ROxVAzFmN jYoAiVi4XMJdqGO1cwgzfEQ8wO8ke12CPBSLeIuf2xP1vpP19+wlbNz9AuSMHfTyLWQI Hr4M+s6ehW5J8ogIIBY6b2F4a5PZwKRcPD3mbhybyQGntRC2Y7LhQZ0LcC5+dw3JrIHZ RaV4eIQ/VqL46kLqTL5Xq+1GfiS0lhp2mpP3qCVozxCCBNZNIfnnAe0pGRgZNeSKjx23 r4FuVuaINa69wniJ8b/sHQvShvJcGl35Llwx3ASjlPXoflrMkr2n2ouRgDiUWs0AN30T B8LQ== X-Gm-Message-State: AOAM530kOeMioUx4t5oQQohXnFWlTcj3gg/5lpD12xueYguaOgHzL//d ZrbhFXmm4LJJwbAFZq+g7OBhib4iDgVSMkUn1WdkFxKFnv39xhfrTQZ8j/H0XNX8zkPZNUvPYkG eGmuQbcESq3IhcHbIfeNDK+6V X-Received: by 2002:ac8:6141:: with SMTP id d1mr9801724qtm.170.1599242813492; Fri, 04 Sep 2020 11:06:53 -0700 (PDT) X-Received: by 2002:ac8:6141:: with SMTP id d1mr9801702qtm.170.1599242813220; Fri, 04 Sep 2020 11:06:53 -0700 (PDT) Received: from trix.remote.csb (075-142-250-213.res.spectrum.com. [75.142.250.213]) by smtp.gmail.com with ESMTPSA id t69sm4879928qka.73.2020.09.04.11.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Sep 2020 11:06:52 -0700 (PDT) From: trix@redhat.com To: syniurge@gmail.com, nehal-bakulchandra.shah@amd.com, shyam-sundar.s-k@amd.com, natechancellor@gmail.com, ndesaulniers@google.com Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Tom Rix Subject: [PATCH] i2c: amd_mp2: handle num is 0 input for i2c_amd_xfer Date: Fri, 4 Sep 2020 11:06:47 -0700 Message-Id: <20200904180647.21080-1-trix@redhat.com> X-Mailer: git-send-email 2.18.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Rix clang static analyzer reports this problem i2c-amd-mp2-plat.c:174:9: warning: Branch condition evaluates to a garbage value return err ? err : num; ^~~ err is not initialized, it depends on the being set in the transfer loop which will not happen if num is 0. Surveying other master_xfer() implementations show all handle a 0 num. Because returning 0 is expected, initialize err to 0. Signed-off-by: Tom Rix --- drivers/i2c/busses/i2c-amd-mp2-plat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-amd-mp2-plat.c b/drivers/i2c/busses/i2c-amd-mp2-plat.c index 17df9e8845b6..506433bc0ff2 100644 --- a/drivers/i2c/busses/i2c-amd-mp2-plat.c +++ b/drivers/i2c/busses/i2c-amd-mp2-plat.c @@ -155,7 +155,7 @@ static int i2c_amd_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) struct amd_i2c_dev *i2c_dev = i2c_get_adapdata(adap); int i; struct i2c_msg *pmsg; - int err; + int err = 0; /* the adapter might have been deleted while waiting for the bus lock */ if (unlikely(!i2c_dev->common.mp2_dev)) -- 2.18.1