On Sun, 1 Nov 2026 at 15:41, Richard Henderson
<[email protected]> wrote:
>
> On 11/1/26 03:30, Peter Maydell wrote:
> > On Fri, 30 Oct 2026 at 13:18, Richard Henderson
> > <[email protected]> wrote:
> >>
> >> Rather than hard-code -1, or compare < 0, use something
> >> more descriptive.  This also allows more use of TCGReg.
> >>
> >> Reviewed-by: Matt Turner <[email protected]>
> >> Signed-off-by: Richard Henderson <[email protected]>
> >
> >>   typedef enum {
> >> +    TCG_REG_NONE = -1,
> >>       TCG_REG_EAX = 0,
> >>       TCG_REG_ECX,
> >>       TCG_REG_EDX,
> >
> > This has resulted in Coverity producing a set of new complaints
> > (CID 1689946, 1689949, 1689951, 1689952, 1689953, 1689954,
> > 1689955), because it now assumes that variables of type TCGReg
> > can be -1, and that therefore code like:
> >
> >                  TCGReg reg = order[i];
> >                  if (tcg_regset_test_reg(set, reg)) {
> > (from tcg_reg_alloc_pair(), but the others are similar)
> >
> > might be buggy, because it hands a TCGReg to tcg_regset_test_reg(),
> > which uses it as a shift count without checking for the -1
> > possibility (which would be UB if it happened).
> >
> > Should we just mark all these as false-positives, or is it
> > worth maybe having operations that work on a TCGReg but
> > don't expect TCG_REG_NONE add assertions against that ?
> Ug.  I didn't want to have to add that many assertions.
> Maybe I should revert the few places that require -1 to int.
> Maybe I should use something other than -1.
>
> Perhaps all false positives for now?  If I adjust anything later, it'll
> refresh itself anyway.

I've marked them as false positives for the moment.

Incidentally, s390x uses 0 for TCG_REG_NONE, but that seems
to be because the instruction set really does have "0 in
register field means no register" in some places.

-- PMM

Reply via email to