[riot-notifications] [RIOT-OS/RIOT] core: refactor thread info (#15506)
Kaspar Schleiser
notifications at github.com
Thu Nov 26 10:13:26 CET 2020
@kaspar030 commented on this pull request.
> + [STATUS_RECEIVE_BLOCKED] = "bl rx",
+ [STATUS_SEND_BLOCKED] = "bl send",
+ [STATUS_REPLY_BLOCKED] = "bl reply",
+ [STATUS_FLAG_BLOCKED_ANY] = "bl anyfl",
+ [STATUS_FLAG_BLOCKED_ALL] = "bl allfl",
+ [STATUS_MBOX_BLOCKED] = "bl mbox",
+ [STATUS_COND_BLOCKED] = "bl cond",
+ [STATUS_RUNNING] = "running",
+ [STATUS_PENDING] = "pending",
+};
+
+#define STATE_NAME_UNKNOWN "unknown"
+
+const char *thread_state_to_string(thread_status_t state)
+{
+ const char *name = state_names[state] ? state_names[state] : NULL;
(this was copied from ps.c unchanged) no, state is an enum, and state_names an array that gets indexed.
But now that I'm taking a closer look this is essentially:
```
if state_names[state] == NULL:
name = NULL;
else:
name = state_names[state]
```
So the assignment could just be ```const char *name = state_names[name];```, right?
Or was that check meant for validity of "state"? In that case it must be ```const char *name = state < STATUS_NUMOF ? state_names[state] : NULL;```.
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/15506#discussion_r530877108
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201126/01841661/attachment.htm>
More information about the notifications
mailing list