Fix gcc10 compiler warnings

- fix attribute format for MINGW in tinycbor/cbor.h
- add pragma to prevent "unaligned pointer" warning in cmddata.c. We know what we are doing there.
- whitespace fixes
This commit is contained in:
pwpiwi 2021-01-29 08:26:33 +01:00
commit 8ac5d5cba1
2 changed files with 59 additions and 52 deletions

View file

@ -1206,13 +1206,16 @@ int getSamples(int n, bool silent)
uint8_t bits_per_sample = 8; uint8_t bits_per_sample = 8;
//Old devices without this feature would send 0 at arg[0] //Old devices without this feature would send 0 at arg[0]
if(response.arg[0] > 0) if(response.arg[0] > 0) {
{ #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Waddress-of-packed-member"
sample_config *sc = (sample_config *) response.d.asBytes; sample_config *sc = (sample_config *) response.d.asBytes;
#pragma GCC diagnostic pop
if (!silent) PrintAndLog("Samples @ %d bits/smpl, decimation 1:%d ", sc->bits_per_sample if (!silent) PrintAndLog("Samples @ %d bits/smpl, decimation 1:%d ", sc->bits_per_sample
, sc->decimation); , sc->decimation);
bits_per_sample = sc->bits_per_sample; bits_per_sample = sc->bits_per_sample;
} }
if(bits_per_sample < 8) if(bits_per_sample < 8)
{ {
if (!silent) PrintAndLog("Unpacking..."); if (!silent) PrintAndLog("Unpacking...");

View file

@ -581,7 +581,11 @@ enum CborPrettyFlags {
typedef CborError (*CborStreamFunction)(void *token, const char *fmt, ...) typedef CborError (*CborStreamFunction)(void *token, const char *fmt, ...)
#ifdef __GNUC__ #ifdef __GNUC__
#if defined(__MINGW32__) || defined(__MINGW64__)
__attribute__((__format__(__MINGW_PRINTF_FORMAT, 2, 3)))
#else
__attribute__((__format__(printf, 2, 3))) __attribute__((__format__(printf, 2, 3)))
#endif
#endif #endif
; ;