mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-07 06:43:00 +03:00
Change XPG-compliant strerror_r function to return error code.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2010-12-25 Ulrich Drepper <drepper@gmail.com>
|
||||||
|
|
||||||
|
[BZ #12204]
|
||||||
|
* string/xpg-strerror.c (__xpg_strerror_r): Return error code, not -1.
|
||||||
|
* sysdeps/mach/xpg-strerror.c (__xpg_strerror_r): Likewise.
|
||||||
|
|
||||||
2010-12-15 H.J. Lu <hongjiu.lu@intel.com>
|
2010-12-15 H.J. Lu <hongjiu.lu@intel.com>
|
||||||
|
|
||||||
* config.h.in (NO_CTORS_DTORS_SECTIONS): Define.
|
* config.h.in (NO_CTORS_DTORS_SECTIONS): Define.
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004
|
/* Copyright (C) 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2010
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
@@ -39,18 +39,13 @@ __xpg_strerror_r (int errnum, char *buf, size_t buflen)
|
|||||||
{
|
{
|
||||||
if (errnum < 0 || errnum >= _sys_nerr_internal
|
if (errnum < 0 || errnum >= _sys_nerr_internal
|
||||||
|| _sys_errlist_internal[errnum] == NULL)
|
|| _sys_errlist_internal[errnum] == NULL)
|
||||||
{
|
return EINVAL;
|
||||||
__set_errno (EINVAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
const char *estr = (const char *) _(_sys_errlist_internal[errnum]);
|
const char *estr = (const char *) _(_sys_errlist_internal[errnum]);
|
||||||
size_t estrlen = strlen (estr) + 1;
|
size_t estrlen = strlen (estr) + 1;
|
||||||
|
|
||||||
if (buflen < estrlen)
|
if (buflen < estrlen)
|
||||||
{
|
return ERANGE;
|
||||||
__set_errno (ERANGE);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy (buf, estr, estrlen);
|
memcpy (buf, estr, estrlen);
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004
|
/* Copyright (C) 1993, 1995, 1996, 1997, 1998, 2000, 2002, 2004, 2010
|
||||||
Free Software Foundation, Inc.
|
Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
@@ -53,30 +53,21 @@ __xpg_strerror_r (int errnum, char *buf, size_t buflen)
|
|||||||
code = err_get_code (errnum);
|
code = err_get_code (errnum);
|
||||||
|
|
||||||
if (system > err_max_system || ! __mach_error_systems[system].bad_sub)
|
if (system > err_max_system || ! __mach_error_systems[system].bad_sub)
|
||||||
{
|
return EINVAL;
|
||||||
__set_errno (EINVAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
es = &__mach_error_systems[system];
|
es = &__mach_error_systems[system];
|
||||||
|
|
||||||
if (sub >= es->max_sub)
|
if (sub >= es->max_sub)
|
||||||
estr = (const char *) es->bad_sub;
|
estr = (const char *) es->bad_sub;
|
||||||
else if (code >= es->subsystem[sub].max_code)
|
else if (code >= es->subsystem[sub].max_code)
|
||||||
{
|
return EINVAL;
|
||||||
__set_errno (EINVAL);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
estr = (const char *) _(es->subsystem[sub].codes[code]);
|
estr = (const char *) _(es->subsystem[sub].codes[code]);
|
||||||
|
|
||||||
size_t estrlen = strlen (estr) + 1;
|
size_t estrlen = strlen (estr) + 1;
|
||||||
|
|
||||||
if (buflen < estrlen)
|
if (buflen < estrlen)
|
||||||
{
|
return ERANGE;
|
||||||
__set_errno (ERANGE);
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy (buf, estr, estrlen);
|
memcpy (buf, estr, estrlen);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user