mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 22:15:20 +00:00
Replace custom isc_u?intNN_t types with C99 u?intNN_t types
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
@@ -102,7 +103,7 @@
|
||||
|
||||
static isc_result_t index_to_disk(dns_journal_t *);
|
||||
|
||||
static inline isc_uint32_t
|
||||
static inline uint32_t
|
||||
decode_uint32(unsigned char *p) {
|
||||
return ((p[0] << 24) +
|
||||
(p[1] << 16) +
|
||||
@@ -111,11 +112,11 @@ decode_uint32(unsigned char *p) {
|
||||
}
|
||||
|
||||
static inline void
|
||||
encode_uint32(isc_uint32_t val, unsigned char *p) {
|
||||
p[0] = (isc_uint8_t)(val >> 24);
|
||||
p[1] = (isc_uint8_t)(val >> 16);
|
||||
p[2] = (isc_uint8_t)(val >> 8);
|
||||
p[3] = (isc_uint8_t)(val >> 0);
|
||||
encode_uint32(uint32_t val, unsigned char *p) {
|
||||
p[0] = (uint8_t)(val >> 24);
|
||||
p[1] = (uint8_t)(val >> 16);
|
||||
p[2] = (uint8_t)(val >> 8);
|
||||
p[3] = (uint8_t)(val >> 0);
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
@@ -235,7 +236,7 @@ typedef struct {
|
||||
* The in-core representation of the journal header.
|
||||
*/
|
||||
typedef struct {
|
||||
isc_uint32_t serial;
|
||||
uint32_t serial;
|
||||
isc_offset_t offset;
|
||||
} journal_pos_t;
|
||||
|
||||
@@ -246,8 +247,8 @@ typedef struct {
|
||||
unsigned char format[16];
|
||||
journal_pos_t begin;
|
||||
journal_pos_t end;
|
||||
isc_uint32_t index_size;
|
||||
isc_uint32_t sourceserial;
|
||||
uint32_t index_size;
|
||||
uint32_t sourceserial;
|
||||
isc_boolean_t serialset;
|
||||
} journal_header_t;
|
||||
|
||||
@@ -256,16 +257,16 @@ typedef struct {
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
isc_uint32_t size;
|
||||
isc_uint32_t serial0;
|
||||
isc_uint32_t serial1;
|
||||
uint32_t size;
|
||||
uint32_t serial0;
|
||||
uint32_t serial1;
|
||||
} journal_xhdr_t;
|
||||
|
||||
/*%
|
||||
* The in-core representation of the RR header.
|
||||
*/
|
||||
typedef struct {
|
||||
isc_uint32_t size;
|
||||
uint32_t size;
|
||||
} journal_rrhdr_t;
|
||||
|
||||
|
||||
@@ -316,13 +317,13 @@ struct dns_journal {
|
||||
journal_pos_t bpos; /*%< Position before first, */
|
||||
journal_pos_t epos; /*%< and after last transaction */
|
||||
/* The rest is iterator state. */
|
||||
isc_uint32_t current_serial; /*%< Current SOA serial */
|
||||
uint32_t current_serial; /*%< Current SOA serial */
|
||||
isc_buffer_t source; /*%< Data from disk */
|
||||
isc_buffer_t target; /*%< Data from _fromwire check */
|
||||
dns_decompress_t dctx; /*%< Dummy decompression ctx */
|
||||
dns_name_t name; /*%< Current domain name */
|
||||
dns_rdata_t rdata; /*%< Current rdata */
|
||||
isc_uint32_t ttl; /*%< Current TTL */
|
||||
uint32_t ttl; /*%< Current TTL */
|
||||
unsigned int xsize; /*%< Size of transaction data */
|
||||
unsigned int xpos; /*%< Current position in it */
|
||||
isc_result_t result; /*%< Result of last call */
|
||||
@@ -375,7 +376,7 @@ journal_header_encode(journal_header_t *cooked, journal_rawheader_t *raw) {
|
||||
* Journal file I/O subroutines, with error checking and reporting.
|
||||
*/
|
||||
static isc_result_t
|
||||
journal_seek(dns_journal_t *j, isc_uint32_t offset) {
|
||||
journal_seek(dns_journal_t *j, uint32_t offset) {
|
||||
isc_result_t result;
|
||||
|
||||
result = isc_stdio_seek(j->fp, (off_t)offset, SEEK_SET);
|
||||
@@ -459,8 +460,8 @@ journal_read_xhdr(dns_journal_t *j, journal_xhdr_t *xhdr) {
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
journal_write_xhdr(dns_journal_t *j, isc_uint32_t size,
|
||||
isc_uint32_t serial0, isc_uint32_t serial1)
|
||||
journal_write_xhdr(dns_journal_t *j, uint32_t size,
|
||||
uint32_t serial0, uint32_t serial1)
|
||||
{
|
||||
journal_rawxhdr_t raw;
|
||||
encode_uint32(size, raw.size);
|
||||
@@ -840,7 +841,7 @@ journal_next(dns_journal_t *j, journal_pos_t *pos) {
|
||||
* but not greater than 'serial'.
|
||||
*/
|
||||
static void
|
||||
index_find(dns_journal_t *j, isc_uint32_t serial, journal_pos_t *best_guess) {
|
||||
index_find(dns_journal_t *j, uint32_t serial, journal_pos_t *best_guess) {
|
||||
unsigned int i;
|
||||
if (j->index == NULL)
|
||||
return;
|
||||
@@ -901,7 +902,7 @@ index_add(dns_journal_t *j, journal_pos_t *pos) {
|
||||
* ambiguous when a new transaction with number 'serial' is added.
|
||||
*/
|
||||
static void
|
||||
index_invalidate(dns_journal_t *j, isc_uint32_t serial) {
|
||||
index_invalidate(dns_journal_t *j, uint32_t serial) {
|
||||
unsigned int i;
|
||||
if (j->index == NULL)
|
||||
return;
|
||||
@@ -931,7 +932,7 @@ index_invalidate(dns_journal_t *j, isc_uint32_t serial) {
|
||||
*
|
||||
*/
|
||||
static isc_result_t
|
||||
journal_find(dns_journal_t *j, isc_uint32_t serial, journal_pos_t *pos) {
|
||||
journal_find(dns_journal_t *j, uint32_t serial, journal_pos_t *pos) {
|
||||
isc_result_t result;
|
||||
journal_pos_t current_pos;
|
||||
REQUIRE(DNS_JOURNAL_VALID(j));
|
||||
@@ -961,7 +962,7 @@ journal_find(dns_journal_t *j, isc_uint32_t serial, journal_pos_t *pos) {
|
||||
|
||||
isc_result_t
|
||||
dns_journal_begin_transaction(dns_journal_t *j) {
|
||||
isc_uint32_t offset;
|
||||
uint32_t offset;
|
||||
isc_result_t result;
|
||||
journal_rawxhdr_t hdr;
|
||||
|
||||
@@ -1005,7 +1006,7 @@ dns_journal_writediff(dns_journal_t *j, dns_diff_t *diff) {
|
||||
dns_difftuple_t *t;
|
||||
isc_buffer_t buffer;
|
||||
void *mem = NULL;
|
||||
isc_uint64_t size;
|
||||
uint64_t size;
|
||||
isc_result_t result;
|
||||
isc_region_t used;
|
||||
|
||||
@@ -1038,7 +1039,7 @@ dns_journal_writediff(dns_journal_t *j, dns_diff_t *diff) {
|
||||
if (size >= DNS_JOURNAL_SIZE_MAX) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"dns_journal_writediff: %s: journal entry "
|
||||
"too big to be stored: %llu bytes", j->filename,
|
||||
"too big to be stored: %" PRIu64 " bytes", j->filename,
|
||||
size);
|
||||
return (ISC_R_NOSPACE);
|
||||
}
|
||||
@@ -1068,7 +1069,7 @@ dns_journal_writediff(dns_journal_t *j, dns_diff_t *diff) {
|
||||
isc_buffer_putuint16(&buffer, t->rdata.rdclass);
|
||||
isc_buffer_putuint32(&buffer, t->ttl);
|
||||
INSIST(t->rdata.length < 65536);
|
||||
isc_buffer_putuint16(&buffer, (isc_uint16_t)t->rdata.length);
|
||||
isc_buffer_putuint16(&buffer, (uint16_t)t->rdata.length);
|
||||
INSIST(isc_buffer_availablelength(&buffer) >= t->rdata.length);
|
||||
isc_buffer_putmem(&buffer, t->rdata.data, t->rdata.length);
|
||||
}
|
||||
@@ -1096,7 +1097,7 @@ isc_result_t
|
||||
dns_journal_commit(dns_journal_t *j) {
|
||||
isc_result_t result;
|
||||
journal_rawheader_t rawheader;
|
||||
isc_uint64_t total;
|
||||
uint64_t total;
|
||||
|
||||
REQUIRE(DNS_JOURNAL_VALID(j));
|
||||
REQUIRE(j->state == JOURNAL_STATE_TRANSACTION ||
|
||||
@@ -1150,8 +1151,8 @@ dns_journal_commit(dns_journal_t *j) {
|
||||
if (total >= DNS_JOURNAL_SIZE_MAX) {
|
||||
isc_log_write(JOURNAL_COMMON_LOGARGS, ISC_LOG_ERROR,
|
||||
"transaction too big to be stored in journal: "
|
||||
"%llub (max is %llub)", total,
|
||||
(isc_uint64_t)DNS_JOURNAL_SIZE_MAX);
|
||||
"%" PRIu64 "b (max is %" PRIu64 "b)", total,
|
||||
(uint64_t)DNS_JOURNAL_SIZE_MAX);
|
||||
return (ISC_R_UNEXPECTED);
|
||||
}
|
||||
|
||||
@@ -1278,8 +1279,8 @@ static isc_result_t
|
||||
roll_forward(dns_journal_t *j, dns_db_t *db, unsigned int options) {
|
||||
isc_buffer_t source; /* Transaction data from disk */
|
||||
isc_buffer_t target; /* Ditto after _fromwire check */
|
||||
isc_uint32_t db_serial; /* Database SOA serial */
|
||||
isc_uint32_t end_serial; /* Last journal SOA serial */
|
||||
uint32_t db_serial; /* Database SOA serial */
|
||||
uint32_t end_serial; /* Last journal SOA serial */
|
||||
isc_result_t result;
|
||||
dns_dbversion_t *ver = NULL;
|
||||
journal_pos_t pos;
|
||||
@@ -1336,7 +1337,7 @@ roll_forward(dns_journal_t *j, dns_db_t *db, unsigned int options) {
|
||||
result = dns_journal_next_rr(j))
|
||||
{
|
||||
dns_name_t *name;
|
||||
isc_uint32_t ttl;
|
||||
uint32_t ttl;
|
||||
dns_rdata_t *rdata;
|
||||
dns_difftuple_t *tuple = NULL;
|
||||
|
||||
@@ -1442,8 +1443,8 @@ dns_journal_print(isc_mem_t *mctx, const char *filename, FILE *file) {
|
||||
dns_journal_t *j;
|
||||
isc_buffer_t source; /* Transaction data from disk */
|
||||
isc_buffer_t target; /* Ditto after _fromwire check */
|
||||
isc_uint32_t start_serial; /* Database SOA serial */
|
||||
isc_uint32_t end_serial; /* Last journal SOA serial */
|
||||
uint32_t start_serial; /* Database SOA serial */
|
||||
uint32_t end_serial; /* Last journal SOA serial */
|
||||
isc_result_t result;
|
||||
dns_diff_t diff;
|
||||
unsigned int n_soa = 0;
|
||||
@@ -1487,7 +1488,7 @@ dns_journal_print(isc_mem_t *mctx, const char *filename, FILE *file) {
|
||||
result = dns_journal_next_rr(j))
|
||||
{
|
||||
dns_name_t *name;
|
||||
isc_uint32_t ttl;
|
||||
uint32_t ttl;
|
||||
dns_rdata_t *rdata;
|
||||
dns_difftuple_t *tuple = NULL;
|
||||
|
||||
@@ -1554,18 +1555,18 @@ dns_journal_empty(dns_journal_t *j) {
|
||||
return (JOURNAL_EMPTY(&j->header));
|
||||
}
|
||||
|
||||
isc_uint32_t
|
||||
uint32_t
|
||||
dns_journal_first_serial(dns_journal_t *j) {
|
||||
return (j->header.begin.serial);
|
||||
}
|
||||
|
||||
isc_uint32_t
|
||||
uint32_t
|
||||
dns_journal_last_serial(dns_journal_t *j) {
|
||||
return (j->header.end.serial);
|
||||
}
|
||||
|
||||
void
|
||||
dns_journal_set_sourceserial(dns_journal_t *j, isc_uint32_t sourceserial) {
|
||||
dns_journal_set_sourceserial(dns_journal_t *j, uint32_t sourceserial) {
|
||||
|
||||
REQUIRE(j->state == JOURNAL_STATE_WRITE ||
|
||||
j->state == JOURNAL_STATE_INLINE ||
|
||||
@@ -1578,7 +1579,7 @@ dns_journal_set_sourceserial(dns_journal_t *j, isc_uint32_t sourceserial) {
|
||||
}
|
||||
|
||||
isc_boolean_t
|
||||
dns_journal_get_sourceserial(dns_journal_t *j, isc_uint32_t *sourceserial) {
|
||||
dns_journal_get_sourceserial(dns_journal_t *j, uint32_t *sourceserial) {
|
||||
REQUIRE(sourceserial != NULL);
|
||||
|
||||
if (!j->header.serialset)
|
||||
@@ -1627,7 +1628,7 @@ size_buffer(isc_mem_t *mctx, isc_buffer_t *b, unsigned size) {
|
||||
|
||||
isc_result_t
|
||||
dns_journal_iter_init(dns_journal_t *j,
|
||||
isc_uint32_t begin_serial, isc_uint32_t end_serial)
|
||||
uint32_t begin_serial, uint32_t end_serial)
|
||||
{
|
||||
isc_result_t result;
|
||||
|
||||
@@ -1671,7 +1672,7 @@ read_one_rr(dns_journal_t *j) {
|
||||
dns_rdatatype_t rdtype;
|
||||
dns_rdataclass_t rdclass;
|
||||
unsigned int rdlen;
|
||||
isc_uint32_t ttl;
|
||||
uint32_t ttl;
|
||||
journal_xhdr_t xhdr;
|
||||
journal_rrhdr_t rrhdr;
|
||||
|
||||
@@ -1789,7 +1790,7 @@ dns_journal_next_rr(dns_journal_t *j) {
|
||||
}
|
||||
|
||||
void
|
||||
dns_journal_current_rr(dns_journal_t *j, dns_name_t **name, isc_uint32_t *ttl,
|
||||
dns_journal_current_rr(dns_journal_t *j, dns_name_t **name, uint32_t *ttl,
|
||||
dns_rdata_t **rdata)
|
||||
{
|
||||
REQUIRE(j->it.result == ISC_R_SUCCESS);
|
||||
@@ -2103,8 +2104,8 @@ dns_db_diffx(dns_diff_t *diff, dns_db_t *dba, dns_dbversion_t *dbvera,
|
||||
}
|
||||
|
||||
isc_result_t
|
||||
dns_journal_compact(isc_mem_t *mctx, char *filename, isc_uint32_t serial,
|
||||
isc_uint32_t target_size)
|
||||
dns_journal_compact(isc_mem_t *mctx, char *filename, uint32_t serial,
|
||||
uint32_t target_size)
|
||||
{
|
||||
unsigned int i;
|
||||
journal_pos_t best_guess;
|
||||
@@ -2169,7 +2170,7 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, isc_uint32_t serial,
|
||||
/*
|
||||
* See if there is any work to do.
|
||||
*/
|
||||
if ((isc_uint32_t) j1->header.end.offset < target_size) {
|
||||
if ((uint32_t) j1->header.end.offset < target_size) {
|
||||
dns_journal_destroy(&j1);
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
@@ -2189,7 +2190,7 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, isc_uint32_t serial,
|
||||
for (i = 0; i < j1->header.index_size; i++) {
|
||||
if (POS_VALID(j1->index[i]) &&
|
||||
DNS_SERIAL_GE(serial, j1->index[i].serial) &&
|
||||
((isc_uint32_t)(j1->header.end.offset - j1->index[i].offset)
|
||||
((uint32_t)(j1->header.end.offset - j1->index[i].offset)
|
||||
>= target_size / 2) &&
|
||||
j1->index[i].offset > best_guess.offset)
|
||||
best_guess = j1->index[i];
|
||||
@@ -2202,7 +2203,7 @@ dns_journal_compact(isc_mem_t *mctx, char *filename, isc_uint32_t serial,
|
||||
break;
|
||||
|
||||
if (DNS_SERIAL_GE(serial, current_pos.serial) &&
|
||||
((isc_uint32_t)(j1->header.end.offset - current_pos.offset)
|
||||
((uint32_t)(j1->header.end.offset - current_pos.offset)
|
||||
>= (target_size / 2)) &&
|
||||
current_pos.offset > best_guess.offset)
|
||||
best_guess = current_pos;
|
||||
|
Reference in New Issue
Block a user