Replace ISC_PRINT_QUADFORMAT with inttypes.h format constants

This commit is contained in:
Ondřej Surý
2018-08-08 09:36:44 +02:00
parent 9e493798c6
commit 64fe6bbaf2
31 changed files with 122 additions and 204 deletions
+4 -3
View File
@@ -13,6 +13,9 @@
#include <config.h>
#include <inttypes.h>
#include <stdarg.h>
#include <isc/buffer.h>
#include <isc/mem.h>
#include <isc/print.h>
@@ -20,8 +23,6 @@
#include <isc/string.h>
#include <isc/util.h>
#include <stdarg.h>
void
isc__buffer_init(isc_buffer_t *b, void *base, unsigned int length) {
/*
@@ -476,7 +477,7 @@ isc_buffer_putdecint(isc_buffer_t *b, isc_int64_t v) {
REQUIRE(ISC_BUFFER_VALID(b));
/* xxxwpk do it more low-level way ? */
l = snprintf(buf, 21, "%" ISC_PRINT_QUADFORMAT "d", v);
l = snprintf(buf, 21, "%" PRId64, v);
RUNTIME_CHECK(l <= 21);
if (ISC_UNLIKELY(b->autore)) {
result = isc_buffer_reserve(&b, l);
-3
View File
@@ -166,9 +166,6 @@
***/
/*! \brief
* The printf format string modifier to use with isc_uint64_t values.
*/
@ISC_PLATFORM_QUADFORMAT@
/*
* If the system needs strlcpy(), ISC_PLATFORM_NEEDSTRLCPY will be defined.
-5
View File
@@ -22,11 +22,6 @@
#include <isc/lang.h>
#include <isc/platform.h>
/***
*** Macros
***/
#define ISC_PRINT_QUADFORMAT ISC_PLATFORM_QUADFORMAT
/***
*** Functions
***/
+15 -15
View File
@@ -16,7 +16,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <inttypes.h>
#include <limits.h>
#include <isc/bind9.h>
@@ -2369,33 +2369,33 @@ xml_renderctx(isc__mem_t *ctx, summarystat_t *summary,
summary->total += ctx->total;
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "total"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
(isc_uint64_t)ctx->total));
TRY0(xmlTextWriterEndElement(writer)); /* total */
summary->inuse += ctx->inuse;
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "inuse"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
(isc_uint64_t)ctx->inuse));
TRY0(xmlTextWriterEndElement(writer)); /* inuse */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "maxinuse"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
(isc_uint64_t)ctx->maxinuse));
TRY0(xmlTextWriterEndElement(writer)); /* maxinuse */
summary->malloced += ctx->malloced;
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "malloced"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
(isc_uint64_t)ctx->malloced));
TRY0(xmlTextWriterEndElement(writer)); /* malloced */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "maxmalloced"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
(isc_uint64_t)ctx->maxmalloced));
TRY0(xmlTextWriterEndElement(writer)); /* maxmalloced */
@@ -2404,7 +2404,7 @@ xml_renderctx(isc__mem_t *ctx, summarystat_t *summary,
summary->blocksize += ctx->basic_table_count *
NUM_BASIC_BLOCKS * ctx->mem_target;
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
(isc_uint64_t)
ctx->basic_table_count *
NUM_BASIC_BLOCKS *
@@ -2420,13 +2420,13 @@ xml_renderctx(isc__mem_t *ctx, summarystat_t *summary,
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "hiwater"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
(isc_uint64_t)ctx->hi_water));
TRY0(xmlTextWriterEndElement(writer)); /* hiwater */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "lowater"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
(isc_uint64_t)ctx->lo_water));
TRY0(xmlTextWriterEndElement(writer)); /* lowater */
@@ -2470,37 +2470,37 @@ isc_mem_renderxml(xmlTextWriterPtr writer) {
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "TotalUse"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
summary.total));
TRY0(xmlTextWriterEndElement(writer)); /* TotalUse */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "InUse"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
summary.inuse));
TRY0(xmlTextWriterEndElement(writer)); /* InUse */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "Malloced"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
summary.malloced));
TRY0(xmlTextWriterEndElement(writer)); /* InUse */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "BlockSize"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
summary.blocksize));
TRY0(xmlTextWriterEndElement(writer)); /* BlockSize */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "ContextSize"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
summary.contextsize));
TRY0(xmlTextWriterEndElement(writer)); /* ContextSize */
TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "Lost"));
TRY0(xmlTextWriterWriteFormatString(writer,
"%" ISC_PRINT_QUADFORMAT "u",
"%" PRIu64 "",
lost));
TRY0(xmlTextWriterEndElement(writer)); /* Lost */
+6 -4
View File
@@ -10,7 +10,9 @@
*/
#include <config.h>
#include <stdlib.h>
#include <inttypes.h>
#include <atf-c.h>
@@ -149,8 +151,8 @@ ATF_TC_BODY(atomic_xaddq, tc) {
isc_test_end();
printf("64-bit counter %"ISC_PRINT_QUADFORMAT"d, "
"expected %"ISC_PRINT_QUADFORMAT"d\n",
printf("64-bit counter %" PRId64 ", "
"expected %" PRId64 "\n",
counter_64, EXPECTED_COUNT_64);
ATF_CHECK_EQ(counter_64, EXPECTED_COUNT_64);
@@ -304,8 +306,8 @@ ATF_TC_BODY(atomic_storeq, tc) {
(isc_uint64_t) r);
val |= ((isc_uint64_t) val << 32);
printf("64-bit store 0x%"ISC_PRINT_QUADFORMAT"x, "
"expected 0x%"ISC_PRINT_QUADFORMAT"x\n",
printf("64-bit store 0x%" PRIx64 ", "
"expected 0x%" PRIx64 "\n",
(isc_uint64_t) store_64, val);
ATF_CHECK_EQ((isc_uint64_t) store_64, val);
+2 -1
View File
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <string.h>
#include <inttypes.h>
#include <isc/hash.h>
@@ -1835,7 +1836,7 @@ ATF_TC_BODY(isc_crc64, tc) {
}
isc_crc64_final(&crc);
snprintf(str, sizeof(str),
"0x%016" ISC_PRINT_QUADFORMAT "X", crc);
"0x%016" PRIX64, crc);
ATF_CHECK_STREQ(str, testcase->result);
testcase++;
+1 -3
View File
@@ -15,11 +15,9 @@
#include <atf-c.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h> /* uintptr_t */
#endif
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <isc/condition.h>
#include <isc/mem.h>
+1 -3
View File
@@ -34,9 +34,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#ifdef HAVE_INTTYPES_H
#include <inttypes.h> /* uintptr_t */
#endif
#include <inttypes.h>
#include <isc/buffer.h>
#include <isc/bufferlist.h>
-2
View File
@@ -50,8 +50,6 @@
#define ISC_PLATFORM_NEEDPTON
#define ISC_PLATFORM_HAVESOCKADDRSTORAGE
#define ISC_PLATFORM_QUADFORMAT "I64"
#define ISC_PLATFORM_NEEDSTRSEP
#define ISC_PLATFORM_NEEDSTRLCPY
#define ISC_PLATFORM_NEEDSTRLCAT