mirror of
https://github.com/raspberrypi/pico-sdk.git
synced 2026-03-14 04:59:43 +01:00
Changed the parameter check to avoid tripping -Werror on spin locks (#307)
This prevents a comparison between a signed and an unsigned number which will create a warning tripping -Werror. Also added a check for the alignment of the spin lock structure
This commit is contained in:
parent
d974a3b0e9
commit
0911393fe2
1 changed files with 4 additions and 3 deletions
|
|
@ -204,9 +204,10 @@ inline static spin_lock_t *spin_lock_instance(uint lock_num) {
|
|||
* \return The Spinlock ID
|
||||
*/
|
||||
inline static uint spin_lock_get_num(spin_lock_t *lock) {
|
||||
int lock_num = lock - (spin_lock_t *) (SIO_BASE + SIO_SPINLOCK0_OFFSET);
|
||||
invalid_params_if(SYNC, lock_num < 0 || lock_num >= NUM_SPIN_LOCKS);
|
||||
return (uint) lock_num;
|
||||
invalid_params_if(SYNC, (uint) lock < SIO_BASE + SIO_SPINLOCK0_OFFSET ||
|
||||
(uint) lock >= NUM_SPIN_LOCKS * sizeof(spin_lock_t) + SIO_BASE + SIO_SPINLOCK0_OFFSET ||
|
||||
((uint) lock - SIO_BASE + SIO_SPINLOCK0_OFFSET) % sizeof(spin_lock_t) != 0);
|
||||
return (uint) (lock - (spin_lock_t *) (SIO_BASE + SIO_SPINLOCK0_OFFSET));
|
||||
}
|
||||
|
||||
/*! \brief Acquire a spin lock without disabling interrupts (hence unsafe)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue