From patchwork Fri Mar 22 14:09:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 160900 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp859858jan; Fri, 22 Mar 2019 07:10:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDW/ZKKRLU9tw3L1Ub5zPuMnNtr1MwDcOeIqObQ/1niq+g7pCoQXR9A31cdepsoBXrRTFb X-Received: by 2002:a63:4e4e:: with SMTP id o14mr9260609pgl.254.1553263809330; Fri, 22 Mar 2019 07:10:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553263809; cv=none; d=google.com; s=arc-20160816; b=JwzHcj2Xk1C/bxYyEOwcNgzrd1vWFlII6XCYHAQh97ObVc9il5u4uxejvWxawhY4uE E5T2iT+DiAo5gxxyKGCMmPF5fj/0ns1GBt9Qi7QwRBaGQOfwuWsb4MjkwAgCQR9NcBVr xBU/FwbkLS5g6IOPLEe99n4dgHIEqyYiVscOWFM8fn1fk7Z48aUQtJCaebqadePpbXOP JliV52kg8N0WpdGsaefOR6Z7ZxKk+p8H8jcFjT0pK9j5nBGSqA+t1tx4DFmlwYadZNDy P4pHtF+v4BDyZVA2pQpilFcXQKO587YsYTeKcg6KPZdrJip++lwl5Fr/wTCU+4WY1inB SNNQ== 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; bh=SrtTjMEcbGKVNz+5/q2g6yvsl8ykKg27wLHG42a+LlQ=; b=fJbP5t0QpicGLcIxSBTiackyz07PAiOK9oL77JxK22wpPDE7Vki64PePdacPasolXw hxKsn4FpDv8sVaUqHDAUL7HUSwNW+skpGvVkUq/cmREqTSTs71YE6FNFz4h3ds31EZTN IgOmYmVfkB8qB5Nw2QQqwp04gK0v+NrzgNNxc8NUSoas4cIHJkiXYmAURwZzVZgBDodO N7xP194p3bIq4tcDmblY2hcMc892OhXW6A1qTFrlQ4eGE17Mf/n8WOXdcEW5mgBnFmXH g0E44iKtG/FqI6oN5nxDh7DN6UVvvCSRf7GhcX7VV/ce2+gWvi9OKWeDRPx9s5KsJxQg 1N1Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7si7443327pla.195.2019.03.22.07.10.09; Fri, 22 Mar 2019 07:10:09 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728673AbfCVOKI (ORCPT + 31 others); Fri, 22 Mar 2019 10:10:08 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:37309 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727487AbfCVOKH (ORCPT ); Fri, 22 Mar 2019 10:10:07 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MVdYY-1hWWi820tY-00RXj6; Fri, 22 Mar 2019 15:09:40 +0100 From: Arnd Bergmann To: Jonathan Cameron Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , Hartmut Knaack , Lars-Peter Clausen , Peter Meerwald-Stadler , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iio: ssp_sensors: avoid uninitialized variable usage Date: Fri, 22 Mar 2019 15:09:22 +0100 Message-Id: <20190322140937.341976-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 X-Provags-ID: V03:K1:QnhDsqh0KFlM5KhzUi7mwUL/YxGqNJt2E7AsUWOjxw8veKn2kNV GVKj1SnggcVRNfOWjpqszRpv6aG7YhNIJKMdSSj/pb0uGa61sLQZGXHnJiDTIBj22tljuPx 5Pilkt2DjVO2OJ99kLk44aQ5o5meReVb2ATUEL3otYpGfyTEpEYTqQ7M4MyUZHZwel6jaCF fsoq8/QyCbrPeWOFH1aWA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:NqvslkTHWSA=:5YLorGwbZnoLpmp35glNcR a0wm+HstR6VbmrvopVmYSxi31OJiUDThx841ncqQZ/vy5S//QjxLS41yaK0mEjYnXGSQj8gkQ xm/HCuwuoSEFYJYqFp3TILDvYSf5A0ZUPQeauRZGvkwACGitKj43maayK7pGG0yp0i0D+hKyF mYIg+tTdSp7uerR4bm7i1Lrh4SC4vI9z3Eo0/8j1j2ofc7P0Ok0Ccc9dpDk+8jUdh71antlFl 0QSofRrau8A53+9pdS5MST+DBp2/UhG/9QRz0fWh8vkK+I1hGH8vespqeTiClIjgeEYsJBHan +Yu5/YehILkU213dipTv/wFgP7ju49sliEvcUTb29a7O4f35Q8Yy2o0fewyLKuqULL6Jedrnw fBC4HO6taoPnetwyv5UkGIEXp0Bd4DKPIAK0jwYZOGRb4E3MBwFe+g6bShd7u5aED5K/h7TiE flGE/5bkcaHQWfnFGhb4YWvPfAFi3o98fM9264lf/VgT2EW26jOIvtI0gj5HYEKZ5kD9OxK/A Za8rwM4gs0s1detjYq1CRFZ5xMAN0OcwOxC6Hs5TUO4VtAQ+75dzpmsy7N9lHKyIpmDmPc2bH QkEg/ZgkkEWOnF5RwoCELVMNzbeE8u1TP5LnjtldbPXu1Y4vTfO32oT2BjMxPQXBsyIy5h24a 4se/ewvyC4XzhJc9Z6vtCRd6XDs3HIQmGR7etjVCOrYATMlUyNNio2h+HzNEzH58K9ixLUNda 1h5h3ox2cXMkg/eu/Ejo6E1ntXXyaNqut8Kebw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org clang points out that 'calculated_time' is only sometimes initialized here, which leads to incorrect data being passed into another function: drivers/iio/common/ssp_sensors/ssp_iio.c:95:6: error: variable 'calculated_time' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] if (indio_dev->scan_timestamp) { ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/iio/common/ssp_sensors/ssp_iio.c:102:9: note: uninitialized use occurs here calculated_time); ^~~~~~~~~~~~~~~ drivers/iio/common/ssp_sensors/ssp_iio.c:95:2: note: remove the 'if' if its condition is always true if (indio_dev->scan_timestamp) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/iio/common/ssp_sensors/ssp_iio.c:84:25: note: initialize the variable 'calculated_time' to silence this warning int64_t calculated_time; ^ The data is subsequently ignored by iio_push_to_buffers_with_timestamp(), but the warning still feels legitimate and to work around it, we can initialize the time in the other case. Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=18501 Signed-off-by: Arnd Bergmann --- drivers/iio/common/ssp_sensors/ssp_iio.c | 2 ++ 1 file changed, 2 insertions(+) -- 2.20.0 Reviewed-by: Nathan Chancellor diff --git a/drivers/iio/common/ssp_sensors/ssp_iio.c b/drivers/iio/common/ssp_sensors/ssp_iio.c index 645f2e3975db..81e8f4844c90 100644 --- a/drivers/iio/common/ssp_sensors/ssp_iio.c +++ b/drivers/iio/common/ssp_sensors/ssp_iio.c @@ -96,6 +96,8 @@ int ssp_common_process_data(struct iio_dev *indio_dev, void *buf, memcpy(&time, &((char *)buf)[len], SSP_TIME_SIZE); calculated_time = timestamp + (int64_t)le32_to_cpu(time) * 1000000; + } else { + calculated_time = 0; } return iio_push_to_buffers_with_timestamp(indio_dev, spd->buffer,