Merge branch 'each-style-tweak' into 'master'

adjust clang-format options to get closer to ISC style

See merge request isc-projects/bind9!3061

(cherry picked from commit d3b49b6675)

0255a974 revise .clang-format and add a C formatting script in util
e851ed0b apply the modified style
This commit is contained in:
Ondřej Surý
2020-02-14 05:35:17 +00:00
parent c646c20e79
commit cdef20bb66
672 changed files with 36044 additions and 42228 deletions

View File

@@ -59,10 +59,8 @@ static double MAXLOG = 7.09782712893383996843E2;
static double big = 4.503599627370496e15;
static double biginv = 2.22044604925031308085e-16;
static double
igamc(double a, double x);
static double
igam(double a, double x);
static double igamc(double a, double x);
static double igam(double a, double x);
/* Set to true (or use -v option) for verbose output */
static bool verbose = false;
@@ -77,8 +75,7 @@ typedef enum {
} isc_random_func;
static int
_setup(void **state)
{
_setup(void **state) {
isc_result_t result;
UNUSED(state);
@@ -90,8 +87,7 @@ _setup(void **state)
}
static int
_teardown(void **state)
{
_teardown(void **state) {
UNUSED(state);
isc_test_end();
@@ -100,8 +96,7 @@ _teardown(void **state)
}
static double
igamc(double a, double x)
{
igamc(double a, double x) {
double ans, ax, c, yc, r, t, y, z;
double pk, pkm1, pkm2, qk, qkm1, qkm2;
@@ -162,8 +157,7 @@ igamc(double a, double x)
}
static double
igam(double a, double x)
{
igam(double a, double x) {
double ans, ax, c, r;
if ((x <= 0) || (a <= 0)) {
@@ -196,13 +190,12 @@ igam(double a, double x)
return (ans * ax / a);
}
static int8_t scounts_table[65536];
static int8_t scounts_table[65536];
static uint8_t bitcounts_table[65536];
static int8_t
scount_calculate(uint16_t n)
{
int i;
scount_calculate(uint16_t n) {
int i;
int8_t sc;
sc = 0;
@@ -223,9 +216,8 @@ scount_calculate(uint16_t n)
}
static uint8_t
bitcount_calculate(uint16_t n)
{
int i;
bitcount_calculate(uint16_t n) {
int i;
uint8_t bc;
bc = 0;
@@ -244,8 +236,7 @@ bitcount_calculate(uint16_t n)
}
static void
tables_init(void)
{
tables_init(void) {
uint32_t i;
for (i = 0; i < 65536; i++) {
@@ -262,12 +253,11 @@ tables_init(void)
* This function destroys (modifies) the data passed in bits.
*/
static uint32_t
matrix_binaryrank(uint32_t *bits, size_t rows, size_t cols)
{
size_t i, j, k;
matrix_binaryrank(uint32_t *bits, size_t rows, size_t cols) {
size_t i, j, k;
unsigned int rt = 0;
uint32_t rank = 0;
uint32_t tmp;
uint32_t rank = 0;
uint32_t tmp;
for (k = 0; k < rows; k++) {
i = k;
@@ -310,18 +300,17 @@ matrix_binaryrank(uint32_t *bits, size_t rows, size_t cols)
}
static void
random_test(pvalue_func_t *func, isc_random_func test_func)
{
random_test(pvalue_func_t *func, isc_random_func test_func) {
uint32_t m;
uint32_t j;
uint32_t histogram[11] = { 0 };
uint32_t passed;
double proportion;
double p_hat;
double lower_confidence, higher_confidence;
double chi_square;
double p_value_t;
double alpha;
double proportion;
double p_hat;
double lower_confidence, higher_confidence;
double chi_square;
double p_value_t;
double alpha;
tables_init();
@@ -329,27 +318,27 @@ random_test(pvalue_func_t *func, isc_random_func test_func)
passed = 0;
for (j = 0; j < m; j++) {
uint32_t i;
uint32_t values[REPS];
uint32_t i;
uint32_t values[REPS];
uint16_t *uniform_values;
double p_value;
double p_value;
switch (test_func) {
case ISC_RANDOM8:
for (i = 0; i < (sizeof(values) / sizeof(*values));
i++) {
for (i = 0; i < (sizeof(values) / sizeof(*values)); i++)
{
values[i] = isc_random8();
}
break;
case ISC_RANDOM16:
for (i = 0; i < (sizeof(values) / sizeof(*values));
i++) {
for (i = 0; i < (sizeof(values) / sizeof(*values)); i++)
{
values[i] = isc_random16();
}
break;
case ISC_RANDOM32:
for (i = 0; i < (sizeof(values) / sizeof(*values));
i++) {
for (i = 0; i < (sizeof(values) / sizeof(*values)); i++)
{
values[i] = isc_random32();
}
break;
@@ -447,13 +436,12 @@ random_test(pvalue_func_t *func, isc_random_func test_func)
* RANDOM test suite.
*/
static double
monobit(isc_mem_t *mctx, uint16_t *values, size_t length)
{
size_t i;
int32_t scount;
monobit(isc_mem_t *mctx, uint16_t *values, size_t length) {
size_t i;
int32_t scount;
uint32_t numbits;
double s_obs;
double p_value;
double s_obs;
double p_value;
UNUSED(mctx);
@@ -481,21 +469,20 @@ monobit(isc_mem_t *mctx, uint16_t *values, size_t length)
* This is the runs test taken from the NIST SP 800-22 RNG test suite.
*/
static double
runs(isc_mem_t *mctx, uint16_t *values, size_t length)
{
size_t i;
runs(isc_mem_t *mctx, uint16_t *values, size_t length) {
size_t i;
uint32_t bcount;
uint32_t numbits;
double pi;
double tau;
double pi;
double tau;
uint32_t j;
uint32_t b;
uint8_t bit_this;
uint8_t bit_prev;
uint8_t bit_this;
uint8_t bit_prev;
uint32_t v_obs;
double numer;
double denom;
double p_value;
double numer;
double denom;
double p_value;
UNUSED(mctx);
@@ -561,16 +548,15 @@ runs(isc_mem_t *mctx, uint16_t *values, size_t length)
* test suite.
*/
static double
blockfrequency(isc_mem_t *mctx, uint16_t *values, size_t length)
{
blockfrequency(isc_mem_t *mctx, uint16_t *values, size_t length) {
uint32_t i;
uint32_t numbits;
uint32_t mbits;
uint32_t mwords;
uint32_t numblocks;
double * pi;
double chi_square;
double p_value;
double *pi;
double chi_square;
double p_value;
numbits = length * sizeof(*values) * 8;
mbits = 32000;
@@ -627,21 +613,20 @@ blockfrequency(isc_mem_t *mctx, uint16_t *values, size_t length)
* test suite.
*/
static double
binarymatrixrank(isc_mem_t *mctx, uint16_t *values, size_t length)
{
binarymatrixrank(isc_mem_t *mctx, uint16_t *values, size_t length) {
uint32_t i;
size_t matrix_m;
size_t matrix_q;
size_t matrix_m;
size_t matrix_q;
uint32_t num_matrices;
size_t numbits;
size_t numbits;
uint32_t fm_0;
uint32_t fm_1;
uint32_t fm_rest;
double term1;
double term2;
double term3;
double chi_square;
double p_value;
double term1;
double term2;
double term3;
double chi_square;
double p_value;
UNUSED(mctx);
@@ -664,11 +649,11 @@ binarymatrixrank(isc_mem_t *mctx, uint16_t *values, size_t length)
* takes up uint32_t array of size 32.
*/
uint32_t bits[32];
int j;
int j;
uint32_t rank;
for (j = 0; j < 32; j++) {
size_t idx;
size_t idx;
uint32_t r1;
uint32_t r2;
@@ -720,8 +705,7 @@ binarymatrixrank(isc_mem_t *mctx, uint16_t *values, size_t length)
/* Monobit test for the RANDOM */
static void
isc_random32_monobit(void **state)
{
isc_random32_monobit(void **state) {
UNUSED(state);
random_test(monobit, ISC_RANDOM32);
@@ -729,8 +713,7 @@ isc_random32_monobit(void **state)
/* Runs test for the RANDOM */
static void
isc_random32_runs(void **state)
{
isc_random32_runs(void **state) {
UNUSED(state);
random_test(runs, ISC_RANDOM32);
@@ -738,8 +721,7 @@ isc_random32_runs(void **state)
/* Block frequency test for the RANDOM */
static void
isc_random32_blockfrequency(void **state)
{
isc_random32_blockfrequency(void **state) {
UNUSED(state);
random_test(blockfrequency, ISC_RANDOM32);
@@ -747,8 +729,7 @@ isc_random32_blockfrequency(void **state)
/* Binary matrix rank test for the RANDOM */
static void
isc_random32_binarymatrixrank(void **state)
{
isc_random32_binarymatrixrank(void **state) {
UNUSED(state);
random_test(binarymatrixrank, ISC_RANDOM32);
@@ -760,8 +741,7 @@ isc_random32_binarymatrixrank(void **state)
/* Monobit test for the RANDOM */
static void
isc_random_bytes_monobit(void **state)
{
isc_random_bytes_monobit(void **state) {
UNUSED(state);
random_test(monobit, ISC_RANDOM_BYTES);
@@ -769,8 +749,7 @@ isc_random_bytes_monobit(void **state)
/* Runs test for the RANDOM */
static void
isc_random_bytes_runs(void **state)
{
isc_random_bytes_runs(void **state) {
UNUSED(state);
random_test(runs, ISC_RANDOM_BYTES);
@@ -778,8 +757,7 @@ isc_random_bytes_runs(void **state)
/* Block frequency test for the RANDOM */
static void
isc_random_bytes_blockfrequency(void **state)
{
isc_random_bytes_blockfrequency(void **state) {
UNUSED(state);
random_test(blockfrequency, ISC_RANDOM_BYTES);
@@ -787,8 +765,7 @@ isc_random_bytes_blockfrequency(void **state)
/* Binary matrix rank test for the RANDOM */
static void
isc_random_bytes_binarymatrixrank(void **state)
{
isc_random_bytes_binarymatrixrank(void **state) {
UNUSED(state);
random_test(binarymatrixrank, ISC_RANDOM_BYTES);
@@ -800,8 +777,7 @@ isc_random_bytes_binarymatrixrank(void **state)
/* Monobit test for the RANDOM */
static void
isc_random_uniform_monobit(void **state)
{
isc_random_uniform_monobit(void **state) {
UNUSED(state);
random_test(monobit, ISC_RANDOM_UNIFORM);
@@ -809,8 +785,7 @@ isc_random_uniform_monobit(void **state)
/* Runs test for the RANDOM */
static void
isc_random_uniform_runs(void **state)
{
isc_random_uniform_runs(void **state) {
UNUSED(state);
random_test(runs, ISC_RANDOM_UNIFORM);
@@ -818,8 +793,7 @@ isc_random_uniform_runs(void **state)
/* Block frequency test for the RANDOM */
static void
isc_random_uniform_blockfrequency(void **state)
{
isc_random_uniform_blockfrequency(void **state) {
UNUSED(state);
random_test(blockfrequency, ISC_RANDOM_UNIFORM);
@@ -827,8 +801,7 @@ isc_random_uniform_blockfrequency(void **state)
/* Binary matrix rank test for the RANDOM */
static void
isc_random_uniform_binarymatrixrank(void **state)
{
isc_random_uniform_binarymatrixrank(void **state) {
UNUSED(state);
random_test(binarymatrixrank, ISC_RANDOM_UNIFORM);
@@ -838,8 +811,7 @@ isc_random_uniform_binarymatrixrank(void **state)
/* Monobit test for the RANDOM */
static void
isc_nonce_bytes_monobit(void **state)
{
isc_nonce_bytes_monobit(void **state) {
UNUSED(state);
random_test(monobit, ISC_NONCE_BYTES);
@@ -847,8 +819,7 @@ isc_nonce_bytes_monobit(void **state)
/* Runs test for the RANDOM */
static void
isc_nonce_bytes_runs(void **state)
{
isc_nonce_bytes_runs(void **state) {
UNUSED(state);
random_test(runs, ISC_NONCE_BYTES);
@@ -856,8 +827,7 @@ isc_nonce_bytes_runs(void **state)
/* Block frequency test for the RANDOM */
static void
isc_nonce_bytes_blockfrequency(void **state)
{
isc_nonce_bytes_blockfrequency(void **state) {
UNUSED(state);
random_test(blockfrequency, ISC_NONCE_BYTES);
@@ -865,16 +835,14 @@ isc_nonce_bytes_blockfrequency(void **state)
/* Binary matrix rank test for the RANDOM */
static void
isc_nonce_bytes_binarymatrixrank(void **state)
{
isc_nonce_bytes_binarymatrixrank(void **state) {
UNUSED(state);
random_test(binarymatrixrank, ISC_NONCE_BYTES);
}
int
main(int argc, char **argv)
{
main(int argc, char **argv) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(isc_random32_monobit),
cmocka_unit_test(isc_random32_runs),
@@ -913,8 +881,7 @@ main(int argc, char **argv)
#include <stdio.h>
int
main(void)
{
main(void) {
printf("1..0 # Skipped: cmocka not available\n");
return (0);
}