-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cpu/cortexm_common: irq_enable returns the current state of interrupts (not previous) #10076
Comments
I think, just applying pure logic here, if it would be wrong we would have observed issues much sooner, since this is a very central function to most of RIOT's functionality, but I assigned @kaspar030 who has way more knowledge of the kernel, just to have a look. |
There's nothing wrong now, but I see some reasons to change irq_enable as @jcarrano proposed
We never met such case in our practice, but then again, why not?
|
Well, definitely, as is, the return value is kinda useless. We might be able to save an instruction or two by changing the function into returning void. Changing |
Actually, not returning the previous state is clearly not as the documentation of |
It's more like "it is wrong I'd wish we had observed issues much sooner". Never take correctness for granted.
Then it's a bug, but....
...this is one of those cases where fixing a bug breaks the API. Options:
|
2.2. would be viable, though ugly. Personally, I'd rather have the API look like we want it to and document the change. Not all API changes are equal, and this would lead to rather trivial changes. |
I doubt anyone is using the return value of |
That is why we can drop the return value.
We cannot not fix it, as it might break code that depends on the old behaviour, (however wrong it might be), without users noticing when compiling, thus leading to in-the-field bugs. |
How about updating the API to return No one is using the return value anyway:
Unused APIs (or unused features of APIs) tend to be untested and buggy. Alternatively, I could PR a test for the correct implementation of the API. |
@maribu: makes sense. That way any user will have a compilation failure if they try to use the value. That will force them to go over what they were doing (anyone using the return value is likely to have a bug). |
+1 |
I just checked the arches for behavior. The following do indeed return the IRQ state prior to enabling IRQs:
So, fixed :) |
Description
I'm opening an issue and not a PR because I'm not sure that this is a bug.
See
RIOT/cpu/cortexm_common/irq_arch.c
Line 38 in b4664a5
I would expect
irq_enable()
to return the state of the interrup mask previous to them being enabled. This is whatirq_disable()
does.Does this make sense? I searched the codebase and this function is used sparingly and the result is never used, so if it is a bug it is asymptomatic now.
The text was updated successfully, but these errors were encountered: