Re: [PATCH v2 30/30] misc: cxl: flash: Remove unused pointer

From: Lee Jones
Date: Wed Jul 01 2020 - 09:31:30 EST


On Wed, 01 Jul 2020, Greg KH wrote:

> On Wed, Jul 01, 2020 at 09:31:18AM +0100, Lee Jones wrote:
> > The DRC index pointer us updated on an OPCODE_ADD, but never
> > actually read. Remove the used pointer and shift up OPCODE_ADD
> > to group with OPCODE_DELETE which also provides a noop.
> >
> > Fixes the following W=1 kernel build warning:
> >
> > drivers/misc/cxl/flash.c: In function âupdate_devicetreeâ:
> > drivers/misc/cxl/flash.c:178:16: warning: variable âdrc_indexâ set but not used [-Wunused-but-set-variable]
> > 178 | __be32 *data, drc_index, phandle;
> > | ^~~~~~~~~
> >
> > Cc: Frederic Barrat <fbarrat@xxxxxxxxxxxxx>
> > Cc: Andrew Donnellan <ajd@xxxxxxxxxxxxx>
> > Cc: linuxppc-dev@xxxxxxxxxxxxxxxx
> > Signed-off-by: Lee Jones <lee.jones@xxxxxxxxxx>
> > ---
> > drivers/misc/cxl/flash.c | 7 ++-----
> > 1 file changed, 2 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/misc/cxl/flash.c b/drivers/misc/cxl/flash.c
> > index cb9cca35a2263..24e3dfcc91a74 100644
> > --- a/drivers/misc/cxl/flash.c
> > +++ b/drivers/misc/cxl/flash.c
> > @@ -175,7 +175,7 @@ static int update_devicetree(struct cxl *adapter, s32 scope)
> > struct update_nodes_workarea *unwa;
> > u32 action, node_count;
> > int token, rc, i;
> > - __be32 *data, drc_index, phandle;
> > + __be32 *data, phandle;
> > char *buf;
> >
> > token = rtas_token("ibm,update-nodes");
> > @@ -206,15 +206,12 @@ static int update_devicetree(struct cxl *adapter, s32 scope)
> >
> > switch (action) {
> > case OPCODE_DELETE:
> > + case OPCODE_ADD:
> > /* nothing to do */
> > break;
> > case OPCODE_UPDATE:
> > update_node(phandle, scope);
> > break;
> > - case OPCODE_ADD:
> > - /* nothing to do, just move pointer */
> > - drc_index = *data++;
> > - break;
>
> I think this is not correct, as *data++ changes the value there, and so
> this changes the logic of the code.

Great spot.

Looks like I overlooked that the pointer itself is being incremented.

> Dropping this one from my queue.

Sounds good.

I'll fix-up and send this separately at a later date.

--
Lee Jones [æçæ]
Senior Technical Lead - Developer Services
Linaro.org â Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog