Skip to content

Commit 8aa3235

Browse files
committed
apply clang-format
1 parent fa97ca8 commit 8aa3235

10 files changed

Lines changed: 153 additions & 150 deletions

File tree

src/wh_client.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ int wh_Client_Init(whClientContext* c, const whClientConfig* config)
8282
#endif
8383
#if defined(WOLFHSM_CFG_CLIENT_TIMEOUT)
8484
if (NULL != config->timeoutConfig) {
85-
c->timeout.timeout_val = config->timeoutConfig->timeout_val;
85+
c->timeout.timeout_val = config->timeoutConfig->timeout_val;
8686
c->timeout.timeout_enabled = config->timeoutConfig->timeout_enabled;
87-
c->timeout.start_time = 0;
87+
c->timeout.start_time = 0;
8888
}
8989
#endif
9090
rc = wh_CommClient_Init(c->comm, config->comm);
@@ -1525,9 +1525,10 @@ int wh_Client_KeyExportDma(whClientContext* c, uint16_t keyId,
15251525
#if defined(WOLFHSM_CFG_CLIENT_TIMEOUT)
15261526
static uint64_t wh_timeval_to_64(const wh_timeval* tv)
15271527
{
1528-
if (tv == NULL) return 0;
1529-
return (uint64_t)tv->tv_sec * WH_BASE_TIMEOUT_UNIT
1530-
+ (uint64_t)((tv->tv_usec * WH_BASE_TIMEOUT_UNIT) / 1000000ULL);
1528+
if (tv == NULL)
1529+
return 0;
1530+
return (uint64_t)tv->tv_sec * WH_BASE_TIMEOUT_UNIT +
1531+
(uint64_t)((tv->tv_usec * WH_BASE_TIMEOUT_UNIT) / 1000000ULL);
15311532
}
15321533
/* Start Timeout */
15331534
int wh_Client_TimeoutStart(whClientContext* c)
@@ -1575,8 +1576,7 @@ int wh_Client_TimeoutCheck(whClientContext* c)
15751576

15761577
/* check timeout by user cb if defined */
15771578
if (c->timeout.cb.CheckTimeout != NULL) {
1578-
return c->timeout.cb.CheckTimeout(
1579-
&c->timeout.start_time, timeout_);
1579+
return c->timeout.cb.CheckTimeout(&c->timeout.start_time, timeout_);
15801580
}
15811581

15821582
/* Otherwise compute elapsed using user-provided GetCurrentTime */
@@ -1589,8 +1589,7 @@ int wh_Client_TimeoutCheck(whClientContext* c)
15891589
return WH_ERROR_OK;
15901590
}
15911591

1592-
int wh_Client_TimeoutRegisterCb(whClientContext* client,
1593-
whClientTimeOutCb* cb)
1592+
int wh_Client_TimeoutRegisterCb(whClientContext* client, whClientTimeOutCb* cb)
15941593
{
15951594
/* No NULL check for cb, since it is optional and always NULL checked before
15961595
* it is called */
@@ -1599,23 +1598,22 @@ int wh_Client_TimeoutRegisterCb(whClientContext* client,
15991598
}
16001599

16011600
client->timeout.cb.GetCurrentTime = cb->GetCurrentTime;
1602-
client->timeout.cb.CheckTimeout = cb->CheckTimeout;
1601+
client->timeout.cb.CheckTimeout = cb->CheckTimeout;
16031602

16041603
return WH_ERROR_OK;
16051604
}
16061605

