[riot-notifications] [RIOT-OS/RIOT] sys/ps: Improve robustness against string table errors. (#10977)

Kaspar Schleiser notifications at github.com
Mon Feb 11 11:51:27 CET 2019

kaspar030 commented on this pull request.

> @@ -42,6 +43,28 @@ static const char *state_names[] = {
     [STATUS_MBOX_BLOCKED] = "bl mbox",
+#define N_STATE_NAMES ((int)(sizeof(state_names)/sizeof(state_names[0])))
+#define UNKNOWN_STATE_NAME "unknown"
+ * Convert a thread state code to a human readable string.
+ *
+ * Use this function instead of a direct array lookup: if ever state_names
+ * and the actual states in tcb.h get out of sync, an invalid index can be
+ * generated, and direct access will cause a crash that this function is
+ * designed to prevent.
+ */
+const char *state_to_string(int state)

Hm. ```thread.h``` defines ```status``` as ```uint8_t```.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190211/6a965f97/attachment.html>

More information about the notifications mailing list