Lora-net / LoRaMac-node

Reference implementation and documentation of a LoRa network node.
Other
1.89k stars 1.09k forks source link

Build warnings using GCC #457

Closed valerianrusu closed 6 years ago

valerianrusu commented 6 years ago

While building LoRaMac using gnu_gcc_arm/bin/arm-none-eabi-gcc with option -Wall I got a lot of warnings. Would you please address these warnings so the build process is clean?

COMPILER OUTPUT: lib/loramac/src/mac/region/RegionEU868.c: In function 'RegionEU868GetPhyParam': lib/loramac/src/mac/region/RegionEU868.c:188:12: warning: function returns an aggregate [-Waggregate-return] PhyParam_t RegionEU868GetPhyParam( GetPhyParams_t getPhy ) ^ lib/loramac/src/mac/region/RegionEU868.c: In function 'RegionEU868AdrNext': lib/loramac/src/mac/region/RegionEU868.c:511:30: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionEU868GetPhyParam( &getPhy ); ^ lib/loramac/src/mac/region/RegionEU868.c: In function 'RegionEU868LinkAdrReq': lib/loramac/src/mac/region/RegionEU868.c:709:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionEU868GetPhyParam( &getPhy ); ^ lib/loramac/src/mac/region/Region.c: In function 'RegionGetPhyParam': lib/loramac/src/mac/region/Region.c:575:12: warning: function returns an aggregate [-Waggregate-return] PhyParam_t RegionGetPhyParam( LoRaMacRegion_t region, GetPhyParams_t getPhy ) ^ lib/loramac/src/mac/region/Region.c:298:65: warning: function call has aggregate value [-Waggregate-return]

define EU868_GET_PHY_PARAM( ) EU868_CASE { return RegionEU868GetPhyParam( getPhy ); }

                                                             ^

lib/loramac/src/mac/region/Region.c:585:9: note: in expansion of macro 'EU868_GET_PHY_PARAM' EU868_GET_PHY_PARAM( ); ^ lib/loramac/src/mac/LoRaMac.c: In function 'OnRadioRxDone': lib/loramac/src/mac/LoRaMac.c:862:104: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if( MAX( 0, ( int16_t )( ( int16_t )size - ( int16_t )LORA_MAC_FRMPAYLOAD_OVERHEAD ) ) > phyParam.Value ) ^ In file included from lib/loramac/src/mac/LoRaMac.c:31:0: lib/loramac/src/mac/LoRaMac.c: In function 'LoRaMacMcpsRequest': lib/eaclib/com/lwa_lorawanadapter/inc/utilities.h:63:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]

define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )

                           ^

lib/loramac/src/mac/LoRaMac.c:3372:16: note: in expansion of macro 'MAX' datarate = MAX( datarate, phyParam.Value ); ^ lib/eaclib/com/lwa_lorawanadapter/inc/utilities.h:63:49: warning: signed and unsigned type in conditional expression [-Wsign-compare]

define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )

                                             ^

lib/loramac/src/mac/LoRaMac.c:3372:16: note: in expansion of macro 'MAX' datarate = MAX( datarate, phyParam.Value ); ^ lib/loramac/src/mac/LoRaMac.c: In function 'OnRadioTxDone': lib/loramac/src/mac/LoRaMac.c:678:22: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c: In function 'OnRadioRxDone': lib/loramac/src/mac/LoRaMac.c:861:26: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:943:26: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c: In function 'OnMacStateCheckTimerEvent': lib/loramac/src/mac/LoRaMac.c:1348:30: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c: In function 'ValidatePayloadLength': lib/loramac/src/mac/LoRaMac.c:1584:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c: In function 'LoRaMacInitialization': lib/loramac/src/mac/LoRaMac.c:2427:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:2431:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:2435:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:2439:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:2443:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:2447:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:2451:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:2455:14: warning: function call has aggregate value [-Waggregate-return] phyParam = RegionGetPhyParam( LoRaMacRegion, &getPhy ); ^ lib/loramac/src/mac/LoRaMac.c:2459:14: warning: function call has aggregate value [-Waggregate-return]

Kamilcuk commented 6 years ago

Wh don't you just disable -Wagregate-return warning? From this stackoverflow post:

[...] we simply disable -Waggregate-return. It a completely anachronistic warning, since its 
motivation was to support backwards compatibility with C compilers that did not allow 
returning structures. Those compilers are long dead and are no longer of practical  
concern.
mluis1 commented 6 years ago

The provided examples don't generate any warnings when we compile them. Please note that by default the -Wall option is enabled on the provided examples.

saml21.cmake:

# Object build options
set(OBJECT_GEN_FLAGS "-Og -g -mthumb -g2 -fno-builtin -mcpu=cortex-m0plus -Wall  -ffunction-sections -fdata-sections -fomit-frame-pointer -mabi=aapcs -fno-unroll-loops -ffast-math -ftree-vectorize -mlong-calls")

stm32l0.cmake:

# Object build options
set(OBJECT_GEN_FLAGS "-Og -g -mthumb -g2 -fno-builtin -mcpu=cortex-m0plus -Wall  -ffunction-sections -fdata-sections -fomit-frame-pointer -mabi=aapcs -fno-unroll-loops -ffast-math -ftree-vectorize")

stm32l1.cmake:

# Object build options
set(OBJECT_GEN_FLAGS "-Og -g -mthumb -g2 -fno-builtin -mcpu=cortex-m3 -Wall  -ffunction-sections -fdata-sections -fomit-frame-pointer -mabi=aapcs -fno-unroll-loops -ffast-math -ftree-vectorize")