aboutsummaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2021-05-06 10:56:25 -0600
committerMartin Sebor <msebor@redhat.com>2021-05-06 11:01:05 -0600
commit26492c0a14966c32c43cd6ca1d0dca5e62c6cfef (patch)
tree1d2aceda8438c17113e02f86f2c8c31d58ac7f79 /misc
parent3f0808ef4c872afeade0e323c024ac59ec90fc2b (diff)
downloadglibc-26492c0a14966c32c43cd6ca1d0dca5e62c6cfef.zip
glibc-26492c0a14966c32c43cd6ca1d0dca5e62c6cfef.tar.gz
glibc-26492c0a14966c32c43cd6ca1d0dca5e62c6cfef.tar.bz2
Annotate additional APIs with GCC attribute access.
This change continues the improvements to compile-time out of bounds checking by decorating more APIs with either attribute access, or by explicitly providing the array bound in APIs such as tmpnam() that expect arrays of some minimum size as arguments. (The latter feature is new in GCC 11.) The only effects of the attribute and/or the array bound is to check and diagnose calls to the functions that fail to provide a sufficient number of elements, and the definitions of the functions that access elements outside the specified bounds. (There is no interplay with _FORTIFY_SOURCE here yet.) Tested with GCC 7 through 11 on x86_64-linux.
Diffstat (limited to 'misc')
-rw-r--r--misc/sys/uio.h37
1 files changed, 24 insertions, 13 deletions
diff --git a/misc/sys/uio.h b/misc/sys/uio.h
index 474527d..08dcb39 100644
--- a/misc/sys/uio.h
+++ b/misc/sys/uio.h
@@ -39,7 +39,7 @@ __BEGIN_DECLS
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count)
- __wur;
+ __wur __attr_access ((__read_only__, 2, 3));
/* Write data pointed by the buffers described by IOVEC, which
is a vector of COUNT 'struct iovec's, to file descriptor FD.
@@ -50,7 +50,7 @@ extern ssize_t readv (int __fd, const struct iovec *__iovec, int __count)
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count)
- __wur;
+ __wur __attr_access ((__read_only__, 2, 3));
#ifdef __USE_MISC
@@ -65,7 +65,8 @@ extern ssize_t writev (int __fd, const struct iovec *__iovec, int __count)
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count,
- __off_t __offset) __wur;
+ __off_t __offset)
+ __wur __attr_access ((__read_only__, 2, 3));
/* Write data pointed by the buffers described by IOVEC, which is a
vector of COUNT 'struct iovec's, to file descriptor FD at the given
@@ -77,16 +78,19 @@ extern ssize_t preadv (int __fd, const struct iovec *__iovec, int __count,
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t pwritev (int __fd, const struct iovec *__iovec, int __count,
- __off_t __offset) __wur;
+ __off_t __offset)
+ __wur __attr_access ((__read_only__, 2, 3));
# else
# ifdef __REDIRECT
extern ssize_t __REDIRECT (preadv, (int __fd, const struct iovec *__iovec,
int __count, __off64_t __offset),
- preadv64) __wur;
+ preadv64)
+ __wur __attr_access ((__read_only__, 2, 3));
extern ssize_t __REDIRECT (pwritev, (int __fd, const struct iovec *__iovec,
int __count, __off64_t __offset),
- pwritev64) __wur;
+ pwritev64)
+ __wur __attr_access ((__read_only__, 2, 3));
# else
# define preadv preadv64
# define pwritev pwritev64
@@ -104,7 +108,8 @@ extern ssize_t __REDIRECT (pwritev, (int __fd, const struct iovec *__iovec,
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t preadv64 (int __fd, const struct iovec *__iovec, int __count,
- __off64_t __offset) __wur;
+ __off64_t __offset)
+ __wur __attr_access ((__read_only__, 2, 3));
/* Write data pointed by the buffers described by IOVEC, which is a
vector of COUNT 'struct iovec's, to file descriptor FD at the given
@@ -116,7 +121,8 @@ extern ssize_t preadv64 (int __fd, const struct iovec *__iovec, int __count,
This function is a cancellation point and therefore not marked with
__THROW. */
extern ssize_t pwritev64 (int __fd, const struct iovec *__iovec, int __count,
- __off64_t __offset) __wur;
+ __off64_t __offset)
+ __wur __attr_access ((__read_only__, 2, 3));
# endif
#endif /* Use misc. */
@@ -125,7 +131,8 @@ extern ssize_t pwritev64 (int __fd, const struct iovec *__iovec, int __count,
# ifndef __USE_FILE_OFFSET64
/* Same as preadv but with an additional flag argumenti defined at uio.h. */
extern ssize_t preadv2 (int __fp, const struct iovec *__iovec, int __count,
- __off_t __offset, int ___flags) __wur;
+ __off_t __offset, int ___flags)
+ __wur __attr_access ((__read_only__, 2, 3));
/* Same as preadv but with an additional flag argument defined at uio.h. */
extern ssize_t pwritev2 (int __fd, const struct iovec *__iodev, int __count,
@@ -136,11 +143,13 @@ extern ssize_t pwritev2 (int __fd, const struct iovec *__iodev, int __count,
extern ssize_t __REDIRECT (pwritev2, (int __fd, const struct iovec *__iovec,
int __count, __off64_t __offset,
int __flags),
- pwritev64v2) __wur;
+ pwritev64v2)
+ __wur __attr_access ((__read_only__, 2, 3));
extern ssize_t __REDIRECT (preadv2, (int __fd, const struct iovec *__iovec,
int __count, __off64_t __offset,
int __flags),
- preadv64v2) __wur;
+ preadv64v2)
+ __wur __attr_access ((__read_only__, 2, 3));
# else
# define preadv2 preadv64v2
# define pwritev2 pwritev64v2
@@ -151,12 +160,14 @@ extern ssize_t __REDIRECT (preadv2, (int __fd, const struct iovec *__iovec,
/* Same as preadv but with an additional flag argumenti defined at uio.h. */
extern ssize_t preadv64v2 (int __fp, const struct iovec *__iovec,
int __count, __off64_t __offset,
- int ___flags) __wur;
+ int ___flags)
+ __wur __attr_access ((__read_only__, 2, 3));
/* Same as preadv but with an additional flag argument defined at uio.h. */
extern ssize_t pwritev64v2 (int __fd, const struct iovec *__iodev,
int __count, __off64_t __offset,
- int __flags) __wur;
+ int __flags)
+ __wur __attr_access ((__read_only__, 2, 3));
# endif
#endif /* Use GNU. */