Topic: WolfTpm build error (annoying warning as error - GCC)

Hello,

While compiling WolfTpm files on Ubuntu, gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0

I encounter this annoying warning as error. Can someone please help on how to get rid of this?

Build error: New warnings appeared:
../wolftpm/wolftpm/tpm2_types.h: In function ‘word64 ByteReverseWord64(word64)’:
../wolftpm/wolftpm/tpm2_types.h:655:66: warning: left shift count >= width of type [-Wshift-count-overflow]
     return (word64)((word64)ByteReverseWord32((word32)value)) << 32 |
                                                                  ^~
../wolftpm/wolftpm/tpm2_types.h:656:66: warning: right shift count >= width of type [-Wshift-count-overflow]
                     (word64)ByteReverseWord32((word32)(value  >> 32));


The build flag: CFLAGS = -Wshift-count-overflow
does not help and neither does
#pragma GCC diagnostic ignored "-Wshift-count-overflow"

The problem is in this function in tpm2_types.h, but I don't want to modify it.

static inline word64 ByteReverseWord64(word64 value)
{
    return (word64)((word64)ByteReverseWord32((word32)value)) << 32 |
                    (word64)ByteReverseWord32((word32)(value  >> 32));
}

Thanks,
Sam

Share

Re: WolfTpm build error (annoying warning as error - GCC)

Hi Sam,

I've put up the changes into PR: https://github.com/wolfSSL/wolfTPM/pull/231

The issue you reported is specific to the way you are building for 32-bit and not properly having word64 setup properly. The solution I provided simply makes use of the GCC builtin swap functions and avoids the 32 bit shifting.

Thanks,
David Garske, wolfSSL

Share

Re: WolfTpm build error (annoying warning as error - GCC)

Thank you David,

The solution (in your patch) works well.

Share