mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/tiny_strerror: add tiny_strerror_minimal
This commit is contained in:
parent
07c04bc0e3
commit
8553c8ff55
@ -477,6 +477,7 @@ PSEUDOMODULES += suit_transport_%
|
||||
PSEUDOMODULES += suit_storage_%
|
||||
PSEUDOMODULES += sys_bus_%
|
||||
PSEUDOMODULES += tiny_strerror_as_strerror
|
||||
PSEUDOMODULES += tiny_strerror_minimal
|
||||
PSEUDOMODULES += vdd_lc_filter_%
|
||||
## @defgroup pseudomodule_vfs_auto_format vfs_auto_format
|
||||
## @brief Format mount points at startup unless they can be mounted
|
||||
|
@ -24,6 +24,13 @@
|
||||
* @note Using module `tiny_strerror_as_strerror` will replace all calls
|
||||
* to `strerror()` by calls to `tiny_strerror()`, which may safe
|
||||
* a bit of ROM.
|
||||
*
|
||||
* @note Using module `tiny_strerror_minimal` will just print the error
|
||||
* code value.
|
||||
* This will save ~1k of ROM, but won't provide much more information.
|
||||
*
|
||||
* @warning The module `tiny_strerror_minimal` is not thread-safe.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
*
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "kernel_defines.h"
|
||||
@ -112,6 +113,12 @@ const char *tiny_strerror(int errnum)
|
||||
const char *retval = "-unknown";
|
||||
unsigned offset = 1;
|
||||
|
||||
if (IS_USED(MODULE_TINY_STRERROR_MINIMAL)) {
|
||||
static char buf[4];
|
||||
snprintf(buf, sizeof(buf), "%d", errnum);
|
||||
return buf;
|
||||
}
|
||||
|
||||
if (errnum <= 0) {
|
||||
offset = 0;
|
||||
errnum = -errnum;
|
||||
|
Loading…
Reference in New Issue
Block a user