kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #22773
Re: [PATCH] Fix typing problems with GR_KB_* constants
Hi
I tested this on Archlinux with clang 3.7.0 and gcc 5.3.0, seems to
work fine. Tested some different operations in pcbnew and saw not
abnormal behaviour.
2016-01-15 0:53 GMT+01:00 Chris Pavlina <pavlina.chris@xxxxxxxxx>:
> 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.
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help : https://help.launchpad.net/ListHelp
>
References