Remove old cruft from dnsrps code

There was some old cruft for ancient compilers checking for attributes
that we regularly use, etc.  Just remove the cruft.
This commit is contained in:
Ondřej Surý 2024-08-19 15:41:43 +02:00
parent 796f886173
commit d7bff3c0f9
No known key found for this signature in database
GPG key ID: 2820F37E873DEA41
6 changed files with 24 additions and 53 deletions

View file

@ -4,7 +4,7 @@ AM_CPPFLAGS += \
$(LIBISC_CFLAGS) \
$(LIBDNS_CFLAGS)
AM_CFLAGS += -Wall -pedantic
AM_CFLAGS += -Wall -pedantic -Wno-zero-length-array
noinst_LTLIBRARIES = libdummyrpz.la
libdummyrpz_la_SOURCES= dummylib.c test-data.c trpz.h test-data.h

View file

@ -42,6 +42,10 @@
#include <time.h>
#include <unistd.h>
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
#include <arpa/nameser_compat.h>
#endif /* HAVE_ARPA_NAMESER_COMPAT_H */
#include <isc/endian.h>
#include <isc/util.h>
@ -2124,7 +2128,7 @@ trpz_rsp_rr(librpz_emsg_t *emsg, uint16_t *typep, uint16_t *classp,
/* If there's CNAME wild card expansion */
if (qname != NULL && qname_size != 0 &&
(this_rr->type == ns_t_cname) &&
(this_rr->type == T_CNAME) &&
(this_rr->rdlength > 2))
{
if (this_rr->rdata[0] == 1 &&
@ -2199,7 +2203,7 @@ trpz_rsp_rr(librpz_emsg_t *emsg, uint16_t *typep, uint16_t *classp,
trsp->rstack[0].result.next_rr = this_rr->rrn;
last_result->rridx++;
} else {
SET_IF_NOT_NULL(typep, ns_t_invalid);
SET_IF_NOT_NULL(typep, 0);
if (rrp != NULL) {
*rrp = NULL;

View file

@ -37,6 +37,10 @@
#include <stdlib.h>
#include <unistd.h>
#ifdef HAVE_ARPA_NAMESER_COMPAT_H
#include <arpa/nameser_compat.h>
#endif /* HAVE_ARPA_NAMESER_COMPAT_H */
#include <isc/atomic.h>
#include <isc/util.h>
@ -397,7 +401,7 @@ add_other_rr(trpz_result_t *node, const char *rrtype, const char *val,
*modified = 0;
nrec.class = ns_c_in;
nrec.class = C_IN;
nrec.ttl = ttl;
nrec.rrn = atomic_fetch_add_relaxed(&rrn, 1);
@ -412,7 +416,7 @@ add_other_rr(trpz_result_t *node, const char *rrtype, const char *val,
return (-1);
}
nrec.type = ns_t_a;
nrec.type = T_A;
nrec.rdlength = sizeof(uint32_t);
nrec.rdata = malloc(nrec.rdlength);
@ -433,7 +437,7 @@ add_other_rr(trpz_result_t *node, const char *rrtype, const char *val,
return (-1);
}
nrec.type = ns_t_aaaa;
nrec.type = T_AAAA;
nrec.rdlength = sizeof(addr);
nrec.rdata = malloc(nrec.rdlength);
@ -444,7 +448,7 @@ add_other_rr(trpz_result_t *node, const char *rrtype, const char *val,
memmove(nrec.rdata, addr, nrec.rdlength);
} else if (!strcasecmp(rrtype, "TXT")) {
nrec.type = ns_t_txt;
nrec.type = T_TXT;
nrec.rdlength = 1 + strlen(val);
nrec.rdata = calloc(nrec.rdlength, 1);
@ -458,7 +462,7 @@ add_other_rr(trpz_result_t *node, const char *rrtype, const char *val,
} else if (!strcasecmp(rrtype, "CNAME")) {
int ret;
nrec.type = ns_t_cname;
nrec.type = T_CNAME;
ret = wdns_str_to_name(val, &(nrec.rdata), 1);
if (ret <= 0) {
@ -473,7 +477,7 @@ add_other_rr(trpz_result_t *node, const char *rrtype, const char *val,
} else if (!strcasecmp(rrtype, "DNAME")) {
int ret;
nrec.type = ns_t_dname;
nrec.type = T_DNAME;
ret = wdns_str_to_name(val, &(nrec.rdata), 1);
if (ret <= 0) {

View file

@ -28,25 +28,8 @@
* limitations under the License.
*/
#define LIBRPZ_LIB_OPEN 2
#include <dns/librpz.h>
#if __NAMESER < 19991006
/*
* If the new API is not available define the values we use.
*/
#define ns_c_in 1
#define ns_t_invalid 0
#define ns_t_a 1
#define ns_t_cname 5
#define ns_t_txt 16
#define ns_t_aaaa 28
#define ns_t_dname 39
#endif
#include "trpz.h"
#define NODE_FLAG_IPV6_ADDRESS 0x1

View file

@ -360,6 +360,11 @@ AC_CHECK_HEADERS([fcntl.h regex.h sys/time.h unistd.h sys/mman.h sys/sockio.h sy
#
AC_CHECK_HEADERS([threads.h])
#
# Also missing from OpenBSD
#
AC_CHECK_HEADERS([arpa/nameser_compat.h])
#
# C11 Atomic Operations
#
@ -1361,22 +1366,6 @@ AC_DEFINE_UNQUOTED([VALIDATION_DEFAULT], ["$validation_default"], [the default v
# modern C compiler. It is enabled on systems with dlopen() and librpz.so.
#
dnsrps_avail=yes
AC_MSG_CHECKING([for librpz __attribute__s])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[]],
[[
extern void f(char *p __attribute__((unused)), ...)
__attribute__((format(printf,1,2))) __attribute__((__noreturn__));
]])],
[
librpz_have_attr=yes
AC_DEFINE([LIBRPZ_HAVE_ATTR], [1], [have __attribute__s used in librpz.h])
AC_MSG_RESULT([yes])
],[
librpz_have_attr=no
AC_MSG_RESULT([no])
])
# [pairwise: --enable-dnsrps --enable-dnsrps-dl, --disable-dnsrps]
AC_ARG_ENABLE([dnsrps-dl],
@ -1385,9 +1374,6 @@ AC_ARG_ENABLE([dnsrps-dl],
[default=yes]])],
[enable_dnsrps_dl="$enableval"], [enable_dnsrps_dl="yes"])
AS_IF([test "$enable_dnsrps_dl" = "yes" -a "$with_dlopen" = "no"],
[AC_MSG_ERROR([DNS Response Policy Service delayed link requires dlopen to be enabled])])
# [pairwise: skip]
AC_ARG_WITH([dnsrps-libname],
[AS_HELP_STRING([--with-dnsrps-libname],

View file

@ -214,15 +214,9 @@ typedef struct {
char c[120];
} librpz_emsg_t;
#ifdef LIBRPZ_HAVE_ATTR
#define LIBRPZ_UNUSED ISC_ATTR_UNUSED
#define LIBRPZ_PF(f, l) __attribute__((format(printf, f, l)))
#define LIBRPZ_UNUSED __attribute__((__unused__))
#define LIBRPZ_PF(f, l) __attribute__((__format__(printf, f, l)))
#define LIBRPZ_NORET __attribute__((__noreturn__))
#else /* ifdef LIBRPZ_HAVE_ATTR */
#define LIBRPZ_UNUSED
#define LIBRPZ_PF(f, l)
#define LIBRPZ_NORET
#endif /* ifdef LIBRPZ_HAVE_ATTR */
typedef bool(librpz_parse_log_opt_t)(librpz_emsg_t *emsg, const char *arg);
LIBDEF_F(parse_log_opt)