Re: [PATCH 3/11] Add MIPS_MAX_REGISTER_SIZE (4/4)

Maciej W. Rozycki
2017-06-12T14:29:20Z

On Fri, 9 Jun 2017, Pedro Alves wrote:

> > Hardcoding things, and especially with literals, causes a maintenance
> > pain when things change. Bad code elsewhere is not an excuse; besides,
> > the other places where `8' is hardcoded are not (buffer) limits, but just
> > handle specific register sizes, which are not going to change, and which
> > are a completely different matter.
>
> Perhaps you won't be surprised to learn that I subscribe to the same general
> principles. However, I believe that this isn't, in fact, a completely
> different matter, because the buffer in question is used to hold the
> contents of a structure's address, to either put in a general register,
> or in a stack slot, and those (addresses and general registers), unlike FPRs,
> aren't expected to grow for a given architecture.

Well, apart from being a software bug a buffer overflow is a potential
security concern, while an unhandled particular object kind is only a bug.

> > So if you find `alloca' unacceptable,
> > then the limit has to be a macro, and an assertion check is also due (as
> > already proposed), preferably using `sizeof', so that a future change does
> > not break it by accident.
>
> I think a patch like the below is likely to clarify things.
> (Builds, but is otherwise untested).

LGTM; fairly mechanical. Thanks!

Maciej