MCPcopy Create free account
hub / github.com/apache/nuttx / strerror

Function strerror

libs/libc/string/lib_strerror.c:374–413  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

372 ****************************************************************************/
373
374FAR char *strerror(int errnum)
375{
376#ifdef CONFIG_LIBC_STRERROR_ERRNUM
377 static char s_err[STRERROR_BUFSIZE];
378#endif
379#ifdef CONFIG_LIBC_STRERROR
380 int ndxlow = 0;
381 int ndxhi = NERRNO_STRS - 1;
382 int ndxmid;
383
384 do
385 {
386 ndxmid = (ndxlow + ndxhi) >> 1;
387 if (errnum > g_errnomap[ndxmid].errnum)
388 {
389 ndxlow = ndxmid + 1;
390 }
391 else if (errnum < g_errnomap[ndxmid].errnum)
392 {
393 ndxhi = ndxmid - 1;
394 }
395 else
396 {
397 return g_errnomap[ndxmid].str;
398 }
399 }
400 while (ndxlow <= ndxhi);
401#endif
402#ifdef CONFIG_LIBC_STRERROR_ERRNUM
403 if (snprintf(s_err, sizeof(s_err), STRERROR_UNKNOWN " %d", errnum)
404 < sizeof(s_err))
405 {
406 return s_err;
407 }
408#elif !defined(CONFIG_LIBC_STRERROR)
409 UNUSED(errnum);
410#endif
411
412 return STRERROR_UNKNOWN;
413}

Callers 15

sim_gpiochip_optionFunction · 0.85
host_gpiochip_directionFunction · 0.85
really_readFunction · 0.85
really_writeFunction · 0.85
convert_pathFunction · 0.85
mainFunction · 0.85
open_proxyFunction · 0.85
open_stubFunction · 0.85
open_wrapperFunction · 0.85
mainFunction · 0.85
get_osFunction · 0.85

Calls 1

snprintfFunction · 0.50

Tested by

no test coverage detected