MCPcopy Create free account
hub / github.com/MariaDB/server / my_strerror

Function my_strerror

strings/my_vsnprintf.c:908–966  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

906*/
907
908const char* my_strerror(char *buf, size_t len, int nr)
909{
910 char *msg= NULL;
911
912 buf[0]= '\0'; /* failsafe */
913
914 if (nr <= 0)
915 {
916 strmake(buf, (nr == 0 ?
917 "Internal error/check (Not system error)" :
918 "Internal error < 0 (Not system error)"),
919 len-1);
920 return buf;
921 }
922
923 /*
924 These (handler-) error messages are shared by perror, as required
925 by the principle of least surprise.
926 */
927 if ((nr >= HA_ERR_FIRST) && (nr <= HA_ERR_LAST))
928 {
929 msg= (char *) handler_error_messages[nr - HA_ERR_FIRST];
930 strmake(buf, msg, len - 1);
931 }
932 else
933 {
934 /*
935 On Windows, do things the Windows way. On a system that supports both
936 the GNU and the XSI variant, use whichever was configured (GNU); if
937 this choice is not advertised, use the default (POSIX/XSI). Testing
938 for __GNUC__ is not sufficient to determine whether this choice exists.
939 */
940#if defined(_WIN32)
941 strerror_s(buf, len, nr);
942#elif ((defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE >= 200112L)) || \
943 (defined _XOPEN_SOURCE && (_XOPEN_SOURCE >= 600))) && \
944 ! defined _GNU_SOURCE
945 strerror_r(nr, buf, len); /* I can build with or without GNU */
946#elif defined(__GLIBC__) && defined (_GNU_SOURCE)
947 char *r= strerror_r(nr, buf, len);
948 if (r != buf) /* Want to help, GNU? */
949 strmake(buf, r, len - 1); /* Then don't. */
950#else
951 strerror_r(nr, buf, len);
952#endif
953
954#ifdef __APPLE__
955 delete_colon_char(buf);
956#endif
957 }
958
959 /*
960 strerror() return values are implementation-dependent, so let's
961 be pragmatic.
962 */
963 if (!buf[0])
964 strmake(buf, "unknown error", len - 1);
965 return buf;

Callers 12

process_argsFunction · 0.85
my_vsnprintf_exFunction · 0.85
open_mysql_upgrade_fileFunction · 0.85
input_cbFunction · 0.85
xtrabackup_prepare_funcFunction · 0.85
directory_existsFunction · 0.85
move_fileMethod · 0.85
copy_backFunction · 0.85
copyMethod · 0.85
local_initFunction · 0.85
local_openFunction · 0.85

Calls 2

strmakeFunction · 0.85
delete_colon_charFunction · 0.85

Tested by

no test coverage detected