1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

treewide: Cleanup access to internal variables

Replace direct accesses to sched_active_thread and sched_active_pid with
the helper functions thread_getpid() and thread_get_active(). This serves
two purposes:

1. It makes accidental writes to those variable from outside core less likely.
2. Casting off the volatile qualifier is now well contained to those two
   functions
This commit is contained in:
Marian Buschsieweke 2020-08-05 08:42:35 +02:00
parent b353733d83
commit 90177889b7
No known key found for this signature in database
GPG Key ID: 61F64C6599B1539F
5 changed files with 8 additions and 6 deletions

View File

@ -71,7 +71,7 @@ static int _init(netdev_t *netdev)
{
kw2xrf_t *dev = (kw2xrf_t *)netdev;
dev->thread = (thread_t *)thread_get(thread_getpid());
dev->thread = thread_get_active();
/* initialize SPI and GPIOs */
if (kw2xrf_init(dev, &_irq_handler)) {

View File

@ -86,7 +86,7 @@ static void kw41zrf_irq_handler(void *arg)
static int kw41zrf_netdev_init(netdev_t *netdev)
{
kw41zrf_t *dev = (kw41zrf_t *)netdev;
dev->thread = (thread_t *)thread_get(thread_getpid());
dev->thread = thread_get_active();
/* initialize hardware */
if (kw41zrf_init(dev, kw41zrf_irq_handler)) {

View File

@ -48,7 +48,8 @@ int main()
THREAD_CREATE_WOUT_YIELD,
threadA_func, NULL, "thread A");
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n", sched_active_pid);
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n",
thread_getpid());
printf("We'll test C++ class and methods here!\n");
cpp_class cpp_obj;
@ -83,7 +84,8 @@ void *threadA_func(void *)
int day = 13, month = 6, year = 2014;
int ret_day;
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n", sched_active_pid);
printf("******** Hello, you're in thread #%" PRIkernel_pid " ********\n",
thread_getpid());
printf("We'll test some C functions here!\n");
printf("\n-= hello function =-\n");

View File

@ -162,6 +162,6 @@ void lvgl_init(screen_dev_t *screen_dev)
void lvgl_wakeup(void)
{
thread_t *tcb = (thread_t *)sched_threads[_task_thread_pid];
thread_t *tcb = thread_get(_task_thread_pid);
thread_flags_set(tcb, LVGL_THREAD_FLAG);
}

View File

@ -93,7 +93,7 @@ static void _netif_init(gnrc_netif_t *netif)
gnrc_netif_default_init(netif);
/* save the threads context pointer, so we can set its flags */
_netif_thread = (thread_t *)thread_get(thread_getpid());
_netif_thread = thread_get_active();
#if IS_USED(MODULE_GNRC_NETIF_6LO)
/* we disable fragmentation for this device, as the L2CAP layer takes care