Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp322046imm; Thu, 13 Sep 2018 00:02:22 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYO1Rsw83YD2jriLyuvt8ta9wVI9VRu6/ZW6Pi/UjxYhiji3V+RgIkcZookOiEV3oz5ttAi X-Received: by 2002:a62:e511:: with SMTP id n17-v6mr5922298pff.210.1536822142623; Thu, 13 Sep 2018 00:02:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536822142; cv=none; d=google.com; s=arc-20160816; b=Uad//SOlKUAKXcdptwqdGINfUUSttE1Ze8WqRRRhD1xFWO07Gzl7PUF3XuxiP8utMw 5rBKWbMG4I3kNwcaMUUBBsAV0QryEyIhg7Gv8fQcqtQqV1+uMdRcfYEKjv7r/3VXerPP c12mgvzGWFbQwDdNySA0X0IbALEZU6yNveuxSw89nSJEtW6cUofl/XUhJ/UL/0xP+ubk ryboIiyCS+Vc2hVbl6WXgAVrhJsPpjCfZOwjC8Ah0LsF1tCpqJ+rNkd0lwkMdQxa6QPN /eULt0hUxnVarnfhqforhfQ0uJXVgdbfI6TeC78y4YrrYvaV7TobXGf9qoOMrwP1gqW2 2AeQ== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=/1T7vOZUG00MZkQ8TJ7dVHOpNz8Z1xU8f1M1SfijzUQ=; b=zHxrzu1aIXeHMgWN1XVlNKPzbeRDQ+73f0fOzHqEOXv1tyklYHJ7p0FFANhPRtBlK/ YnZLX619wvg7qg3EB1PEdZlQewO4CR9ac3pI9rPEGMNYqj7ccEanqShU0BmmxuV53ngZ TDDFhRHpAnVzNNK5+1YRYzohHgHKvQ8eDz6Rz4JgCDUcEnacyy5h5bFSXaedXnz6tj+p mUQK02+UzC1eJF0qRaiMttx575hSV6kOdOcbTUg9vHEFNBceemP/vuie3mpQexbeXzrD NQLdqSeSa8/M9BZsUK2vMOed0z1dSsKO3Bu28BTy5ab1Io84hgxFUVhrLFceBQ/QG3rV flzA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v8-v6si3443606pga.487.2018.09.13.00.02.07; Thu, 13 Sep 2018 00:02:22 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726945AbeIMMKJ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 13 Sep 2018 08:10:09 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:34903 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726741AbeIMMKJ (ORCPT ); Thu, 13 Sep 2018 08:10:09 -0400 Received: by mail-lf1-f67.google.com with SMTP id q13-v6so3874126lfc.2 for ; Thu, 13 Sep 2018 00:02:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=KRdWlk5uVYAEVUZwL4iHRm9XeMBrapaUYPwsyVAv6Po=; b=ScPXeCf1vtpiUpfJV8204nKYrJsYc/3ByqrVByXbbuNPZrQ5MphRfbMcqp+W7+kQO9 2Nq+qWOCXpDmoc/2JXoT5mfhQhfFzhFU4gg6Ng99vjy5uaDEQ94yEkXN3U7JJ/6dLpp0 fLp+tz2YEluxrEVFp84zujaJqLsOZv0kGWBmcMt86QYdBgSMtfHN9eqRhyMCoDD2Q2vk fWBy3VIVfU9mzMdynLZ1h9Goc6rXwA1F+HyQ+CEkBdoMoS8of8F1z62dyeJY56AWB7he JnVrbcato9x/PjxxVOQEhOAKVUZ59iOwuwSwRWQzXx5TBPAiJAr/uSvh2S2DQeRHUdMu QLHw== X-Gm-Message-State: APzg51B25bZX3kefGWu9DWasDfRJs0H8fJ+WVxvm423YCK5p3a5x/Yzf +LeJ1t7vwEwDsa8SRs9ezysN2ZNbpGbwFfTf0Encdg== X-Received: by 2002:a19:d808:: with SMTP id p8-v6mr3685382lfg.105.1536822119306; Thu, 13 Sep 2018 00:01:59 -0700 (PDT) MIME-Version: 1.0 References: <1536810739-27342-1-git-send-email-zhongjiang@huawei.com> In-Reply-To: <1536810739-27342-1-git-send-email-zhongjiang@huawei.com> From: Benjamin Tissoires Date: Thu, 13 Sep 2018 09:01:47 +0200 Message-ID: Subject: Re: [PATCH] HID: logitech: fix a used uninitialized GCC warning To: zhongjiang@huawei.com Cc: Jiri Kosina , "open list:HID CORE LAYER" , lkml Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Why don't you initialize the value to 8 as in the 'else' statement and remove the now duplicated assignement in this else statement? 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 >