1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00

Refactor several debug routines.

To simplify additions of debug routines we replace a custom function
implementation by a simple call.
This commit is contained in:
Ondřej Bílka
2013-12-04 02:02:25 +01:00
parent 6905a19f7a
commit d674f0ef38
7 changed files with 16 additions and 288 deletions

View File

@@ -26,63 +26,8 @@ __strncpy_chk (s1, s2, n, s1len)
size_t n;
size_t s1len;
{
char c;
char *s = s1;
if (__builtin_expect (s1len < n, 0))
__chk_fail ();
--s1;
if (n >= 4)
{
size_t n4 = n >> 2;
for (;;)
{
c = *s2++;
*++s1 = c;
if (c == '\0')
break;
c = *s2++;
*++s1 = c;
if (c == '\0')
break;
c = *s2++;
*++s1 = c;
if (c == '\0')
break;
c = *s2++;
*++s1 = c;
if (c == '\0')
break;
if (--n4 == 0)
goto last_chars;
}
n = n - (s1 - s) - 1;
if (n == 0)
return s;
goto zero_fill;
}
last_chars:
n &= 3;
if (n == 0)
return s;
do
{
c = *s2++;
*++s1 = c;
if (--n == 0)
return s;
}
while (c != '\0');
zero_fill:
do
*++s1 = '\0';
while (--n > 0);
return s;
return strncpy (s1, s2, n);
}