Merge branch '46-just-use-clang-format-to-reformat-sources' into 'master'

Reformat source code with clang-format

Closes #46

See merge request isc-projects/bind9!2156

(cherry picked from commit 7099e79a9b)

4c3b063e Import Linux kernel .clang-format with small modifications
f50b1e06 Use clang-format to reformat the source files
11341c76 Update the definition files for Windows
df6c1f76 Remove tkey_test (which is no-op anyway)
This commit is contained in:
Ondřej Surý
2020-02-12 14:33:32 +00:00
parent dbe15330fe
commit c931d8e417
974 changed files with 75952 additions and 74434 deletions

View File

@@ -11,12 +11,11 @@
#if HAVE_CMOCKA
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <sched.h> /* IWYU pragma: keep */
#include <setjmp.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include <unistd.h>
@@ -28,17 +27,16 @@
#include <isc/stdio.h>
#include <isc/string.h>
#include <isc/util.h>
#include <isc/util.h>
#include "../dst_internal.h"
#include "dnstest.h"
#include <dst/dst.h>
#include <dst/result.h>
#include "../dst_internal.h"
#include "dnstest.h"
static int
_setup(void **state) {
_setup(void **state)
{
isc_result_t result;
UNUSED(state);
@@ -50,7 +48,8 @@ _setup(void **state) {
}
static int
_teardown(void **state) {
_teardown(void **state)
{
UNUSED(state);
dns_test_end();
@@ -60,13 +59,14 @@ _teardown(void **state) {
/* Read sig in file at path to buf. Check signature ineffability */
static isc_result_t
sig_fromfile(const char *path, isc_buffer_t *buf) {
isc_result_t result;
size_t rval, len;
FILE *fp = NULL;
sig_fromfile(const char *path, isc_buffer_t *buf)
{
isc_result_t result;
size_t rval, len;
FILE * fp = NULL;
unsigned char val;
char *p, *data;
off_t size;
char * p, *data;
off_t size;
result = isc_stdio_open(path, "rb", &fp);
assert_int_equal(result, ISC_R_SUCCESS);
@@ -95,7 +95,7 @@ sig_fromfile(const char *path, isc_buffer_t *buf) {
--len;
continue;
} else if (len < 2U) {
goto err;
goto err;
}
if (('0' <= *p) && (*p <= '9')) {
val = *p - '0';
@@ -123,7 +123,7 @@ sig_fromfile(const char *path, isc_buffer_t *buf) {
result = ISC_R_SUCCESS;
err:
err:
isc_mem_put(dt_mctx, data, size + 1);
return (result);
}
@@ -132,20 +132,20 @@ static void
check_sig(const char *datapath, const char *sigpath, const char *keyname,
dns_keytag_t id, dns_secalg_t alg, int type, bool expect)
{
isc_result_t result;
size_t rval, len;
FILE *fp;
dst_key_t *key = NULL;
unsigned char sig[512];
unsigned char *p;
unsigned char *data;
off_t size;
isc_buffer_t b;
isc_buffer_t databuf, sigbuf;
isc_region_t datareg, sigreg;
isc_result_t result;
size_t rval, len;
FILE * fp;
dst_key_t * key = NULL;
unsigned char sig[512];
unsigned char * p;
unsigned char * data;
off_t size;
isc_buffer_t b;
isc_buffer_t databuf, sigbuf;
isc_region_t datareg, sigreg;
dns_fixedname_t fname;
dns_name_t *name;
dst_context_t *ctx = NULL;
dns_name_t * name;
dst_context_t * ctx = NULL;
/*
* Read data from file in a form usable by dst_verify.
@@ -177,8 +177,8 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
isc_buffer_add(&b, strlen(keyname));
result = dns_name_fromtext(name, &b, dns_rootname, 0, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
result = dst_key_fromfile(name, id, alg, type, "testdata/dst",
dt_mctx, &key);
result = dst_key_fromfile(name, id, alg, type, "testdata/dst", dt_mctx,
&key);
assert_int_equal(result, ISC_R_SUCCESS);
isc_buffer_init(&databuf, data, (unsigned int)size);
@@ -209,14 +209,14 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
if (expect && result != ISC_R_SUCCESS) {
isc_result_t result2;
result2 = dst_context_create(key, dt_mctx, DNS_LOGCATEGORY_GENERAL,
false, 0, &ctx);
result2 = dst_context_create(
key, dt_mctx, DNS_LOGCATEGORY_GENERAL, false, 0, &ctx);
assert_int_equal(result2, ISC_R_SUCCESS);
result2 = dst_context_adddata(ctx, &datareg);
assert_int_equal(result2, ISC_R_SUCCESS);
char sigbuf2[4096];
char sigbuf2[4096];
isc_buffer_t sigb;
isc_buffer_init(&sigb, sigbuf2, sizeof(sigbuf2));
@@ -226,7 +226,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
isc_region_t r;
isc_buffer_usedregion(&sigb, &r);
char hexbuf[4096] = { 0 };
char hexbuf[4096] = { 0 };
isc_buffer_t hb;
isc_buffer_init(&hb, hexbuf, sizeof(hexbuf));
@@ -248,59 +248,46 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
}
static void
sig_test(void **state) {
sig_test(void **state)
{
UNUSED(state);
struct {
const char *datapath;
const char *sigpath;
const char *keyname;
const char * datapath;
const char * sigpath;
const char * keyname;
dns_keytag_t keyid;
dns_secalg_t alg;
bool expect;
bool expect;
} testcases[] = {
{
"testdata/dst/test1.data",
"testdata/dst/test1.ecdsa256sig",
"test.", 49130, DST_ALG_ECDSA256, true
},
{
"testdata/dst/test1.data",
"testdata/dst/test1.rsasha256sig",
"test.", 11349, DST_ALG_RSASHA256, true
},
{
/* wrong sig */
"testdata/dst/test1.data",
"testdata/dst/test1.ecdsa256sig",
"test.", 11349, DST_ALG_RSASHA256, false
},
{
/* wrong data */
"testdata/dst/test2.data",
"testdata/dst/test1.ecdsa256sig",
"test.", 49130, DST_ALG_ECDSA256, false
},
{ "testdata/dst/test1.data", "testdata/dst/test1.ecdsa256sig",
"test.", 49130, DST_ALG_ECDSA256, true },
{ "testdata/dst/test1.data", "testdata/dst/test1.rsasha256sig",
"test.", 11349, DST_ALG_RSASHA256, true },
{ /* wrong sig */
"testdata/dst/test1.data", "testdata/dst/test1.ecdsa256sig",
"test.", 11349, DST_ALG_RSASHA256, false },
{ /* wrong data */
"testdata/dst/test2.data", "testdata/dst/test1.ecdsa256sig",
"test.", 49130, DST_ALG_ECDSA256, false },
};
unsigned int i;
for (i = 0; i < (sizeof(testcases)/sizeof(testcases[0])); i++) {
for (i = 0; i < (sizeof(testcases) / sizeof(testcases[0])); i++) {
if (!dst_algorithm_supported(testcases[i].alg)) {
continue;
}
check_sig(testcases[i].datapath,
testcases[i].sigpath,
testcases[i].keyname,
testcases[i].keyid,
testcases[i].alg,
DST_TYPE_PRIVATE|DST_TYPE_PUBLIC,
check_sig(testcases[i].datapath, testcases[i].sigpath,
testcases[i].keyname, testcases[i].keyid,
testcases[i].alg, DST_TYPE_PRIVATE | DST_TYPE_PUBLIC,
testcases[i].expect);
}
}
int
main(void) {
main(void)
{
const struct CMUnitTest tests[] = {
cmocka_unit_test_setup_teardown(sig_test, _setup, _teardown),
};
@@ -313,7 +300,8 @@ main(void) {
#include <stdio.h>
int
main(void) {
main(void)
{
printf("1..0 # Skipped: cmocka not available\n");
return (0);
}