From patchwork Wed Jun 21 22:10:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9803117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9904C6038C for ; Wed, 21 Jun 2017 22:11:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 90E5928409 for ; Wed, 21 Jun 2017 22:11:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8572028512; Wed, 21 Jun 2017 22:11:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B1932846B for ; Wed, 21 Jun 2017 22:11:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752564AbdFUWLE (ORCPT ); Wed, 21 Jun 2017 18:11:04 -0400 Received: from mout.kundenserver.de ([217.72.192.74]:49624 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751979AbdFUWLC (ORCPT ); Wed, 21 Jun 2017 18:11:02 -0400 Received: from wuerfel.lan ([5.56.224.194]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MNtut-1dPje71NNr-007QuW; Thu, 22 Jun 2017 00:10:48 +0200 From: Arnd Bergmann To: Hans Verkuil , Mauro Carvalho Chehab Cc: Arnd Bergmann , Colin Ian King , Wei Yongjun , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [media] rainshadow-cec: avoid -Wmaybe-uninitialized warning again Date: Thu, 22 Jun 2017 00:10:32 +0200 Message-Id: <20170621221047.128705-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:MobarWjIlbtZkZ1PbvUoFZWAywzLsF6CV8altj5RVP1E3FW+v0h JPESlibL2T3zX1od16CksQrCccoJzPt5qCy8qHUlgx2h2ssNOZ7gTt4Rw4QrDLK6MMDMxWA 9iyALhNRoBLrxAxYFS1+ASRiH5pp9Ij+DelMBJat5SavFWV9RnEVVwRVdHS8+Yx3esUuLHz hshkyQF2dzX4kwYai4HGA== X-UI-Out-Filterresults: notjunk:1; V01:K0:BmEY7KdHfq4=:43cMpf/Yt8+QkB+PfzB//E MK/ThpTvOOs8nC28XRgWgJKXat5xl4BfydNe7C4tap0pcmMYH3AJhw1NGA6ILFanik4MhfxEW ySxzRwBP6Wbjo0DjQUSXOAsgToJtDO2z9ipy0dlhFr7cBK0FpRgGHgdQknyuOKsOMkPHZjmPi cm8mAKMST8K3zdX1/RYDd58b4xlocs851hvGaJKdlVl8Tpy1NJ2U2QsahOrggIjYrdeRugkCA 4PirsSPCBJOPB9TogXMCAnErGz+5oukOKdWVd2WrzZBLeawfadMBnQ/5p07jswLkqFZAA5vk0 Diid8dlLFWv4+VNlfTmPUnVrc1CikD3c5huY0I/Vqgv+GIr6r8/3x8L1zgAWulADgCNMNbCre dHzjz25y+zwabSWdzdnnBZydfZxfimsah74b4ukJyq9ihVDREk99V7vZ+EHcYbf+c3XlwqT5d uMeOYg7/MtYaRA/Xln8L4S7/JhSPcD/zw0iL3whD0Kavxhxc0QsuRsIQ810YJBBwa02ZTkFBj +p3R8dV3fpMrkkVJRLXk22LwN13jyS9Cp6QXDfYDRktCDvgf5BZeZCQ7i7h1cxhw0M5oQVx61 BoSTLCXJ4R/KGI2c+Y0IzbYVNlGiOl7RSyJeg+VtiucflxOdN3tgneeG7KQnxnQsAPgho+8kY gt8XhePZ/9w/LQ8Hp5ps+dFMrH9jT3GiYPjPVm7kSGXzm6HlFzEvcFCpgSCc1uSiNpaA= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Back in April I created a patch to address a false-positive warning: drivers/media/usb/rainshadow-cec/rainshadow-cec.c: In function 'rain_irq_work_handler': drivers/media/usb/rainshadow-cec/rainshadow-cec.c:171:31: error: 'data' may be used uninitialized in this function [-Werror=maybe-uninitialized] My patch was totally wrong and introduced a real bug, and Colin Ian King thankfully noticed it now and fixed my mistake. Unfortunately, fixing the actual uninitialized data in this case brought back the original bogus warning. This is a new version of the patch, which simplifies the code to the point where gcc notices the behavior is correct. Fixes: ca33784ba494 ("[media] rainshadow-cec: ensure exit_loop is intialized") Fixes: ea6a69defd3311 ("[media] rainshadow-cec: avoid -Wmaybe-uninitialized warning") Cc: Colin Ian King Signed-off-by: Arnd Bergmann --- drivers/media/usb/rainshadow-cec/rainshadow-cec.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/media/usb/rainshadow-cec/rainshadow-cec.c b/drivers/media/usb/rainshadow-cec/rainshadow-cec.c index ad468efc4399..7bc28bb92c35 100644 --- a/drivers/media/usb/rainshadow-cec/rainshadow-cec.c +++ b/drivers/media/usb/rainshadow-cec/rainshadow-cec.c @@ -119,21 +119,19 @@ static void rain_irq_work_handler(struct work_struct *work) while (true) { unsigned long flags; - bool exit_loop = false; char data; spin_lock_irqsave(&rain->buf_lock, flags); - if (rain->buf_len) { - data = rain->buf[rain->buf_rd_idx]; - rain->buf_len--; - rain->buf_rd_idx = (rain->buf_rd_idx + 1) & 0xff; - } else { - exit_loop = true; + if (!rain->buf_len) { + spin_unlock_irqrestore(&rain->buf_lock, flags); + break; } - spin_unlock_irqrestore(&rain->buf_lock, flags); - if (exit_loop) - break; + data = rain->buf[rain->buf_rd_idx]; + rain->buf_len--; + rain->buf_rd_idx = (rain->buf_rd_idx + 1) & 0xff; + + spin_unlock_irqrestore(&rain->buf_lock, flags); if (!rain->cmd_started && data != '?') continue;