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

@@ -33,13 +33,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* session [-m module] [-s $slot] [-n count] */
/*! \file */
#include <stdio.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -51,8 +50,8 @@
#include <isc/types.h>
#include <isc/util.h>
#include <pk11/pk11.h>
#include <pk11/internal.h>
#include <pk11/pk11.h>
#ifndef HAVE_CLOCK_GETTIME
@@ -62,37 +61,39 @@
#define CLOCK_REALTIME 0
#endif
static int clock_gettime(int32_t id, struct timespec *tp);
static int
clock_gettime(int32_t id, struct timespec *tp);
static int
clock_gettime(int32_t id, struct timespec *tp)
{
struct timeval tv;
int result;
int result;
UNUSED(id);
result = gettimeofday(&tv, NULL);
if (result == 0) {
tp->tv_sec = tv.tv_sec;
tp->tv_nsec = (long) tv.tv_usec * 1000;
tp->tv_nsec = (long)tv.tv_usec * 1000;
}
return (result);
}
#endif
int
main(int argc, char *argv[]) {
CK_RV rv;
CK_SLOT_ID slot = 0;
main(int argc, char *argv[])
{
CK_RV rv;
CK_SLOT_ID slot = 0;
CK_SESSION_HANDLE *hSession;
char *lib_name = NULL;
int error = 0;
int c, errflg = 0;
unsigned int count = 1000;
unsigned int i;
struct timespec starttime;
struct timespec endtime;
char * lib_name = NULL;
int error = 0;
int c, errflg = 0;
unsigned int count = 1000;
unsigned int i;
struct timespec starttime;
struct timespec endtime;
while ((c = isc_commandline_parse(argc, argv, ":m:s:n:")) != -1) {
switch (c) {
@@ -106,8 +107,7 @@ main(int argc, char *argv[]) {
count = atoi(isc_commandline_argument);
break;
case ':':
fprintf(stderr,
"Option -%c requires an operand\n",
fprintf(stderr, "Option -%c requires an operand\n",
isc_commandline_option);
errflg++;
break;
@@ -121,14 +121,13 @@ main(int argc, char *argv[]) {
if (errflg) {
fprintf(stderr, "Usage:\n");
fprintf(stderr,
"\tsession [-m module] [-s slot] [-n count]\n");
fprintf(stderr, "\tsession [-m module] [-s slot] [-n count]\n");
exit(1);
}
/* Allocate sessions */
hSession = (CK_SESSION_HANDLE *)
malloc(count * sizeof(CK_SESSION_HANDLE));
hSession =
(CK_SESSION_HANDLE *)malloc(count * sizeof(CK_SESSION_HANDLE));
if (hSession == NULL) {
perror("malloc");
exit(1);
@@ -143,8 +142,7 @@ main(int argc, char *argv[]) {
rv = pkcs_C_Initialize(NULL_PTR);
if (rv != CKR_OK) {
if (rv == 0xfe)
fprintf(stderr,
"Can't load or link module \"%s\"\n",
fprintf(stderr, "Can't load or link module \"%s\"\n",
pk11_get_lib_name());
else
fprintf(stderr, "C_Initialize: Error = 0x%.8lX\n", rv);
@@ -160,11 +158,10 @@ main(int argc, char *argv[]) {
/* loop */
for (i = 0; i < count; i++) {
/* Open sessions */
rv = pkcs_C_OpenSession(slot, CKF_SERIAL_SESSION,
NULL_PTR, NULL_PTR, &hSession[i]);
rv = pkcs_C_OpenSession(slot, CKF_SERIAL_SESSION, NULL_PTR,
NULL_PTR, &hSession[i]);
if (rv != CKR_OK) {
fprintf(stderr,
"C_OpenSession[%u]: Error = 0x%.8lX\n",
fprintf(stderr, "C_OpenSession[%u]: Error = 0x%.8lX\n",
i, rv);
error = 1;
if (i == 0)
@@ -184,12 +181,12 @@ main(int argc, char *argv[]) {
endtime.tv_sec -= 1;
endtime.tv_nsec += 1000000000;
}
printf("%u sessions in %ld.%09lds\n", i,
endtime.tv_sec, endtime.tv_nsec);
printf("%u sessions in %ld.%09lds\n", i, endtime.tv_sec,
endtime.tv_nsec);
if (i > 0)
printf("%g sessions/s\n",
i / ((double) endtime.tv_sec +
(double) endtime.tv_nsec / 1000000000.));
i / ((double)endtime.tv_sec +
(double)endtime.tv_nsec / 1000000000.));
for (i = 0; i < count; i++) {
/* Close sessions */
@@ -197,14 +194,13 @@ main(int argc, char *argv[]) {
continue;
rv = pkcs_C_CloseSession(hSession[i]);
if ((rv != CKR_OK) && !errflg) {
fprintf(stderr,
"C_CloseSession[%u]: Error = 0x%.8lX\n",
fprintf(stderr, "C_CloseSession[%u]: Error = 0x%.8lX\n",
i, rv);
errflg = 1;
}
}
exit_program:
exit_program:
free(hSession);
rv = pkcs_C_Finalize(NULL_PTR);