kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #22776
Re: [PATCH] Fix typing problems with GR_KB_* constants
Just ignore this patch.
On Jan 14, 2016 18:56, "Chris Pavlina" <pavlina.chris@xxxxxxxxx> wrote:
> Hi,
>
> We have a few minor typing issues with the GR_KB_* constants in
> include/common.h:
>
> - Type is a signed int32 on most platforms, yet we use 0x80000000
> (greater than INT_MAX) as a constant.
>
> This has caused people some trouble before:
> https://bugs.launchpad.net/kicad/+bug/1445606
>
> - In a few places, we're even using (-1) as a "special" value, which is
> a /bug/, not just me being picky about types - if one of these were to
> make it into a section that doesn't know to check for that (and
> there's nothing preventing this), it would come up as a valid key with
> all modifier flags, not a special value.
>
> I've made a few minor changes in the attached patch. Hopefully someone
> can review and commit this; I don't think it's particularly
> controversial, but still big enough that it should be seen.
>
> - Change these to 64-bit unsigned integers. Making them 64-bit gives
> plenty of space for flags, and making them unsigned resolves the
> bitmasking issue above.
>
> - Use a typedef EDA_KEY to simplify making similar changes in the
> future.
>
> - Add a positive constant (GR_KEY_INVALID) to represent what (-1) did
> before.
>
> - Just in case any code I missed is still trying to pass in (-1),
> continue handling this in release builds. Fail with a helpful message
> in debug builds.
>
>
Follow ups
References