From c7615bc28d2dd14d54c45c15500e70bb822f3a54 Mon Sep 17 00:00:00 2001 From: Tony Finch Date: Fri, 16 Dec 2022 11:47:40 +0000 Subject: [PATCH] Remove do-nothing header And replace all uses of isc_offset_t with standard off_t --- bin/named/logconf.c | 9 ++++----- lib/dns/dnstap.c | 2 +- lib/dns/journal.c | 18 +++++++++--------- lib/isc/Makefile.am | 1 - lib/isc/file.c | 2 +- lib/isc/include/isc/file.h | 2 +- lib/isc/include/isc/log.h | 4 ++-- lib/isc/include/isc/offset.h | 25 ------------------------- lib/isc/include/isc/time.h | 3 +-- lib/isc/include/isc/types.h | 6 +++--- 10 files changed, 22 insertions(+), 50 deletions(-) delete mode 100644 lib/isc/include/isc/offset.h diff --git a/bin/named/logconf.c b/bin/named/logconf.c index 5fd0904f43..59dfb2fb8f 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -146,14 +145,14 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) { const cfg_obj_t *suffixobj = cfg_tuple_get(fileobj, "suffix"); int32_t versions = ISC_LOG_ROLLNEVER; isc_log_rollsuffix_t suffix = isc_log_rollsuffix_increment; - isc_offset_t size = 0; + off_t size = 0; uint64_t maxoffset; /* - * isc_offset_t is a signed integer type, so the maximum + * off_t is a signed integer type, so the maximum * value is all 1s except for the MSB. */ - switch (sizeof(isc_offset_t)) { + switch (sizeof(off_t)) { case 4: maxoffset = 0x7fffffffULL; break; @@ -178,7 +177,7 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) { if (sizeobj != NULL && cfg_obj_isuint64(sizeobj) && cfg_obj_asuint64(sizeobj) < maxoffset) { - size = (isc_offset_t)cfg_obj_asuint64(sizeobj); + size = (off_t)cfg_obj_asuint64(sizeobj); } if (suffixobj != NULL && cfg_obj_isstring(suffixobj) && strcasecmp(cfg_obj_asstring(suffixobj), "timestamp") == 0) diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index 784acd92f1..2137e74db7 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -118,7 +118,7 @@ struct dns_dtenv { isc_region_t version; char *path; dns_dtmode_t mode; - isc_offset_t max_size; + off_t max_size; int rolls; isc_log_rollsuffix_t suffix; isc_stats_t *stats; diff --git a/lib/dns/journal.c b/lib/dns/journal.c index 62038a01b2..66a6e74324 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -184,7 +184,7 @@ typedef struct { unsigned char serial[4]; /*%< SOA serial before update. */ /* * XXXRTH Should offset be 8 bytes? - * XXXDCL ... probably, since isc_offset_t is 8 bytes on many OSs. + * XXXDCL ... probably, since off_t is 8 bytes on many OSs. * XXXAG ... but we will not be able to seek >2G anyway on many * platforms as long as we are using fseek() rather * than lseek(). @@ -259,7 +259,7 @@ typedef struct { */ typedef struct { uint32_t serial; - isc_offset_t offset; + off_t offset; } journal_pos_t; #define POS_VALID(pos) ((pos).offset != 0) @@ -330,7 +330,7 @@ struct dns_journal { * while reading the journal */ char *filename; /*%< Journal file name */ FILE *fp; /*%< File handle */ - isc_offset_t offset; /*%< Current file offset */ + off_t offset; /*%< Current file offset */ journal_xhdr_t curxhdr; /*%< Current transaction header */ journal_header_t header; /*%< In-core journal header */ unsigned char *rawindex; /*%< In-core buffer for journal index @@ -441,7 +441,7 @@ journal_read(dns_journal_t *j, void *mem, size_t nbytes) { isc_result_totext(result)); return (ISC_R_UNEXPECTED); } - j->offset += (isc_offset_t)nbytes; + j->offset += (off_t)nbytes; return (ISC_R_SUCCESS); } @@ -456,7 +456,7 @@ journal_write(dns_journal_t *j, void *mem, size_t nbytes) { isc_result_totext(result)); return (ISC_R_UNEXPECTED); } - j->offset += (isc_offset_t)nbytes; + j->offset += (off_t)nbytes; return (ISC_R_SUCCESS); } @@ -857,7 +857,7 @@ ixfr_order(const void *av, const void *bv) { static isc_result_t maybe_fixup_xhdr(dns_journal_t *j, journal_xhdr_t *xhdr, uint32_t serial, - isc_offset_t offset) { + off_t offset) { isc_result_t result = ISC_R_SUCCESS; /* @@ -990,7 +990,7 @@ journal_next(dns_journal_t *j, journal_pos_t *pos) { ? sizeof(journal_rawxhdr_t) : sizeof(journal_rawxhdr_ver1_t); - if ((isc_offset_t)(pos->offset + hdrsize + xhdr.size) < pos->offset) { + if ((off_t)(pos->offset + hdrsize + xhdr.size) < pos->offset) { isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR, "%s: offset too large", j->filename); return (ISC_R_UNEXPECTED); @@ -1367,7 +1367,7 @@ dns_journal_commit(dns_journal_t *j) { CHECK(journal_fsync(j)); if (j->state == JOURNAL_STATE_TRANSACTION) { - isc_offset_t offset; + off_t offset; offset = (j->x.pos[1].offset - j->x.pos[0].offset) - (j->header_ver1 ? sizeof(journal_rawxhdr_ver1_t) : sizeof(journal_rawxhdr_t)); @@ -2621,7 +2621,7 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial, */ while (rewrite && len > 0) { journal_xhdr_t xhdr; - isc_offset_t offset = j1->offset; + off_t offset = j1->offset; uint32_t count; result = journal_read_xhdr(j1, &xhdr); diff --git a/lib/isc/Makefile.am b/lib/isc/Makefile.am index 314a70df91..4322f2e686 100644 --- a/lib/isc/Makefile.am +++ b/lib/isc/Makefile.am @@ -61,7 +61,6 @@ libisc_la_HEADERS = \ include/isc/netmgr.h \ include/isc/netscope.h \ include/isc/nonce.h \ - include/isc/offset.h \ include/isc/once.h \ include/isc/os.h \ include/isc/parseint.h \ diff --git a/lib/isc/file.c b/lib/isc/file.c index a1aed8e164..128f985cd9 100644 --- a/lib/isc/file.c +++ b/lib/isc/file.c @@ -584,7 +584,7 @@ isc_file_absolutepath(const char *filename, char *path, size_t pathlen) { } isc_result_t -isc_file_truncate(const char *filename, isc_offset_t size) { +isc_file_truncate(const char *filename, off_t size) { isc_result_t result = ISC_R_SUCCESS; if (truncate(filename, size) < 0) { diff --git a/lib/isc/include/isc/file.h b/lib/isc/include/isc/file.h index 46d0f9246a..2e5d4d2da5 100644 --- a/lib/isc/include/isc/file.h +++ b/lib/isc/include/isc/file.h @@ -287,7 +287,7 @@ isc_file_absolutepath(const char *filename, char *path, size_t pathlen); */ isc_result_t -isc_file_truncate(const char *filename, isc_offset_t size); +isc_file_truncate(const char *filename, off_t size); /*%< * Truncate/extend the file specified to 'size' bytes. */ diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h index 54b4022201..5a9a7a1bb3 100644 --- a/lib/isc/include/isc/log.h +++ b/lib/isc/include/isc/log.h @@ -138,8 +138,8 @@ typedef struct isc_logfile { * anyone would want). st_size returned by fstat should be typedef'd * to a size large enough for the largest possible file on a system. */ - isc_offset_t maximum_size; - bool maximum_reached; /*%< Private. */ + off_t maximum_size; + bool maximum_reached; /*%< Private. */ } isc_logfile_t; /*% diff --git a/lib/isc/include/isc/offset.h b/lib/isc/include/isc/offset.h deleted file mode 100644 index 2b62e2a292..0000000000 --- a/lib/isc/include/isc/offset.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -/*! \file - * \brief - * File offsets are operating-system dependent. - */ -#include /* Required for CHAR_BIT. */ -#include /* For Linux Standard Base. */ - -#include - -typedef off_t isc_offset_t; diff --git a/lib/isc/include/isc/time.h b/lib/isc/include/isc/time.h index e2f232a793..ea9fb9d9c4 100644 --- a/lib/isc/include/isc/time.h +++ b/lib/isc/include/isc/time.h @@ -15,8 +15,7 @@ /*! \file */ -#include -#include +#include #include #include diff --git a/lib/isc/include/isc/types.h b/lib/isc/include/isc/types.h index 94aa5f760b..8e3e9b5b19 100644 --- a/lib/isc/include/isc/types.h +++ b/lib/isc/include/isc/types.h @@ -19,10 +19,10 @@ * \brief * OS-specific types, from the OS-specific include directories. */ -#include +#include #include - -#include +#include +#include /* * XXXDCL This is just for ISC_LIST and ISC_LINK, but gets all of the other