mod_timer is supposed to return 1 if the modified timer was pending, which
is exactly what callout_reset does so return this value directly.
The only not handled case is when callout_reset fails, for now returns 0 as if the timer
wasn't modified.
del_timer_sync returns int so add a function and handle that.
Details
- Reviewers
• hselasky emaste - Commits
- rS361452: linuxkpi: Fix mod_timer and del_timer_sync
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
sys/compat/linuxkpi/common/include/linux/timer.h | ||
---|---|---|
86–87 | This is wrong. callout_drain() is not the same like callout_stop() as used by del_timer(). Please read the callout implementation carefully. | |
sys/compat/linuxkpi/common/src/linux_compat.c | ||
1912 | Please read the callout_reset() code that you return exactly what you want! |
sys/compat/linuxkpi/common/src/linux_compat.c | ||
---|---|---|
1912 | From what I know callout functions can return 1,0,-1. Are you sure callout reset only returns 1/0 ? |
sys/compat/linuxkpi/common/src/linux_compat.c | ||
---|---|---|
1912 | Oh mhm, right, I guess I should just ignore <0 like we do now. |
sys/compat/linuxkpi/common/src/linux_compat.c | ||
---|---|---|
1908 | Callout reset never fails. Please remove or update this comment. Either it: MPASS(ret == 0 || ret == 1); return (ret == 1); |
sys/compat/linuxkpi/common/src/linux_compat.c | ||
---|---|---|
1908 | So my original code was right ? |
sys/compat/linuxkpi/common/src/linux_compat.c | ||
---|---|---|
1908 | Yes, looks like, except for only testing ret == 1. Add an assert for the sake of future changes in callout APIs. |
Beware that older versions of FreeBSD behave different w.r.t the return values from FreeBSD callout APIs. Be careful when MFC-ing to 11 and older.