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

Marian Buschsieweke notifications at github.com
Fri Feb 8 19:22:23 CET 2019

maribu commented on this pull request.

Good idea to guard against this. I think you can mark the state_to_string function as `static`, so that the compiler can optimize.

Feel free to squash right away.

> @@ -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)

Please add `static`

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/20190208/e6a28b91/attachment.html>

More information about the notifications mailing list