1607-
int wh_Client_TimeoutSet(whClientContext* client,
1608-
wh_timeval* timeout_val)
1606+
int wh_Client_TimeoutSet(whClientContext* client, wh_timeval* timeout_val)
16091607
{
16101608
if (NULL == client) {
16111609
return WH_ERROR_BADARGS;
16121610
}
16131611

16141612
if (timeout_val != NULL) {
16151613
client->timeout.timeout_enabled = 1;
1616-
memcpy(&client->timeout.timeout_val, timeout_val,
1617-
sizeof(wh_timeval));
1618-
} else {
1614+
memcpy(&client->timeout.timeout_val, timeout_val, sizeof(wh_timeval));
1615+
}
1616+
else {
16191617
client->timeout.timeout_enabled = 0;
16201618
memset(&client->timeout.timeout_val, 0, sizeof(wh_timeval));
16211619
}

src/wh_client_crypto.c

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ static int _getCryptoResponse(uint8_t* respBuf, uint16_t type,
181181

182182
return header->rc;
183183
}
184-
static int _SendRecieveWithTimeout(whClientContext *ctx,
185-
uint16_t *group, uint16_t *action, uint16_t req_len,
186-
uint16_t *res_len, void* data)
184+
static int _SendRecieveWithTimeout(whClientContext* ctx, uint16_t* group,
185+
uint16_t* action, uint16_t req_len,
186+
uint16_t* res_len, void* data)
187187
{
188188

189189
int ret = WH_ERROR_OK;
@@ -203,7 +203,8 @@ static int _SendRecieveWithTimeout(whClientContext *ctx,
203203
int chk = wh_Client_TimeoutCheck(ctx);
204204
if (chk == WH_ERROR_TIMEOUT) {
205205
return WH_ERROR_TIMEOUT;
206-
} else if (chk < 0 && chk != WH_ERROR_OK) {
206+
}
207+
else if (chk < 0 && chk != WH_ERROR_OK) {
207208
return chk;
208209
}
209210
}
@@ -263,8 +264,8 @@ int wh_Client_RngGenerate(whClientContext* ctx, uint8_t* out, uint32_t size)
263264
/* Send request and get response with Timeout */
264265
if (ret == 0) {
265266
do {
266-
ret = _SendRecieveWithTimeout(ctx, &group, &action,
267-
req_len, &res_len, dataPtr);
267+
ret = _SendRecieveWithTimeout(ctx, &group, &action, req_len,
268+
&res_len, dataPtr);
268269
} while (ret == WH_ERROR_NOTREADY);
269270
}
270271
if (ret == WH_ERROR_OK) {
@@ -444,9 +445,8 @@ int wh_Client_AesCtr(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
444445
/* Response packet */
445446
uint16_t res_len = 0;
446447
do {
447-
ret =
448-
_SendRecieveWithTimeout(ctx, &group, &action,
449-
req_len, &res_len, dataPtr);
448+
ret = _SendRecieveWithTimeout(ctx, &group, &action, req_len,
449+
&res_len, dataPtr);
450450
} while (ret == WH_ERROR_NOTREADY);
451451

452452
if (ret == WH_ERROR_OK) {
@@ -558,9 +558,8 @@ int wh_Client_AesEcb(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
558558
/* Response packet */
559559
uint16_t res_len = 0;
560560
do {
561-
ret =
562-
_SendRecieveWithTimeout(ctx, &group, &action,
563-
req_len, &res_len, dataPtr);
561+
ret = _SendRecieveWithTimeout(ctx, &group, &action, req_len,
562+
&res_len, dataPtr);
564563
} while (ret == WH_ERROR_NOTREADY);
565564

566565
if (ret == WH_ERROR_OK) {
@@ -668,9 +667,8 @@ int wh_Client_AesCbc(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
668667
/* Response packet */
669668
uint16_t res_len = 0;
670669
do {
671-
ret =
672-
_SendRecieveWithTimeout(ctx, &group, &action,
673-
req_len, &res_len, dataPtr);
670+
ret = _SendRecieveWithTimeout(ctx, &group, &action, req_len,
671+
&res_len, dataPtr);
674672
} while (ret == WH_ERROR_NOTREADY);
675673

676674
if (ret == WH_ERROR_OK) {
@@ -790,9 +788,8 @@ int wh_Client_AesGcm(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
790788
if (ret == 0) {
791789
uint16_t res_len = 0;
792790
do {
793-
ret =
794-
_SendRecieveWithTimeout(ctx, &group, &action,
795-
req_len, &res_len, dataPtr);
791+
ret = _SendRecieveWithTimeout(ctx, &group, &action, req_len,
792+
&res_len, dataPtr);
796793
} while (ret == WH_ERROR_NOTREADY);
797794

798795
if (ret == WH_ERROR_OK) {
@@ -989,9 +986,8 @@ int wh_Client_AesGcmDma(whClientContext* ctx, Aes* aes, int enc,
989986
if (ret == 0) {
990987
uint16_t resLen = 0;
991988
do {
992-
ret =
993-
_SendRecieveWithTimeout(ctx, &group, &action,
994-
reqLen, &resLen, dataPtr);
989+
ret = _SendRecieveWithTimeout(ctx, &group, &action, reqLen, &resLen,
990+
dataPtr);
995991
} while (ret == WH_ERROR_NOTREADY);
996992

997993
if (ret == WH_ERROR_OK) {

test/config/wolfhsm_cfg.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@
6969
#define WOLFHSM_CFG_SERVER_NVM_FLASH_LOG
7070

7171
/* Enable client crypto timeout feature for testing */
72-
#if defined(WOLFHSM_CFG_CLIENT_TIMEOUT) && \
73-
defined(WOLFHSM_CFG_TEST_POSIX)
72+
#if defined(WOLFHSM_CFG_CLIENT_TIMEOUT) && defined(WOLFHSM_CFG_TEST_POSIX)
7473
#define WOLFHSM_CFG_CLIENT_TIMEOUT_USEC (500000) /* 500ms */
7574
#define WOLFHSM_CFG_TEST_CLIENT_TIMEOUT
7675
#endif /* WOLFHSM_CFG_TEST_CLIENT_TIMEOUT */

test/wh_test_common.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,7 @@ uint64_t whTest_GetCurrentTime(int reset)
107107
return 0;
108108

109109
/* Convert to milliseconds number. */
110-
return (uint64_t)ts.tv_sec * 1000ULL +
111-
(uint64_t)ts.tv_nsec / 1000000ULL;
110+
return (uint64_t)ts.tv_sec * 1000ULL + (uint64_t)ts.tv_nsec / 1000000ULL;
112111
#else
113112
struct timeval tv;
114113
if (gettimeofday(&tv, 0) < 0)

test/wh_test_common.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ int whTest_NvmCfgBackend(whTestNvmBackendType type,
147147
uint64_t whTest_GetCurrentTime(int reset);
148148
int whTest_CheckTimeout(uint64_t* start_time, uint64_t timeout_val);
149149

150-
#define WH_CLIENT_TIMEOUT_CB \
151-
{ \
152-
.GetCurrentTime = whTest_GetCurrentTime, \
153-
.CheckTimeout = whTest_CheckTimeout, \
150+
#define WH_CLIENT_TIMEOUT_CB \
151+
{ \
152+
.GetCurrentTime = whTest_GetCurrentTime, \
153+
.CheckTimeout = whTest_CheckTimeout, \
154154
}
155155

156156
#endif /* WH_TEST_COMMON_H_ */

0 commit comments

Comments
 (0)