Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2160846pxb; Mon, 12 Apr 2021 16:28:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAxOI87zMfip3XQMF5v0s3XlQG8BSPQfdn7As8lcAwsLDzJvLs71F/LplC50pd+TWS6Z2d X-Received: by 2002:a17:903:22c2:b029:e7:1f02:434c with SMTP id y2-20020a17090322c2b02900e71f02434cmr29498447plg.73.1618270111897; Mon, 12 Apr 2021 16:28:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618270111; cv=none; d=google.com; s=arc-20160816; b=g6sIIQ9IyYwxH8r39OjKfV1KwFqKwUlHmy9p3YfNG8mRzeciiosREG/Nt9YotspG/S ycf/gQLbGhwEiNULUX+gGNR3WXaDNr8LKPh+TKvYdXolWOZAeIDXOHJ0lOL2U0LKNxZq FuLIkOwQI0v7XEMGbOxsUn3PKofIOggAZFHHSo0kvA5fI3pmP610hZzCvTvMx8SD10MN T4Akdbg9E8LgpHauIUloHoQQOUUIaOEtObCaDhfiEmqBemMuQJ0rdGV7iidlRUZ+aJAM P1la7OBG2tETGBWuyd3aphlto/upH9hV6rTj9pe/rPtT0VDEN80GCYXnSOZjCMXKpzSp gTJw== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=Vhxp8luQc/koYEfNrbTJMEEtJlp1Rn3CdIs23IGb7lA=; b=j9x4LmNc0xpqBpWeNCg+xN1UTSuYEn8fPahqcSqwriDTni9xHtT6C5u9ild1SNIvIy JODFvNg/uAwKGtzB20t2OOuc6RPJ06SNXIns6295jeBwZLBqy7o7rDG4lmdIMeh5JO+9 II5jxghN4Av1tbH3/PukAmM/74qtQMNdlCOdJEOOa/2tVJOmeuq/IsptTZLBIVyGs6Pk CzCVLxNsAJdKxv0j+yiCOW37HORqOtgKRAeCZ5M2JVwejmcI+sMsGZNrm0Sa9VcpO221 E3SOErbi+W4sq62n74floRe1XwGQrikrsmDEBTgEoQh9MmKf3WAWIareHJiQTiTBpvD7 3YHA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c16si15977907plg.135.2021.04.12.16.28.19; Mon, 12 Apr 2021 16:28:31 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238740AbhDLKW3 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 12 Apr 2021 06:22:29 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:2834 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239008AbhDLKW0 (ORCPT ); Mon, 12 Apr 2021 06:22:26 -0400 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FJl3M1h5sz688RF; Mon, 12 Apr 2021 18:14:55 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 12 Apr 2021 12:22:06 +0200 Received: from localhost (10.47.93.73) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Mon, 12 Apr 2021 11:22:05 +0100 Date: Mon, 12 Apr 2021 11:20:39 +0100 From: Jonathan Cameron To: Srinivas Pandruvada CC: Jonathan Cameron , Jiapeng Chong , , , , , Subject: Re: [PATCH] HID: hid-sensor-custom: remove useless variable Message-ID: <20210412112039.00006821@Huawei.com> In-Reply-To: References: <1617952508-47150-1-git-send-email-jiapeng.chong@linux.alibaba.com> <4079bb49a9c0022603abeffcdaec32208f449e51.camel@linux.intel.com> <20210411145635.3c6b48d1@jic23-huawei> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.47.93.73] X-ClientProxiedBy: lhreml713-chm.china.huawei.com (10.201.108.64) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 11 Apr 2021 09:06:35 -0700 Srinivas Pandruvada wrote: > On Sun, 2021-04-11 at 14:56 +0100, Jonathan Cameron wrote: > > On Fri, 09 Apr 2021 11:19:12 -0700 > > Srinivas Pandruvada wrote: > > > > > On Fri, 2021-04-09 at 15:15 +0800, Jiapeng Chong wrote: > > > > Fix the following gcc warning: > > > > > > > > drivers/hid/hid-sensor-custom.c:400:7: warning: variable ‘ret’ > > > > set > > > > but > > > > not used [-Wunused-but-set-variable]. > > > > > > > > Reported-by: Abaci Robot > > > > Signed-off-by: Jiapeng Chong > > > Acked-by: Srinivas Pandruvada > > > Perhaps better to return ret if it is non zero? > > I can't immediately figure out if there is a reason we know that > > can't > > happen. > Only time it can fail when there is no report descriptor or the field > index is >= report->maxfield. > But since the attribute is registered from the report descriptor and > index, this can't happen. > But we can enhance sensor_hub_set_feature() to fail when > hid_set_field() fails. There is one case where field->logical_minimum > < 0 and value is out of range. I'll go with what you think. Apply as is, or handle the return value because we might at some later date return an error that can actually happen from here? Jonathan > > Thanks, > Srinivas > > > > > > Jonathan > > > > > > --- > > > > drivers/hid/hid-sensor-custom.c | 5 ++--- > > > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/drivers/hid/hid-sensor-custom.c b/drivers/hid/hid- > > > > sensor-custom.c > > > > index 2628bc5..e430673 100644 > > > > --- a/drivers/hid/hid-sensor-custom.c > > > > +++ b/drivers/hid/hid-sensor-custom.c > > > > @@ -397,15 +397,14 @@ static ssize_t store_value(struct device > > > > *dev, > > > > struct device_attribute *attr, > > > > > > > > if (!strncmp(name, "value", strlen("value"))) { > > > > u32 report_id; > > > > - int ret; > > > > > > > > if (kstrtoint(buf, 0, &value) != 0) > > > > return -EINVAL; > > > > > > > > report_id = sensor_inst->fields[field_index].attribute. > > > > report_ > > > > id; > > > > - ret = sensor_hub_set_feature(sensor_inst->hsdev, > > > > report_id, > > > > - index, sizeof(value), > > > > &value); > > > > + sensor_hub_set_feature(sensor_inst->hsdev, report_id, > > > > index, > > > > + sizeof(value), &value); > > > > } else > > > > return -EINVAL; > > > > >