Use the semantic patch to do the unsigned -> unsigned int change

Apply the semantic patch on the whole code base to get rid of 'unsigned'
usage in favor of explicit 'unsigned int'.
This commit is contained in:
Ondřej Surý
2022-09-07 17:22:47 +02:00
parent 7e74e441a5
commit f6e4f620b3
34 changed files with 82 additions and 79 deletions

View File

@@ -23,7 +23,7 @@
#define SIZE (1024 * 1024)
typedef void
copy_fn(void *a, void *b, unsigned len);
copy_fn(void *a, void *b, unsigned int len);
static void
time_it(copy_fn *copier, void *a, void *b, const char *name) {
@@ -40,12 +40,12 @@ time_it(copy_fn *copier, void *a, void *b, const char *name) {
}
static void
copy_raw(void *a, void *b, unsigned size) {
copy_raw(void *a, void *b, unsigned int size) {
memmove(a, b, size);
}
static void
copy_toupper(void *va, void *vb, unsigned size) {
copy_toupper(void *va, void *vb, unsigned int size) {
uint8_t *a = va, *b = vb;
while (size-- > 0) {
*a++ = isc_ascii_toupper(*b++);
@@ -53,21 +53,21 @@ copy_toupper(void *va, void *vb, unsigned size) {
}
static void
copy_tolower8(void *a, void *b, unsigned size) {
copy_tolower8(void *a, void *b, unsigned int size) {
isc_ascii_lowercopy(a, b, size);
}
#define TOLOWER(c) ((c) + ('a' - 'A') * (((c) >= 'A') ^ ((c) > 'Z')))
static void
copy_tolower1(void *va, void *vb, unsigned size) {
copy_tolower1(void *va, void *vb, unsigned int size) {
for (uint8_t *a = va, *b = vb; size-- > 0; a++, b++) {
*a = TOLOWER(*b);
}
}
static bool
cmp_tolower1(void *va, void *vb, unsigned size) {
cmp_tolower1(void *va, void *vb, unsigned int size) {
for (uint8_t *a = va, *b = vb; size-- > 0; a++, b++) {
if (TOLOWER(*a) != TOLOWER(*b)) {
return false;
@@ -79,7 +79,7 @@ cmp_tolower1(void *va, void *vb, unsigned size) {
static bool oldskool_result;
static void
cmp_oldskool(void *va, void *vb, unsigned size) {
cmp_oldskool(void *va, void *vb, unsigned int size) {
uint8_t *a = va, *b = vb, c;
while (size > 3) {
@@ -119,22 +119,22 @@ diff:
static bool tolower1_result;
static void
vcmp_tolower1(void *a, void *b, unsigned size) {
vcmp_tolower1(void *a, void *b, unsigned int size) {
tolower1_result = cmp_tolower1(a, b, size);
}
static bool swar_result;
static void
cmp_swar(void *a, void *b, unsigned size) {
cmp_swar(void *a, void *b, unsigned int size) {
swar_result = isc_ascii_lowerequal(a, b, size);
}
static bool chunk_result;
static unsigned chunk_size;
static unsigned int chunk_size;
static void
cmp_chunks1(void *va, void *vb, unsigned size) {
cmp_chunks1(void *va, void *vb, unsigned int size) {
uint8_t *a = va, *b = vb;
chunk_result = false;
@@ -150,7 +150,7 @@ cmp_chunks1(void *va, void *vb, unsigned size) {
}
static void
cmp_chunks8(void *va, void *vb, unsigned size) {
cmp_chunks8(void *va, void *vb, unsigned int size) {
uint8_t *a = va, *b = vb;
while (size >= chunk_size) {
@@ -169,7 +169,7 @@ diff:
}
static void
cmp_oldchunks(void *va, void *vb, unsigned size) {
cmp_oldchunks(void *va, void *vb, unsigned int size) {
uint8_t *a = va, *b = vb;
while (size >= chunk_size) {

View File

@@ -112,7 +112,7 @@ verify_active_counters(dns_rdatastatstype_t which, uint64_t value, void *arg) {
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_ANCIENT) ? "~" : " ",
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_STALE) ? "#" : " ",
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_NXDOMAIN) ? "X" : " ",
type, (unsigned)value);
type, (unsigned int)value);
#endif /* if debug */
if ((attributes & DNS_RDATASTATSTYPE_ATTR_ANCIENT) == 0 &&
(attributes & DNS_RDATASTATSTYPE_ATTR_STALE) == 0)
@@ -143,7 +143,7 @@ verify_stale_counters(dns_rdatastatstype_t which, uint64_t value, void *arg) {
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_ANCIENT) ? "~" : " ",
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_STALE) ? "#" : " ",
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_NXDOMAIN) ? "X" : " ",
type, (unsigned)value);
type, (unsigned int)value);
#endif /* if debug */
if ((attributes & DNS_RDATASTATSTYPE_ATTR_STALE) != 0) {
assert_int_equal(value, 1);
@@ -172,7 +172,7 @@ verify_ancient_counters(dns_rdatastatstype_t which, uint64_t value, void *arg) {
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_ANCIENT) ? "~" : " ",
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_STALE) ? "#" : " ",
ATTRIBUTE_SET(DNS_RDATASTATSTYPE_ATTR_NXDOMAIN) ? "X" : " ",
type, (unsigned)value);
type, (unsigned int)value);
#endif /* if debug */
if ((attributes & DNS_RDATASTATSTYPE_ATTR_ANCIENT) != 0) {
assert_int_equal(value, 1);

View File

@@ -207,7 +207,7 @@ printmessage(dns_message_t *msg) {
}
static void
render(isc_buffer_t *buf, unsigned flags, dns_tsigkey_t *key,
render(isc_buffer_t *buf, unsigned int flags, dns_tsigkey_t *key,
isc_buffer_t **tsigin, isc_buffer_t **tsigout, dst_context_t *tsigctx) {
dns_message_t *msg = NULL;
dns_compress_t cctx;

View File

@@ -111,13 +111,13 @@ ISC_RUN_TEST_IMPL(lowerequal) {
for (size_t n = 0; n < ARRAY_SIZE(same); n++) {
const uint8_t *a = (void *)same[n][0];
const uint8_t *b = (void *)same[n][1];
unsigned len = (unsigned)strlen(same[n][0]);
unsigned int len = (unsigned int)strlen(same[n][0]);
assert_true(isc_ascii_lowerequal(a, b, len));
}
for (size_t n = 0; n < ARRAY_SIZE(diff); n++) {
const uint8_t *a = (void *)diff[n].a;
const uint8_t *b = (void *)diff[n].b;
unsigned len = (unsigned)strlen(diff[n].a);
unsigned int len = (unsigned int)strlen(diff[n].a);
assert_true(!isc_ascii_lowerequal(a, b, len));
}
}
@@ -126,13 +126,13 @@ ISC_RUN_TEST_IMPL(lowercmp) {
for (size_t n = 0; n < ARRAY_SIZE(same); n++) {
const uint8_t *a = (void *)same[n][0];
const uint8_t *b = (void *)same[n][1];
unsigned len = (unsigned)strlen(same[n][0]);
unsigned int len = (unsigned int)strlen(same[n][0]);
assert_true(isc_ascii_lowercmp(a, b, len) == 0);
}
for (size_t n = 0; n < ARRAY_SIZE(diff); n++) {
const uint8_t *a = (void *)diff[n].a;
const uint8_t *b = (void *)diff[n].b;
unsigned len = (unsigned)strlen(diff[n].a);
unsigned int len = (unsigned int)strlen(diff[n].a);
assert_true(isc_ascii_lowercmp(a, b, len) == diff[n].cmp);
}
}

View File

@@ -377,7 +377,7 @@ static isc_quota_t *
init_listener_quota(size_t nthreads) {
isc_quota_t *quotap = NULL;
if (atomic_load(&check_listener_quota)) {
unsigned max_quota = ISC_MAX(nthreads / 2, 1);
unsigned int max_quota = ISC_MAX(nthreads / 2, 1);
isc_quota_max(&listener_quota, max_quota);
quotap = &listener_quota;
}

View File

@@ -574,7 +574,7 @@ isc_quota_t *
tcp_listener_init_quota(size_t nthreads) {
isc_quota_t *quotap = NULL;
if (atomic_load(&check_listener_quota)) {
unsigned max_quota = ISC_MAX(nthreads / 2, 1);
unsigned int max_quota = ISC_MAX(nthreads / 2, 1);
isc_quota_max(&listener_quota, max_quota);
quotap = &listener_quota;
}