[PATCH-RFC 2/5] nvme: tcp: split controller bringup handling

Christoph Hellwig hch at lst.de
Mon Jun 3 21:23:03 PDT 2024


On Mon, Jun 03, 2024 at 08:44:55PM -0600, Keith Busch wrote:
> > > +       ctrl = nvme_tcp_alloc_ctrl(dev, opts);
> > > +       if (IS_ERR(ctrl))
> > > +               return (struct nvme_ctrl *)ctrl;
> > 
> > This cast doesn't look right, as struct nvme_tcp_ctrl doesn't start
> > with a struct nvme_ctrl field. Looks like this should be &ctrl->ctrl
> > to match the current implementation of nvme_tcp_create_ctrl()?
> 
> We can't take an offset here because the "ctrl" is an ERR_PTR, and we
> want to preserve that for this function's return value. I could cast to
> a "void *" instead to suppress the compiler complaints if that helps get
> the intention across.

Or you could use the ERR_CAST helper, which does exactly that void *
cast, but actually documents why it is done :)



More information about the Linux-nvme mailing list