Skip to content

Commit 3f6c7c7

Browse files
committed
Fix compiler warning: comparison of unsigned expression
Fix #44 cores/arduino/stm32/PinNamesTypes.h:132:44: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits] #define STM_VALID_PINNAME(X) ((STM_PORT(X) >= FirstPort) && (STM_PORT(X) <= LastPort)) Signed-off-by: Frederic.Pillon <[email protected]>
1 parent ed710fe commit 3f6c7c7

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

cores/arduino/stm32/PinNamesTypes.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ typedef enum {
129129
#define STM_PORT(X) (((uint32_t)(X) >> 4) & 0xF)
130130
#define STM_PIN(X) ((uint32_t)(X) & 0xF)
131131
// Check PinName is valid: FirstPort <= PortName <= LastPort
132-
#define STM_VALID_PINNAME(X) ((STM_PORT(X) >= FirstPort) && (STM_PORT(X) <= LastPort))
132+
// As FirstPort is equal to 0 and STM_PORT cast as an unsigned
133+
// (STM_PORT(X) >= FirstPort) is always true
134+
//#define STM_VALID_PINNAME(X) ((STM_PORT(X) >= FirstPort) && (STM_PORT(X) <= LastPort))
135+
#define STM_VALID_PINNAME(X) (STM_PORT(X) <= LastPort)
133136

134137
#define STM_GPIO_PIN(X) ((uint16_t)(1<<STM_PIN(X)))
135138
/* Defines to be used by application */

0 commit comments

Comments
 (0)