Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp354188imm; Thu, 13 Sep 2018 00:39:40 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda2RLL25isQObA6Lf7HD8aP/qWoz1skBbX1oaY8pC3Fw/kOh5USxw/L3SWZmDhIIZvIe1CG X-Received: by 2002:a62:cdcf:: with SMTP id o198-v6mr6172323pfg.12.1536824380609; Thu, 13 Sep 2018 00:39:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536824380; cv=none; d=google.com; s=arc-20160816; b=LlPLlnugiQ4XhiyCtXgrQ0hPSn/5GOQI9Vtx+IVWXexCxF0A6Y9/w57bBtQC0fwziH cer4yXd17r2onAGvToige8Is6O85gtnSU8yXnYCA9Gfu/m0WnZd5SkCwaWza37LxEsCw 5XmSmjYjKwFbCYyRQ+AYp3WKAJZEoeTXGMF9/qx5sgQSCU0Xdm6PklkMrvs4KwUJFHOm VJfwlZbO+AKffbeiTJHZ58yyAvdFkjR/ZK4cghS09Yj0yEuJ/bC5O0eoa5NZJZLU9TCE ID5vBLDEJwsUYNVdKajdmwcjXpdD3Q+OG8uYcwYgcnyNpsn3HD/P+xr984Ej4hWVN9r2 D42A== 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:in-reply-to :references:subject:illegal-object:cc:to:mime-version:user-agent :from:date:message-id; bh=qvcbeo2x0O5oxrTleZpF/o/jR9zPahKPi+RvtIDobqQ=; b=gR4fU9kc7LBcoRKPzBTiXUlMMRhn7eMT54OJJ+6vaWgvPuWwWSHQZiSWnAZhnGTXM5 r67UNVuwj3qyAxpUXvJIuBkyul8dIEejxZr/loxT/H2Zl+KgILEDB78t51ZOhsIiaJbZ p9/Lz44/g3btIC2ZNRkzEKcZ3VVGzyIMCJ7OBhsJzxKI75hXOFmRfbbxZSkobbrY7ja8 tllI40UyFj4duURl4gq5XbcktUuSrIaLsAgbZcvZQtuOzDG7bRHO524aLXf2U5usPVMb 8QjkTR9w7OP/LxV4zZcbFxbhMpx6kyVUQ+F634zjEXFVj6zkYde6WOug6N8nko5qigQZ AxvQ== 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 y123-v6si3562631pfc.302.2018.09.13.00.39.24; Thu, 13 Sep 2018 00:39:40 -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 S1727685AbeIMMrW (ORCPT + 99 others); Thu, 13 Sep 2018 08:47:22 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:11699 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726680AbeIMMrW (ORCPT ); Thu, 13 Sep 2018 08:47:22 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 1F3D8514BD132; Thu, 13 Sep 2018 15:39:04 +0800 (CST) Received: from [127.0.0.1] (10.177.29.68) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.399.0; Thu, 13 Sep 2018 15:39:03 +0800 Message-ID: <5B9A1416.7010405@huawei.com> Date: Thu, 13 Sep 2018 15:39:02 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: Benjamin Tissoires CC: Jiri Kosina , open list: HID CORE LAYER , lkml , ; Illegal-Object: Syntax error in CC: address found on vger.kernel.org: CC: ; ^-missing semicolon to end mail group, extraneous tokens in mailbox, missing end of mailbox Subject: Re: [PATCH] HID: logitech: fix a used uninitialized GCC warning References: <1536810739-27342-1-git-send-email-zhongjiang@huawei.com> In-Reply-To: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.177.29.68] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/9/13 15:01, Benjamin Tissoires wrote: > On Thu, Sep 13, 2018 at 6:04 AM zhong jiang wrote: >> Fix the following compile warning: >> >> drivers/hid/hid-logitech-hidpp.c: In function ‘hi_res_scroll_enable’: >> drivers/hid/hid-logitech-hidpp.c:2714:54: warning: ‘multiplier’ may be used uninitialized in this function [-Wmaybe-uninitialized] >> hidpp->vertical_wheel_counter.resolution_multiplier = multiplier; >> >> Signed-off-by: zhong jiang >> --- >> drivers/hid/hid-logitech-hidpp.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c >> index 5f0c080..83c43dd 100644 >> --- a/drivers/hid/hid-logitech-hidpp.c >> +++ b/drivers/hid/hid-logitech-hidpp.c >> @@ -2696,7 +2696,7 @@ static int hi_res_scroll_look_up_microns(__u32 product_id) >> static int hi_res_scroll_enable(struct hidpp_device *hidpp) >> { >> int ret; >> - u8 multiplier; >> + u8 uninitialized_var(multiplier); > I think your patch is correct (multiplier will be set given the code > path), but IMO, it feels terribly wrong to explicitly remove this > warning this way. The problem is that if someone else adds a new piece > of code, we might miss the fact that multiplier is not set and we > might show garbage in the hid_info call. Make sense. > > Why don't you initialize the value to 8 as in the 'else' statement and > remove the now duplicated assignement in this else statement? Will do in v2. Thank you for your suggestion. Thanks, zhong jiang > Cheers, > Benjamin > >> if (hidpp->quirks & HIDPP_QUIRK_HI_RES_SCROLL_X2121) { >> ret = hidpp_hrw_set_wheel_mode(hidpp, false, true, false); >> -- >> 1.7.12.4 >> > . >