gcc 4.3 compiler warning, possible off-by-one error?

Pavel Roskin proski
Wed Jun 4 09:55:24 PDT 2008

On Wed, 2008-06-04 at 19:01 +0300, Jouni Malinen wrote:

> The current code is actually correct from functional view point, i.e.,
> WPA_PUT_BE32 is supposed to "overflow" the 3-octet oui field and
> continue to the oui_type. In other words, your patch is not correct way
> of getting rid of the warning. One way to do this would be to change the
> oui to 4-octet field and remove oui_type, but that is not exactly
> correct either since OUI is 24 bits. The other option would be to not
> use WPA_{PUT,GET}_BE32 here, but that adds more complexity to the code.
> That could be hidden in the macro, but the binary size would still be a
> bit larger..

"struct" might help:

    struct oui {
        u8 oui_id[3];
        u8 oui_type;

When accessing 4 bytes, refer to (u32)oui, when writing 3 bytes, refer
to oui_id.  Maybe a union around this would be needed to suppress some
warnings, but I'll rather avoid it if possible.

Pavel Roskin

More information about the Hostap mailing list