Skip to content

Commit

Permalink
RTC: Fix pthread_t type to avoid overflow
Browse files Browse the repository at this point in the history
Change pthread_t type from int16_t to int by NuttX 11.0.0 update.
  • Loading branch information
SPRESENSE committed Feb 16, 2023
1 parent 03ef5c2 commit 3f21892
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ static void alarm_handler(int signo, FAR siginfo_t *info, FAR void *ucontext)
g_alarm = 1;
}

static int alarm_daemon(int argc, FAR char *argv[])
static void *alarm_daemon(void *arg)
{
struct sigaction act;
sigset_t set;
int ret;

(void)argc;
(void)argv;
(void)arg;

/* Make sure that the alarm signal is unmasked */

Expand Down Expand Up @@ -90,7 +89,7 @@ static int alarm_daemon(int argc, FAR char *argv[])
}
}

return -1;
return NULL;
}
#endif /* !SUBCORE */

Expand All @@ -115,7 +114,7 @@ void RtcClass::begin()
param.sched_priority = 120;
pthread_attr_setschedparam(&attr, &param);

pthread_create((pthread_t*)&_pid, &attr, (pthread_startroutine_t)alarm_daemon, NULL);
pthread_create(&_pid, &attr, (pthread_startroutine_t)alarm_daemon, NULL);
pthread_setname_np(_pid, "alarm_daemon");
assert (_pid > 0);
}
Expand All @@ -130,7 +129,7 @@ void RtcClass::end()
{
#ifndef SUBCORE
if (_pid > 0) {
pthread_cancel((pthread_t)_pid);
pthread_cancel(_pid);
_pid = -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class RtcClass

private:
int _fd;
int16_t _pid;
pthread_t _pid;

};

Expand Down

0 comments on commit 3f21892

Please sign in to comment.