Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5410988pxj; Wed, 26 May 2021 09:52:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3csjXB3divWwzZoVQTPP2s4kwEG0+s75elq1e7KIrI/tRdcPRsslze93Ar0R1MSOsPbtL X-Received: by 2002:a17:906:a245:: with SMTP id bi5mr35898877ejb.316.1622047946559; Wed, 26 May 2021 09:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622047946; cv=none; d=google.com; s=arc-20160816; b=DJERG4kdWt8SDCMvbU5FwUaIDF1EElUWrzmgq5Y1U0XT1VfPU9NsPDlCDmOL9XuMLL TMGQrL8+aXMEhUNORw0bNkwuZXnJNWZ6zDRhRqVAhr5aIAn1RRaR39C7eZPqRKdmuFj9 IpQP4e83WHhFlk3YFlkptYUfxzy36IcYtzTi3XRNoz4FhvivxyX2Hc8jmJfoevaFwiJ+ FcpvuNFZ9WbdsUFlvyOGPayne4nc8fNqg/igA3nQu63U7gOopdvgsGTCRQlu7DjNGrIj vYRIwRm7lPeSlHOECqm71OZ4SMGOuvPv9Z7KIDEtpxwNdtENf5UdpE83JIDnIeWm/vPO 70xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:message-id:in-reply-to:subject:cc:to:from :date:dkim-signature; bh=aq1xs2YInyS0g06P2V3NTVnGJUu2RtgFkv9etHyvBhc=; b=zUpgCAT0i71Kg81oW+jRHYUfionJxW4qPd21y2L3Zl5btuLE9IDnNXuNTkfx6l+2GD Ku7+9QqXm4qbgGztHg6qqzCQAw6fgJzWPHVI+WWqZw4lRdTZiJB8uov89ACZQVb7d/IH nII0JJvaPQggGeZTIwi4XzC7AY1QNm7IFdlKuONXBJ8N84vlDOHNweV7V+eHdEQEV8B2 GAqH53XSIUZ82gEyatf3xl71k9nsdGIHGcVmv4UVCTulOcjzQ8Dx8uMPdkfbli5eaLOQ MRi+Gc9ZaO1kCkwlY5IRFvX1Iyska54aS+J+56xsmnYJVtUmk1Ku/k+2fjX1XaSQon8F Bv+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bGJcvcuj; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt11si4323644ejc.499.2021.05.26.09.52.03; Wed, 26 May 2021 09:52:26 -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=@kernel.org header.s=k20201202 header.b=bGJcvcuj; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234075AbhEZKlR (ORCPT + 99 others); Wed, 26 May 2021 06:41:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:52634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbhEZKlF (ORCPT ); Wed, 26 May 2021 06:41:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1B089613D3; Wed, 26 May 2021 10:39:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1622025574; bh=XkkR+3D/FW9VYxBOYTi3kuPLSQb/fFmFtNWeOGh98uU=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=bGJcvcujacwa2IPyL5izJYMIWtVxwBpUeou1i8mqK/XXq7Y52M3LW71d+rogG8ZXi nSzo3U58Io9VJ/eYtQ/JE/lNguf+UXD8UeG3/uX96fMFlBbR2zw/HtlkPZ6scJIpKo 0M/u6PGuxw4QwVAlqYPItzDwjmR9zuC2lBxBPv/nC3kq/v8tWaVtXLkifJOhbZ1z0P O5FY0RiH8W8zgaKiXe91N7cc6SAhF5tOJMQaFZeuNNtfit8xP92bXGbwzBL+zcIkdv Nj4dYAoWfCsFmqdN4WZTTklN2IhX5ZV2m2mXDxEct3Rck4NcJns7uiHoapcrIDO1PN genHFjPxf2rhQ== Date: Wed, 26 May 2021 12:39:31 +0200 (CEST) From: Jiri Kosina To: =?ISO-8859-15?Q?Filipe_La=EDns?= cc: trix@redhat.com, benjamin.tissoires@redhat.com, pedro@pedrovanzella.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] HID: logitech-hidpp: initialize level variable In-Reply-To: Message-ID: References: <20210507191819.71092-1-trix@redhat.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 16 May 2021, Filipe Laíns wrote: > > Static analysis reports this representative problem > > > > hid-logitech-hidpp.c:1356:23: warning: Assigned value is > >   garbage or undefined > >         hidpp->battery.level = level; > >                              ^ ~~~~~ > > > > In some cases, 'level' is never set in hidpp20_battery_map_status_voltage() > > Since level is not available on all hw, initialize level to unknown. > > > > Fixes: be281368f297 ("hid-logitech-hidpp: read battery voltage from newer > > devices") > > Signed-off-by: Tom Rix > > --- > >  drivers/hid/hid-logitech-hidpp.c | 1 + > >  1 file changed, 1 insertion(+) > > > > diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech- > > hidpp.c > > index 69670ca7e1e1..61635e629469 100644 > > --- a/drivers/hid/hid-logitech-hidpp.c > > +++ b/drivers/hid/hid-logitech-hidpp.c > > @@ -1265,6 +1265,7 @@ static int hidpp20_battery_map_status_voltage(u8 > > data[3], int *voltage, > >         int status; > >   > >         long flags = (long) data[2]; > > +       *level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN; > >   > >         if (flags & 0x80) > >                 switch (flags & 0x07) { > > Hi Tom, > > Taking a look at how this function is used, it does make sense to initialize the > level, thank you :) > > Reviewed-by: Filipe Laíns Applied, thanks. -- Jiri Kosina SUSE Labs