[PATCH] score: Help static analysis

2023-01-28 Thread Sebastian Huber
Add an assert to _Thread_Initialize_scheduler_and_wait_nodes() which may
help a static analyzer.  Use a do/while loop since we have at least one
scheduler.

Update #4832.
---
 cpukit/score/src/threadinitialize.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/cpukit/score/src/threadinitialize.c 
b/cpukit/score/src/threadinitialize.c
index 9b37206c6d..0d382853fd 100644
--- a/cpukit/score/src/threadinitialize.c
+++ b/cpukit/score/src/threadinitialize.c
@@ -139,7 +139,10 @@ static void _Thread_Initialize_scheduler_and_wait_nodes(
* The application configuration ensures that we have at least one scheduler
* configured.
*/
-  while ( scheduler_index < _Scheduler_Count ) {
+
+  _Assert ( _Scheduler_Count >= 1 );
+
+  do {
 Priority_Control priority;
 
 if ( scheduler == config->scheduler ) {
@@ -172,7 +175,7 @@ static void _Thread_Initialize_scheduler_and_wait_nodes(
   ( (uintptr_t) scheduler_node + _Scheduler_Node_size );
 ++scheduler;
 ++scheduler_index;
-  }
+  } while ( scheduler_index < _Scheduler_Count );
 
   /*
* The thread is initialized to use exactly one scheduler node which is
-- 
2.35.3

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


Re: [PATCH] score: Help static analysis

2023-01-28 Thread Joel Sherrill
This only impacts one file and the change is precise so the short log
should be more specific.

Otherwise ok. I hope this makes it happy.

On Sat, Jan 28, 2023, 3:59 AM Sebastian Huber <
sebastian.hu...@embedded-brains.de> wrote:

> Add an assert to _Thread_Initialize_scheduler_and_wait_nodes() which may
> help a static analyzer.  Use a do/while loop since we have at least one
> scheduler.
>
> Update #4832.
> ---
>  cpukit/score/src/threadinitialize.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/cpukit/score/src/threadinitialize.c
> b/cpukit/score/src/threadinitialize.c
> index 9b37206c6d..0d382853fd 100644
> --- a/cpukit/score/src/threadinitialize.c
> +++ b/cpukit/score/src/threadinitialize.c
> @@ -139,7 +139,10 @@ static void
> _Thread_Initialize_scheduler_and_wait_nodes(
> * The application configuration ensures that we have at least one
> scheduler
> * configured.
> */
> -  while ( scheduler_index < _Scheduler_Count ) {
> +
> +  _Assert ( _Scheduler_Count >= 1 );
> +
> +  do {
>  Priority_Control priority;
>
>  if ( scheduler == config->scheduler ) {
> @@ -172,7 +175,7 @@ static void
> _Thread_Initialize_scheduler_and_wait_nodes(
>( (uintptr_t) scheduler_node + _Scheduler_Node_size );
>  ++scheduler;
>  ++scheduler_index;
> -  }
> +  } while ( scheduler_index < _Scheduler_Count );
>
>/*
> * The thread is initialized to use exactly one scheduler node which is
> --
> 2.35.3
>
> ___
> devel mailing list
> devel@rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel