Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3512514pxb; Mon, 1 Mar 2021 11:56:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6Uk+gl2uT5RLBWxkFRmYR0QYcPbiuHricrOUOn2W82CDEeYvd7tyfIP2xz3Lb75FdHYAE X-Received: by 2002:a17:907:94d4:: with SMTP id dn20mr17681114ejc.397.1614628600190; Mon, 01 Mar 2021 11:56:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614628600; cv=none; d=google.com; s=arc-20160816; b=DSO6nmqcMFH6FVFkrUtMOF4FoajhQTWn4WKXNMJxzZCWeugY36tshwNwEv3k2AgwdR m738m3ewaLKRWqabJPhRuT+Mq2eWHCl1ZmvLSCMGdTUCNPYP3nXqdOT/A5I8P/RdFq0o vgDjrkfvKtRTuegW10yK4J/4zhjIR0gTWBrwavqo9n7dA+bgJH5/sIJF3yIj1WpV5KrO JBlyIrmqA4NODv0pZyB3yuno9oQ9Km2nqMLe0PxDybMETgHSBc5QPU8ExMunl/QN4YiS camd8L1AtcQaGaouLNfOjeqeXQoxSGa45c8YHpJrUKiOLgG8K06bJ5ott4PVvZGGUI2x b49Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :mime-version:accept-language:in-reply-to:references:message-id:date :thread-index:thread-topic:subject:cc:to:from; bh=eT5KSwjD4tRKPFq+NW4RySrsMLouEIlXZpR3bnezoqQ=; b=hEbLwlGVu/gmelR8H+ygbabQGesRrwxA4g1rdKyabZoUzX2pyJTagkP7cvSer3kzUr 1F1lTDgY8R8m5cSgQ/7T6MlGkeG6+CtzF0JQKKG07EG5dngY4dV5T8dYNEOKZLIiuGk7 LP7smebt+zoYHOv6ThUz7F3+zUR61sh3mqiNwuTA+P+BsfczT8brD0sxLDsS7jxzdhTK +Yq7Um3abIPm6fQG0+5NPTJssfHjysomObWcn7gpgu9O99zPYvftyPcvtzRBBh4BkEyl jkrt2EiclzxbdxnnkJqPQjKKYweo9up95THuYMLOI73sY9MVL6qdnaUzuiiREz6IKQiQ HP9g== 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=aculab.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j7si12616302ejm.408.2021.03.01.11.56.10; Mon, 01 Mar 2021 11:56:40 -0800 (PST) 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=aculab.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242274AbhCATwz convert rfc822-to-8bit (ORCPT + 99 others); Mon, 1 Mar 2021 14:52:55 -0500 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.85.151]:45021 "EHLO eu-smtp-delivery-151.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235731AbhCAQ5A (ORCPT ); Mon, 1 Mar 2021 11:57:00 -0500 Received: from AcuMS.aculab.com (156.67.243.126 [156.67.243.126]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-60-ldJHFi9KOjKwpI4jjguaoQ-1; Mon, 01 Mar 2021 16:55:12 +0000 X-MC-Unique: ldJHFi9KOjKwpI4jjguaoQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) by AcuMS.aculab.com (fd9f:af1c:a25b:0:43c:695e:880f:8750) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Mon, 1 Mar 2021 16:55:09 +0000 Received: from AcuMS.Aculab.com ([fe80::43c:695e:880f:8750]) by AcuMS.aculab.com ([fe80::43c:695e:880f:8750%12]) with mapi id 15.00.1347.000; Mon, 1 Mar 2021 16:55:09 +0000 From: David Laight To: 'Konrad Rzeszutek Wilk' , "alison.schofield@intel.com" , "vishal.l.verma@intel.com" , "ira.weiny@intel.com" , "ben.widawsky@intel.com" , "dan.j.williams@intel.com" , "linux-cxl@vger.kernel.org" CC: "linux-kernel@vger.kernel.org" Subject: RE: [PATCH v2] cxl: Make loop variable be 'i' instead of 'j' Thread-Topic: [PATCH v2] cxl: Make loop variable be 'i' instead of 'j' Thread-Index: AQHXDITnpuSc/NuooE2Hlm/1gHtj5qpvXgLg Date: Mon, 1 Mar 2021 16:55:09 +0000 Message-ID: <9c4643b7200449ce8e6693e4bcaf24b6@AcuMS.aculab.com> References: <20210226211656.46359-1-konrad.wilk@oracle.com> In-Reply-To: <20210226211656.46359-1-konrad.wilk@oracle.com> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Konrad Rzeszutek Wilk > Sent: 26 February 2021 21:17 > > .. otherwise people spend extra cycles looking for the > inner loop and wondering 'why j'? > > This was an oversight when initial work was rebased > so let's fix it here. > > Signed-off-by: Konrad Rzeszutek Wilk > --- > v1: Initial posting > v2: Fix per Dan's request > --- > drivers/cxl/mem.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/cxl/mem.c b/drivers/cxl/mem.c > index 244cb7d89678..d43197a193ce 100644 > --- a/drivers/cxl/mem.c > +++ b/drivers/cxl/mem.c > @@ -698,7 +698,6 @@ static int cxl_query_cmd(struct cxl_memdev *cxlmd, > struct device *dev = &cxlmd->dev; > struct cxl_mem_command *cmd; > u32 n_commands; > - int j = 0; > > dev_dbg(dev, "Query IOCTL\n"); > > @@ -715,11 +714,12 @@ static int cxl_query_cmd(struct cxl_memdev *cxlmd, > */ > cxl_for_each_cmd(cmd) { > const struct cxl_command_info *info = &cmd->info; > + int i = 0; > > - if (copy_to_user(&q->commands[j++], info, sizeof(*info))) > + if (copy_to_user(&q->commands[i++], info, sizeof(*info))) > return -EFAULT; > > - if (j == n_commands) > + if (i == n_commands) > break; Did you test this? Looks badly broken to me. David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)