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
@ -204,9 +204,10 @@ inline static spin_lock_t *spin_lock_instance(uint lock_num) {
|
|||||||
* \return The Spinlock ID
|
* \return The Spinlock ID
|
||||||
*/
|
*/
|
||||||
inline static uint spin_lock_get_num(spin_lock_t *lock) {
|
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, (uint) lock < SIO_BASE + SIO_SPINLOCK0_OFFSET ||
|
||||||
invalid_params_if(SYNC, lock_num < 0 || lock_num >= NUM_SPIN_LOCKS);
|
(uint) lock >= NUM_SPIN_LOCKS * sizeof(spin_lock_t) + SIO_BASE + SIO_SPINLOCK0_OFFSET ||
|
||||||
return (uint) lock_num;
|
((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)
|
/*! \brief Acquire a spin lock without disabling interrupts (hence unsafe)
|
||||||
|
Loading…
Reference in New Issue
Block a user