Re: [PATCH] nvme-tcp: fix signedness bug in nvme_tcp_init_connection()
From: Christoph Hellwig
Date: Wed Mar 05 2025 - 09:42:15 EST
On Wed, Mar 05, 2025 at 05:37:15PM +0300, Dan Carpenter wrote:
> > if (ret >= 0 && ret < sizeof(*icresp))
> > ret = -ECONNRESET;
> > if (ret < 0) {
> > ...
>
> Sure, I can do that.
>
> I don't love casts either. I normally have tried to write these as
> "if (ret < 0 || ret < sizeof(*icresp)) {" and people don't love that.
I can see why people don't like it as it's really counterintuitive.
These kinds of interfaces just suck given the type promotion rules
unfortunately.