Skip to content

Commit a719bbb

Browse files
committed
Update to latest rra-c-util upstream version
1 parent a915098 commit a719bbb

9 files changed

Lines changed: 64 additions & 44 deletions

File tree

include/inn/buffer.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
1717
*
1818
* Written by Russ Allbery <eagle@eyrie.org>
19-
* Copyright 2014-2015, 2022 Russ Allbery <eagle@eyrie.org>
19+
* Copyright 2014-2015, 2022, 2025 Russ Allbery <eagle@eyrie.org>
2020
* Copyright 2011-2012
2121
* The Board of Trustees of the Leland Stanford Junior University
2222
* Copyright 2004-2006 Internet Systems Consortium, Inc. ("ISC")
@@ -125,20 +125,23 @@ bool buffer_find_string(struct buffer *, const char *, size_t start,
125125
* error or after any successful read. Returns -1 on an error reading from
126126
* the file descriptor and sets errno.
127127
*/
128-
ssize_t buffer_read(struct buffer *, int fd) __attribute__((__nonnull__));
128+
ssize_t buffer_read(struct buffer *, int fd)
129+
__attribute__((__fd_arg_read__(2), __nonnull__));
129130

130131
/*
131132
* Read from a file descriptor into a buffer until end of file is reached.
132133
* Returns true on success and false (setting errno) on error.
133134
*/
134-
bool buffer_read_all(struct buffer *, int fd) __attribute__((__nonnull__));
135+
bool buffer_read_all(struct buffer *, int fd)
136+
__attribute__((__fd_arg_read__(2), __nonnull__));
135137

136138
/*
137139
* Read the contents of a file into a buffer. This should be used instead of
138140
* buffer_read_all when fstat can be called on the file descriptor. Returns
139141
* true on success and false (setting errno) on error.
140142
*/
141-
bool buffer_read_file(struct buffer *, int fd) __attribute__((__nonnull__));
143+
bool buffer_read_file(struct buffer *, int fd)
144+
__attribute__((__fd_arg_read__(2), __nonnull__));
142145

143146
END_DECLS
144147

include/inn/xwrite.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
66
*
77
* Written by Russ Allbery <eagle@eyrie.org>
8+
* Copyright 2025 Russ Allbery <eagle@eyrie.org>
89
* Copyright 2008, 2010, 2013
910
* The Board of Trustees of the Leland Stanford Junior University
1011
* Copyright 2004-2006 Internet Systems Consortium, Inc. ("ISC")
@@ -46,11 +47,11 @@ BEGIN_DECLS
4647
* writes and EINTR/EAGAIN errors.
4748
*/
4849
ssize_t xpwrite(int fd, const void *buffer, size_t size, off_t offset)
49-
__attribute__((__nonnull__));
50+
__attribute__((__fd_arg_write__(1), __nonnull__));
5051
ssize_t xwrite(int fd, const void *buffer, size_t size)
51-
__attribute__((__nonnull__));
52+
__attribute__((__fd_arg_write__(1), __nonnull__));
5253
ssize_t xwritev(int fd, const struct iovec *iov, int iovcnt)
53-
__attribute__((__nonnull__));
54+
__attribute__((__fd_arg_write__(1), __nonnull__));
5455

5556
END_DECLS
5657

include/portable/macros.h

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
66
*
77
* Written by Russ Allbery <eagle@eyrie.org>
8-
* Copyright 2015, 2022 Russ Allbery <eagle@eyrie.org>
8+
* Copyright 2015, 2022, 2025 Russ Allbery <eagle@eyrie.org>
99
* Copyright 2008, 2011-2012
1010
* The Board of Trustees of the Leland Stanford Junior University
1111
*
@@ -32,11 +32,7 @@
3232
#endif
3333

3434
/*
35-
* We use __alloc_size__, but it was only available in fairly recent versions
36-
* of GCC. Suppress warnings about the unknown attribute if GCC is too old.
37-
* We know that we're GCC at this point, so we can use the GCC variadic macro
38-
* extension, which will still work with versions of GCC too old to have C99
39-
* variadic macro support.
35+
* __alloc_size__ was introduced in GCC 4.3.
4036
*/
4137
#if !defined(__attribute__) && !defined(__alloc_size__)
4238
# if (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)) \
@@ -46,8 +42,20 @@
4642
#endif
4743

4844
/*
49-
* Suppress the argument to __malloc__ in Clang (not supported in at least
50-
* version 13) and GCC versions prior to 11.
45+
* __fd_arg__ and company were introduced in GCC 13 and is not supported in
46+
* Clang 19.
47+
*/
48+
#if !defined(__attribute__) && !defined(__fd_arg__)
49+
# if __GNUC__ < 13 && !defined(__clang__)
50+
# define __fd_arg__(arg) /* empty */
51+
# define __fd_arg_read__(arg) /* empty */
52+
# define __fd_arg_write__(arg) /* empty */
53+
# endif
54+
#endif
55+
56+
/*
57+
* Suppress the argument to __malloc__ in Clang and in GCC versions prior to
58+
* 11.
5159
*/
5260
#if !defined(__attribute__) && !defined(__malloc__)
5361
# if defined(__clang__) || __GNUC__ < 11
@@ -57,17 +65,17 @@
5765

5866
/*
5967
* LLVM and Clang pretend to be GCC but don't support all of the __attribute__
60-
* settings that GCC does. For them, suppress warnings about unknown
61-
* attributes on declarations. This unfortunately will affect the entire
68+
* settings that GCC does. For them, suppress warnings about unknown
69+
* attributes on declarations. This unfortunately will affect the entire
6270
* compilation context, but there's no push and pop available.
6371
*/
6472
#if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__))
6573
# pragma GCC diagnostic ignored "-Wattributes"
6674
#endif
6775

6876
/*
69-
* BEGIN_DECLS is used at the beginning of declarations so that C++
70-
* compilers don't mangle their names. END_DECLS is used at the end.
77+
* BEGIN_DECLS is used at the beginning of declarations so that C++ compilers
78+
* don't mangle their names. END_DECLS is used at the end.
7179
*/
7280
#undef BEGIN_DECLS
7381
#undef END_DECLS

lib/getaddrinfo.c

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
* which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
2121
*
2222
* Written by Russ Allbery <eagle@eyrie.org>
23-
* Copyright 2003-2005, 2016-2017, 2019-2020 Russ Allbery <eagle@eyrie.org>
23+
* Copyright 2003-2005, 2016-2017, 2019-2020, 2025
24+
* Russ Allbery <eagle@eyrie.org>
2425
* Copyright 2015 Julien ÉLIE <julien@trigofacile.com>
2526
* Copyright 2008, 2011, 2013-2014
2627
* The Board of Trustees of the Leland Stanford Junior University
@@ -121,13 +122,6 @@ static const char *const gai_errors[] = {
121122
"Supplied buffer too small", /* 10 EAI_OVERFLOW */
122123
};
123124

124-
/* Macro to set the len attribute of sockaddr_in. */
125-
#if HAVE_STRUCT_SOCKADDR_SA_LEN
126-
# define sin_set_length(s) ((s)->sin_len = sizeof(struct sockaddr_in))
127-
#else
128-
# define sin_set_length(s) /* empty */
129-
#endif
130-
131125
/*
132126
* Used for iterating through arrays. ARRAY_SIZE returns the number of
133127
* elements in the array (useful for a < upper bound in a for loop).
@@ -230,7 +224,9 @@ gai_addrinfo_new(int socktype, const char *canonical, struct in_addr addr,
230224
sin->sin_family = AF_INET;
231225
sin->sin_addr = addr;
232226
sin->sin_port = htons(port);
233-
sin_set_length(sin);
227+
#if HAVE_STRUCT_SOCKADDR_SA_LEN
228+
sin->sin_len = sizeof(struct sockaddr_in);
229+
#endif
234230
ai->ai_addr = (struct sockaddr *) sin;
235231
ai->ai_addrlen = sizeof(struct sockaddr_in);
236232
return ai;

m4/cc-flags.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dnl
88
dnl The canonical version of this file is maintained in the rra-c-util
99
dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
1010
dnl
11-
dnl Copyright 2016-2024 Russ Allbery <eagle@eyrie.org>
11+
dnl Copyright 2016-2025 Russ Allbery <eagle@eyrie.org>
1212
dnl Copyright 2006, 2009, 2016
1313
dnl by Internet Systems Consortium, Inc. ("ISC")
1414
dnl

m4/sqlite3.m4

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ dnl --with-sqlite3-include configure options to specify non-standard paths to
66
dnl the SQLite v3 libraries or header files.
77
dnl
88
dnl Provides the macro INN_LIB_SQLITE3 and sets the substitution variables
9-
dnl SQLITE3_CPPFLAGS, SQLITE3_LDFLAGS, and SQLITE3_LIBS. Also provides
9+
dnl SQLITE3_CPPFLAGS, SQLITE3_LDFLAGS, and SQLITE3_LIBS. Also provides
1010
dnl INN_LIB_SQLITE3_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the
1111
dnl SQLite library, saving the current values first, and
1212
dnl INN_LIB_SQLITE3_RESTORE to restore those settings to before the last
13-
dnl INN_LIB_SQLITE3_SWITCH. Defines HAVE_SQLITE3 and sets inn_use_SQLITE3 to
13+
dnl INN_LIB_SQLITE3_SWITCH. Defines HAVE_SQLITE3 and sets inn_use_SQLITE3 to
1414
dnl true.
1515
dnl
1616
dnl Provides the INN_LIB_SQLITE3_OPTIONAL macro, which should be used if
17-
dnl SQLite support is optional. This macro will still always set the
17+
dnl SQLite support is optional. This macro will still always set the
1818
dnl substitution variables, but they'll be empty if the SQLite library is not
19-
dnl found or if --without-sqlite3 is given. Defines HAVE_SQLITE3 and sets
19+
dnl found or if --without-sqlite3 is given. Defines HAVE_SQLITE3 and sets
2020
dnl inn_use_SQLITE3 to true if the SQLite library is found and
2121
dnl --without-sqlite3 is not given.
2222
dnl
@@ -27,7 +27,7 @@ dnl The canonical version of this file is maintained in the rra-c-util
2727
dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
2828
dnl
2929
dnl Written by Russ Allbery <eagle@eyrie.org>
30-
dnl Copyright 2020, 2022 Russ Allbery <eagle@eyrie.org>
30+
dnl Copyright 2020, 2022, 2025 Russ Allbery <eagle@eyrie.org>
3131
dnl Copyright 2014
3232
dnl The Board of Trustees of the Leland Stanford Junior University
3333
dnl
@@ -38,7 +38,7 @@ dnl
3838
dnl SPDX-License-Identifier: FSFULLR
3939

4040
dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to
41-
dnl versions that include the SQLite 3 flags. Used as a wrapper, with
41+
dnl versions that include the SQLite 3 flags. Used as a wrapper, with
4242
dnl INN_LIB_SQLITE3_RESTORE, around tests.
4343
AC_DEFUN([INN_LIB_SQLITE3_SWITCH], [INN_LIB_HELPER_SWITCH([SQLITE3])])
4444

m4/systemd.m4

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ dnl to use to control whether to install unit files.
77
dnl
88
dnl Provides the INN_LIB_SYSTEMD_DAEMON_OPTIONAL macro, which sets
99
dnl SYSTEMD_CFLAGS and SYSTEMD_LIBS substitution variables if libsystemd is
10-
dnl available and defines HAVE_SD_NOTIFY. Adds sd-daemon.c to LIBOBJS if
11-
dnl libsystemd is not available. pkg-config support for libsystemd-daemon is
10+
dnl available and defines HAVE_SD_NOTIFY. Adds sd-daemon.c to LIBOBJS if
11+
dnl libsystemd is not available. pkg-config support for libsystemd-daemon is
1212
dnl required for it to be detected.
1313
dnl
1414
dnl Depends on the Autoconf macros that come with pkg-config.
@@ -17,7 +17,7 @@ dnl The canonical version of this file is maintained in the rra-c-util
1717
dnl package, available at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
1818
dnl
1919
dnl Written by Russ Allbery <eagle@eyrie.org>
20-
dnl Copyright 2015, 2021, 2022 Russ Allbery <eagle@eyrie.org>
20+
dnl Copyright 2015, 2021, 2022, 2025 Russ Allbery <eagle@eyrie.org>
2121
dnl Copyright 2013-2014
2222
dnl The Board of Trustees of the Leland Stanford Junior University
2323
dnl
@@ -28,10 +28,10 @@ dnl
2828
dnl SPDX-License-Identifier: FSFULLR
2929

3030
dnl Determine the systemd system unit directory, along with a configure flag
31-
dnl to override, and sets @systemdsystemunitdir@. Provides the Automake
31+
dnl to override, and sets @systemdsystemunitdir@. Provides the Automake
3232
dnl HAVE_SYSTEMD Automake conditional.
3333
AC_DEFUN([INN_WITH_SYSTEMD_UNITDIR],
34-
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])
34+
[PKG_PROG_PKG_CONFIG([], [PKG_CONFIG=false])
3535
AS_IF([test x"$PKG_CONFIG" = x], [PKG_CONFIG=false])
3636
AC_ARG_WITH([systemdsystemunitdir],
3737
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
@@ -45,12 +45,14 @@ AC_DEFUN([INN_WITH_SYSTEMD_UNITDIR],
4545
&& test x"$with_systemdsystemunitdir" != xno])])
4646

4747
dnl Check for libsystemd or libsystemd-daemon and define SYSTEMD_{CFLAGS,LIBS}
48-
dnl if it is available. This is called INN_LIB_SYSTEMD_DAEMON_OPTIONAL since
48+
dnl if it is available. This is called INN_LIB_SYSTEMD_DAEMON_OPTIONAL since
4949
dnl it was originally written when libsystemd-daemon was separate, and only
50-
dnl checks for that library. It may eventually make sense to retire this in
50+
dnl checks for that library. It may eventually make sense to retire this in
5151
dnl favor of a simple INN_LIB_SYSTEMD_OPTIONAL that isn't backward-compatible.
5252
AC_DEFUN([INN_LIB_SYSTEMD_DAEMON_OPTIONAL],
53-
[PKG_CHECK_EXISTS([libsystemd],
53+
[PKG_PROG_PKG_CONFIG([], [PKG_CONFIG=false])
54+
AS_IF([test x"$PKG_CONFIG" = x], [PKG_CONFIG=false])
55+
PKG_CHECK_EXISTS([libsystemd],
5456
[PKG_CHECK_MODULES([SYSTEMD], [libsystemd])
5557
AC_DEFINE([HAVE_SD_NOTIFY], 1, [Define if sd_notify is available.])],
5658
[PKG_CHECK_EXISTS([libsystemd-daemon],

support/getc-tap-harness

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Synchronize INN files maintained in c-tap-harness with upstream.
44
##
5+
## Initial version written in September 2014 by Julien ÉLIE.
6+
##
7+
## Various bug fixes, code and documentation improvements since then
8+
## in 2014-2016, 2018, 2021, 2022, 2024, 2025.
9+
##
510
## This script downloads the latest version of the files maintained
611
## in the C TAP Harness package that INN uses for its test driver suite.
712
## These files are available at

support/getrra-c-util

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
## Synchronize INN files maintained in rra-c-util with upstream.
44
##
5+
## Initial version written in November 2013 by Julien ÉLIE.
6+
##
7+
## Various bug fixes, code and documentation improvements since then
8+
## in 2014-2018, 2020-2025.
9+
##
510
## This script downloads the latest version of the files maintained
611
## in the rra-c-util package that INN uses for most of its utility and
712
## portability functions. These files are available at
@@ -83,7 +88,7 @@ AC_DEFUN([_INN_LIB_SQLITE3_INTERNAL],\
8388
[AS_IF([test x"$1" = xtrue],\
8489
[AC_MSG_ERROR([cannot find usable SQLite v3 library])])])])\
8590
' \
86-
-e '49,69d' \
91+
-e '49,71d' \
8792
${TEMP}
8893
fi
8994
elif [ "$2" = "include/inn" ] || [ "$2" = "include/portable" ] \

0 commit comments

Comments
 (0)