Re: Re: [PATCH v3] RDMA/siw: Fix 64/32bit pointer inconsistency

Jason Gunthorpe
2019-08-23T16:15:54Z

On Fri, Aug 23, 2019 at 12:13:54PM -0400, Doug Ledford wrote:
> On Fri, 2019-08-23 at 15:05 +0000, Bernard Metzler wrote:
> > > > Doug,
> > > > May I ask you to amend this patch in a way which would
> > > > just stop this monument of programming stupidity from
> > > > prolonging into the future, while of course recognizing
> > > > the impossibility of erasing it from the past?
> > > > Exchanging the %u with %d would help me regaining
> > > > some self-confidence ;)
> > >
> > > A
> > > q?a:b
> > >
> > > Expression has only a single type. There are some tricky rules on
> > > this, but since gcc does not complain on the %u it means
> > > 'q?(u32):(int)' is a (u32) and the -1 is implicitly casted.
> > >
> > > The better thing to write would have been U32_MAX instead of -1
> > >
> >
> > What I wanted to have though is an easy to spot invalid number
> > for the QP. This is why I wanted to have it a negative number
> > on the screen, which is obviously not nicely achievable. So,
> > yeah, U32_MAX is a better idea. It will not very often be a
> > valid QP ID...
>
> Given that this patch was still the top of my tree, I fixed this up.
> But, I think U32_MAX is wrong. It should be UINT_MAX (which is what I
> used). Otherwise it will give errors on s390 where an int is 31 bits
> (and anywhere else that might have a non-32 bit int).

qp_id returns u32 and the types of both sides of the : should be
identical

A non-32 bit int does not exist in Linux, everything would break.

Jason