2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-29 05:28:00 +00:00

Remove do-nothing header <isc/offset.h>

And replace all uses of isc_offset_t with standard off_t
This commit is contained in:
Tony Finch 2022-12-16 11:47:40 +00:00
parent bed09c1676
commit c7615bc28d
10 changed files with 22 additions and 50 deletions

View File

@ -17,7 +17,6 @@
#include <stdbool.h>
#include <isc/file.h>
#include <isc/offset.h>
#include <isc/print.h>
#include <isc/result.h>
#include <isc/stdio.h>
@ -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)

View File

@ -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;

View File

@ -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);

View File

@ -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 \

View File

@ -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) {

View File

@ -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.
*/

View File

@ -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;
/*%

View File

@ -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 <limits.h> /* Required for CHAR_BIT. */
#include <stddef.h> /* For Linux Standard Base. */
#include <sys/types.h>
typedef off_t isc_offset_t;

View File

@ -15,8 +15,7 @@
/*! \file */
#include <inttypes.h>
#include <stdbool.h>
#include <time.h>
#include <isc/lang.h>
#include <isc/types.h>

View File

@ -19,10 +19,10 @@
* \brief
* OS-specific types, from the OS-specific include directories.
*/
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <isc/offset.h>
#include <stddef.h>
#include <stdint.h>
/*
* XXXDCL This is just for ISC_LIST and ISC_LINK, but gets all of the other