patacongo commented on code in PR #9848: URL: https://github.com/apache/nuttx/pull/9848#discussion_r1267507292
########## sched/signal/sig_nanosleep.c: ########## @@ -261,6 +262,11 @@ int clock_nanosleep(clockid_t clockid, int flags, { int ret; + if (clockid < CLOCK_REALTIME || clockid > CLOCK_BOOTTIME) + { + return EINVAL; + } Review Comment: > @xiaoxiang781216 @patacongo do you know what should have more "power" here, cancelation point or invalid parameter check? In other words, should these lines be placed here or after `enter_cancellation_point();`? Or in other words, should `clock_nanosleep()` call with invalid `clockid` be equivalent to `pthread_testcancel` or not? enter_cancellation_point() catches the case where the thread is canceled prior to calling the cancellation point function. I would think that returning ECANCEL would be more important to return in that case. Otherwise the thread may not exit until the next time a cancellation point function is called. Hmmm... the only problem that I see is that enter_cancellation_point() increments cpcount. Returning without calling leave_cancellation_point() will leave cpcount set meaning that we are still in a (possibley nested) cancellation point. That would need to be fixed up somewhere otherwise, moving the EINVAL return after enter_critical_secction() would mess up the cancellation point logic. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org