<p><b>@kaspar030</b> requested changes on this pull request.</p>

<p>seeing that the thread status names are plain integers 0..something, maybe it would make sense to change them from define to enum, with STATES_NUMOF as last. the names array could have it's sized pinned with that. maybe the compiler would even warn if an enum out of range is used.</p>
<p>I also don't like differing behaviour dependent on whether we're building with develhelp.</p><hr>

<p>In <a href="https://github.com/RIOT-OS/RIOT/pull/10977#discussion_r255295303">sys/ps/ps.c</a>:</p>
<pre style='color:#555'>> @@ -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])))
</pre>
<p>please use STATE_NAMES_NUMOF.</p>

<hr>

<p>In <a href="https://github.com/RIOT-OS/RIOT/pull/10977#discussion_r255295318">sys/ps/ps.c</a>:</p>
<pre style='color:#555'>> @@ -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"
</pre>
<p>STATE_NAME_UNKNOWN?</p>

<hr>

<p>In <a href="https://github.com/RIOT-OS/RIOT/pull/10977#discussion_r255295348">sys/ps/ps.c</a>:</p>
<pre style='color:#555'>> @@ -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)
</pre>
<p>why int?</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/RIOT-OS/RIOT/pull/10977#pullrequestreview-201859347">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AEn7YIB1Zc-3FXcsD2Q4gukB0JuvNXj9ks5vLqqxgaJpZM4awvIF">mute the thread</a>.<img src="https://github.com/notifications/beacon/AEn7YCINoJ8MhohmOEcE6sKHx6LiPlR4ks5vLqqxgaJpZM4awvIF.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/RIOT-OS/RIOT","title":"RIOT-OS/RIOT","subtitle":"GitHub repository","main_image_url":"https://github.githubassets.com/images/email/message_cards/header.png","avatar_image_url":"https://github.githubassets.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/RIOT-OS/RIOT"}},"updates":{"snippets":[{"icon":"PERSON","message":"@kaspar030 requested changes on #10977"}],"action":{"name":"View Pull Request","url":"https://github.com/RIOT-OS/RIOT/pull/10977#pullrequestreview-201859347"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/RIOT-OS/RIOT/pull/10977#pullrequestreview-201859347",
"url": "https://github.com/RIOT-OS/RIOT/pull/10977#pullrequestreview-201859347",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>