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.
*/
/* create [-m module] [-s $slot] [-p pin] [-t] [-n count] */
/*! \file */
#include <stdio.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -62,56 +61,57 @@
#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
CK_BYTE buf[1024];
char label[16];
char label[16];
static CK_BBOOL truevalue = TRUE;
static CK_BBOOL falsevalue = FALSE;
int
main(int argc, char *argv[]) {
isc_result_t result;
CK_RV rv;
CK_SLOT_ID slot = 0;
main(int argc, char *argv[])
{
isc_result_t result;
CK_RV rv;
CK_SLOT_ID slot = 0;
CK_SESSION_HANDLE hSession = CK_INVALID_HANDLE;
CK_OBJECT_HANDLE *hKey;
CK_OBJECT_CLASS kClass = CKO_DATA;
CK_ULONG len = sizeof(buf);
CK_ATTRIBUTE kTemplate[] =
{
{ CKA_CLASS, &kClass, (CK_ULONG) sizeof(kClass) },
{ CKA_TOKEN, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
{ CKA_PRIVATE, &falsevalue, (CK_ULONG) sizeof(falsevalue) },
{ CKA_LABEL, (CK_BYTE_PTR) label, (CK_ULONG) sizeof(label) },
{ CKA_VALUE, buf, (CK_ULONG) sizeof(buf) }
CK_OBJECT_CLASS kClass = CKO_DATA;
CK_ULONG len = sizeof(buf);
CK_ATTRIBUTE kTemplate[] = {
{ CKA_CLASS, &kClass, (CK_ULONG)sizeof(kClass) },
{ CKA_TOKEN, &falsevalue, (CK_ULONG)sizeof(falsevalue) },
{ CKA_PRIVATE, &falsevalue, (CK_ULONG)sizeof(falsevalue) },
{ CKA_LABEL, (CK_BYTE_PTR)label, (CK_ULONG)sizeof(label) },
{ CKA_VALUE, buf, (CK_ULONG)sizeof(buf) }
};
pk11_context_t pctx;
char *lib_name = NULL;
char *pin = NULL;
int error = 0;
int c, errflg = 0;
int ontoken = 0;
unsigned int count = 1000;
unsigned int i;
pk11_context_t pctx;
char * lib_name = NULL;
char * pin = NULL;
int error = 0;
int c, errflg = 0;
int ontoken = 0;
unsigned int count = 1000;
unsigned int i;
struct timespec starttime;
struct timespec endtime;
@@ -133,8 +133,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;
@@ -148,16 +147,15 @@ main(int argc, char *argv[]) {
if (errflg) {
fprintf(stderr, "Usage:\n");
fprintf(stderr,
"\tcreate [-m module] [-s slot] [-t] [-n count]\n");
fprintf(stderr, "\tcreate [-m module] [-s slot] [-t] [-n "
"count]\n");
exit(1);
}
pk11_result_register();
/* Allocate hanles */
hKey = (CK_SESSION_HANDLE *)
malloc(count * sizeof(CK_SESSION_HANDLE));
hKey = (CK_SESSION_HANDLE *)malloc(count * sizeof(CK_SESSION_HANDLE));
if (hKey == NULL) {
perror("malloc");
exit(1);
@@ -172,10 +170,9 @@ main(int argc, char *argv[]) {
if (pin == NULL)
pin = getpass("Enter Pin: ");
result = pk11_get_session(&pctx, OP_ANY, true, true,
true, (const char *) pin, slot);
if ((result != ISC_R_SUCCESS) &&
(result != PK11_R_NORANDOMSERVICE) &&
result = pk11_get_session(&pctx, OP_ANY, true, true, true,
(const char *)pin, slot);
if ((result != ISC_R_SUCCESS) && (result != PK11_R_NORANDOMSERVICE) &&
(result != PK11_R_NODIGESTSERVICE) &&
(result != PK11_R_NOAESSERVICE)) {
fprintf(stderr, "Error initializing PKCS#11: %s\n",
@@ -204,12 +201,11 @@ main(int argc, char *argv[]) {
}
for (i = 0; i < count; i++) {
(void) snprintf(label, sizeof(label), "obj%u", i);
(void)snprintf(label, sizeof(label), "obj%u", i);
kTemplate[3].ulValueLen = strlen(label);
rv = pkcs_C_CreateObject(hSession, kTemplate, 5, &hKey[i]);
if (rv != CKR_OK) {
fprintf(stderr,
"C_CreateObject[%u]: Error = 0x%.8lX\n",
fprintf(stderr, "C_CreateObject[%u]: Error = 0x%.8lX\n",
i, rv);
error = 1;
if (i == 0)
@@ -229,14 +225,15 @@ main(int argc, char *argv[]) {
endtime.tv_sec -= 1;
endtime.tv_nsec += 1000000000;
}
printf("%u created objects in %ld.%09lds\n", i,
endtime.tv_sec, endtime.tv_nsec);
printf("%u created objects in %ld.%09lds\n", i, endtime.tv_sec,
endtime.tv_nsec);
if (i > 0)
printf("%g created objects/s\n",
1024 * i / ((double) endtime.tv_sec +
(double) endtime.tv_nsec / 1000000000.));
1024 * i /
((double)endtime.tv_sec +
(double)endtime.tv_nsec / 1000000000.));
exit_objects:
exit_objects:
for (i = 0; i < count; i++) {
/* Destroy objects */
if (hKey[i] == CK_INVALID_HANDLE)
@@ -244,15 +241,15 @@ main(int argc, char *argv[]) {
rv = pkcs_C_DestroyObject(hSession, hKey[i]);
if ((rv != CKR_OK) && !errflg) {
fprintf(stderr,
"C_DestroyObject[%u]: Error = 0x%.8lX\n",
i, rv);
"C_DestroyObject[%u]: Error = 0x%.8lX\n", i,
rv);
errflg = 1;
}
}
free(hKey);
pk11_return_session(&pctx);
(void) pk11_finalize();
(void)pk11_finalize();
exit(error);
}