diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 8d6b28661ae6..64ba7e5a14e9 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -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 diff --git a/sys/include/tiny_strerror.h b/sys/include/tiny_strerror.h index 5c5fa80224fb..76225cb8a031 100644 --- a/sys/include/tiny_strerror.h +++ b/sys/include/tiny_strerror.h @@ -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. + * * @{ * * diff --git a/sys/tiny_strerror/tiny_strerror.c b/sys/tiny_strerror/tiny_strerror.c index 4c114d8eec98..ad129d935b25 100644 --- a/sys/tiny_strerror/tiny_strerror.c +++ b/sys/tiny_strerror/tiny_strerror.c @@ -18,6 +18,7 @@ */ #include +#include #include #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;