LCOV - code coverage report
Current view: top level - usr/include/x86_64-linux-gnu/bits - stdlib.h (source / functions) Hit Total Coverage
Test: coverage report for master 2b515b7d Lines: 4 5 80.0 %
Date: 2024-02-28 12:06:22 Functions: 0 0 -

          Line data    Source code
       1             : /* Checking macros for stdlib functions.
       2             :    Copyright (C) 2005-2022 Free Software Foundation, Inc.
       3             :    This file is part of the GNU C Library.
       4             : 
       5             :    The GNU C Library is free software; you can redistribute it and/or
       6             :    modify it under the terms of the GNU Lesser General Public
       7             :    License as published by the Free Software Foundation; either
       8             :    version 2.1 of the License, or (at your option) any later version.
       9             : 
      10             :    The GNU C Library is distributed in the hope that it will be useful,
      11             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      12             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      13             :    Lesser General Public License for more details.
      14             : 
      15             :    You should have received a copy of the GNU Lesser General Public
      16             :    License along with the GNU C Library; if not, see
      17             :    <https://www.gnu.org/licenses/>.  */
      18             : 
      19             : #ifndef _STDLIB_H
      20             : # error "Never include <bits/stdlib.h> directly; use <stdlib.h> instead."
      21             : #endif
      22             : 
      23             : extern char *__realpath_chk (const char *__restrict __name,
      24             :                              char *__restrict __resolved,
      25             :                              size_t __resolvedlen) __THROW __wur;
      26             : extern char *__REDIRECT_NTH (__realpath_alias,
      27             :                              (const char *__restrict __name,
      28             :                               char *__restrict __resolved), realpath) __wur;
      29             : extern char *__REDIRECT_NTH (__realpath_chk_warn,
      30             :                              (const char *__restrict __name,
      31             :                               char *__restrict __resolved,
      32             :                               size_t __resolvedlen), __realpath_chk) __wur
      33             :      __warnattr ("second argument of realpath must be either NULL or at "
      34             :                  "least PATH_MAX bytes long buffer");
      35             : 
      36             : __fortify_function __wur char *
      37       55823 : __NTH (realpath (const char *__restrict __name, char *__restrict __resolved))
      38             : {
      39       55823 :   size_t sz = __glibc_objsize (__resolved);
      40             : 
      41       55823 :   if (sz == (size_t) -1)
      42       55823 :     return __realpath_alias (__name, __resolved);
      43             : 
      44             : #if defined _LIBC_LIMITS_H_ && defined PATH_MAX
      45             :   if (__glibc_unsafe_len (PATH_MAX, sizeof (char), sz))
      46             :     return __realpath_chk_warn (__name, __resolved, sz);
      47             : #endif
      48           0 :   return __realpath_chk (__name, __resolved, sz);
      49             : }
      50             : 
      51             : 
      52             : extern int __ptsname_r_chk (int __fd, char *__buf, size_t __buflen,
      53             :                             size_t __nreal) __THROW __nonnull ((2))
      54             :     __attr_access ((__write_only__, 2, 3));
      55             : extern int __REDIRECT_NTH (__ptsname_r_alias, (int __fd, char *__buf,
      56             :                                                size_t __buflen), ptsname_r)
      57             :      __nonnull ((2)) __attr_access ((__write_only__, 2, 3));
      58             : extern int __REDIRECT_NTH (__ptsname_r_chk_warn,
      59             :                            (int __fd, char *__buf, size_t __buflen,
      60             :                             size_t __nreal), __ptsname_r_chk)
      61             :      __nonnull ((2)) __warnattr ("ptsname_r called with buflen bigger than "
      62             :                                  "size of buf");
      63             : 
      64             : __fortify_function int
      65             : __NTH (ptsname_r (int __fd, char *__buf, size_t __buflen))
      66             : {
      67             :   return __glibc_fortify (ptsname_r, __buflen, sizeof (char),
      68             :                           __glibc_objsize (__buf),
      69             :                           __fd, __buf, __buflen);
      70             : }
      71             : 
      72             : 
      73             : extern int __wctomb_chk (char *__s, wchar_t __wchar, size_t __buflen)
      74             :   __THROW __wur;
      75             : extern int __REDIRECT_NTH (__wctomb_alias, (char *__s, wchar_t __wchar),
      76             :                            wctomb) __wur;
      77             : 
      78             : __fortify_function __wur int
      79             : __NTH (wctomb (char *__s, wchar_t __wchar))
      80             : {
      81             :   /* We would have to include <limits.h> to get a definition of MB_LEN_MAX.
      82             :      But this would only disturb the namespace.  So we define our own
      83             :      version here.  */
      84             : #define __STDLIB_MB_LEN_MAX     16
      85             : #if defined MB_LEN_MAX && MB_LEN_MAX != __STDLIB_MB_LEN_MAX
      86             : # error "Assumed value of MB_LEN_MAX wrong"
      87             : #endif
      88             :   if (__glibc_objsize (__s) != (size_t) -1
      89             :       && __STDLIB_MB_LEN_MAX > __glibc_objsize (__s))
      90             :     return __wctomb_chk (__s, __wchar, __glibc_objsize (__s));
      91             :   return __wctomb_alias (__s, __wchar);
      92             : }
      93             : 
      94             : 
      95             : extern size_t __mbstowcs_chk (wchar_t *__restrict __dst,
      96             :                               const char *__restrict __src,
      97             :                               size_t __len, size_t __dstlen) __THROW
      98             :     __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
      99             : extern size_t __REDIRECT_NTH (__mbstowcs_alias,
     100             :                               (wchar_t *__restrict __dst,
     101             :                                const char *__restrict __src,
     102             :                                size_t __len), mbstowcs)
     103             :     __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
     104             : extern size_t __REDIRECT_NTH (__mbstowcs_chk_warn,
     105             :                               (wchar_t *__restrict __dst,
     106             :                                const char *__restrict __src,
     107             :                                size_t __len, size_t __dstlen), __mbstowcs_chk)
     108             :      __warnattr ("mbstowcs called with dst buffer smaller than len "
     109             :                  "* sizeof (wchar_t)");
     110             : 
     111             : __fortify_function size_t
     112             : __NTH (mbstowcs (wchar_t *__restrict __dst, const char *__restrict __src,
     113             :                  size_t __len))
     114             : {
     115             :   return __glibc_fortify_n (mbstowcs, __len, sizeof (wchar_t),
     116             :                             __glibc_objsize (__dst),
     117             :                             __dst, __src, __len);
     118             : }
     119             : 
     120             : 
     121             : extern size_t __wcstombs_chk (char *__restrict __dst,
     122             :                               const wchar_t *__restrict __src,
     123             :                               size_t __len, size_t __dstlen) __THROW
     124             :   __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
     125             : extern size_t __REDIRECT_NTH (__wcstombs_alias,
     126             :                               (char *__restrict __dst,
     127             :                                const wchar_t *__restrict __src,
     128             :                                size_t __len), wcstombs)
     129             :   __attr_access ((__write_only__, 1, 3)) __attr_access ((__read_only__, 2));
     130             : extern size_t __REDIRECT_NTH (__wcstombs_chk_warn,
     131             :                               (char *__restrict __dst,
     132             :                                const wchar_t *__restrict __src,
     133             :                                size_t __len, size_t __dstlen), __wcstombs_chk)
     134             :      __warnattr ("wcstombs called with dst buffer smaller than len");
     135             : 
     136             : __fortify_function size_t
     137             : __NTH (wcstombs (char *__restrict __dst, const wchar_t *__restrict __src,
     138             :                  size_t __len))
     139             : {
     140             :   return __glibc_fortify (wcstombs, __len, sizeof (char),
     141             :                           __glibc_objsize (__dst),
     142             :                           __dst, __src, __len);
     143             : }

Generated by: LCOV version 1.14