Skip to content

Commit 43e8c75

Browse files
committed
apply clang-format
1 parent be2ceff commit 43e8c75

File tree

10 files changed

+155
-152
lines changed

10 files changed

+155
-152
lines changed

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);
@@ -1528,9 +1528,10 @@ int wh_Client_KeyExportDma(whClientContext* c, uint16_t keyId,
15281528
#if defined(WOLFHSM_CFG_CLIENT_TIMEOUT)
15291529
static uint64_t wh_timeval_to_64(const wh_timeval* tv)
15301530
{
1531-
if (tv == NULL) return 0;
1532-
return (uint64_t)tv->tv_sec * WH_BASE_TIMEOUT_UNIT
1533-
+ (uint64_t)((tv->tv_usec * WH_BASE_TIMEOUT_UNIT) / 1000000ULL);
1531+
if (tv == NULL)
1532+
return 0;
1533+
return (uint64_t)tv->tv_sec * WH_BASE_TIMEOUT_UNIT +
1534+
(uint64_t)((tv->tv_usec * WH_BASE_TIMEOUT_UNIT) / 1000000ULL);
15341535
}
15351536
/* Start Timeout */
15361537
int wh_Client_TimeoutStart(whClientContext* c)
@@ -1578,8 +1579,7 @@ int wh_Client_TimeoutCheck(whClientContext* c)
15781579

15791580
/* check timeout by user cb if defined */
15801581
if (c->timeout.cb.CheckTimeout != NULL) {
1581-
return c->timeout.cb.CheckTimeout(
1582-
&c->timeout.start_time, timeout_);
1582+
return c->timeout.cb.CheckTimeout(&c->timeout.start_time, timeout_);
15831583
}
15841584

15851585
/* Otherwise compute elapsed using user-provided GetCurrentTime */
@@ -1592,8 +1592,7 @@ int wh_Client_TimeoutCheck(whClientContext* c)
15921592
return WH_ERROR_OK;
15931593
}
15941594

1595-
int wh_Client_TimeoutRegisterCb(whClientContext* client,
1596-
whClientTimeOutCb* cb)
1595+
int wh_Client_TimeoutRegisterCb(whClientContext* client, whClientTimeOutCb* cb)
15971596
{
15981597
/* No NULL check for cb, since it is optional and always NULL checked before
15991598
* it is called */
@@ -1602,23 +1601,22 @@ int wh_Client_TimeoutRegisterCb(whClientContext* client,
16021601
}
16031602

16041603
client->timeout.cb.GetCurrentTime = cb->GetCurrentTime;
1605-
client->timeout.cb.CheckTimeout = cb->CheckTimeout;
1604+
client->timeout.cb.CheckTimeout = cb->CheckTimeout;
16061605

16071606
return WH_ERROR_OK;
16081607
}
16091608

1610-
int wh_Client_TimeoutSet(whClientContext* client,
1611-
wh_timeval* timeout_val)
1609+
int wh_Client_TimeoutSet(whClientContext* client, wh_timeval* timeout_val)
16121610
{
16131611
if (NULL == client) {
16141612
return WH_ERROR_BADARGS;
16151613
}
16161614

16171615
if (timeout_val != NULL) {
16181616
client->timeout.timeout_enabled = 1;
1619-
memcpy(&client->timeout.timeout_val, timeout_val,
1620-
sizeof(wh_timeval));
1621-
} else {
1617+
memcpy(&client->timeout.timeout_val, timeout_val, sizeof(wh_timeval));
1618+
}
1619+
else {
16221620
client->timeout.timeout_enabled = 0;
16231621
memset(&client->timeout.timeout_val, 0, sizeof(wh_timeval));
16241622
}

src/wh_client_crypto.c

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

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

188188
int ret = WH_ERROR_OK;
@@ -202,7 +202,8 @@ static int _SendRecieveWithTimeout(whClientContext *ctx,
202202
int chk = wh_Client_TimeoutCheck(ctx);
203203
if (chk == WH_ERROR_TIMEOUT) {
204204
return WH_ERROR_TIMEOUT;
205-
} else if (chk < 0 && chk != WH_ERROR_OK) {
205+
}
206+
else if (chk < 0 && chk != WH_ERROR_OK) {
206207
return chk;
207208
}
208209
}
@@ -262,8 +263,8 @@ int wh_Client_RngGenerate(whClientContext* ctx, uint8_t* out, uint32_t size)
262263
/* Send request and get response with Timeout */
263264
if (ret == 0) {
264265
do {
265-
ret = _SendRecieveWithTimeout(ctx, &group, &action,
266-
req_len, &res_len, dataPtr);
266+
ret = _SendRecieveWithTimeout(ctx, &group, &action, req_len,
267+
&res_len, dataPtr);
267268
} while (ret == WH_ERROR_NOTREADY);
268269
}
269270
if (ret == WH_ERROR_OK) {
@@ -443,9 +444,8 @@ int wh_Client_AesCtr(whClientContext* ctx, Aes* aes, int enc, const uint8_t* in,
443444
/* Response packet */
444445
uint16_t res_len = 0;
445446
do {
446-
ret =
447-
_SendRecieveWithTimeout(ctx, &group, &action,
448-
req_len, &res_len, dataPtr);
447+
ret = _SendRecieveWithTimeout(ctx, &group, &action, req_len,
448+
&res_len, dataPtr);
449449
} while (ret == WH_ERROR_NOTREADY);
450450

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

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

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

797794
if (ret == WH_ERROR_OK) {
@@ -988,9 +985,8 @@ int wh_Client_AesGcmDma(whClientContext* ctx, Aes* aes, int enc,
988985
if (ret == 0) {
989986
uint16_t resLen = 0;
990987
do {
991-
ret =
992-
_SendRecieveWithTimeout(ctx, &group, &action,
993-
reqLen, &resLen, dataPtr);
988+
ret = _SendRecieveWithTimeout(ctx, &group, &action, reqLen, &resLen,
989+
dataPtr);
994990
} while (ret == WH_ERROR_NOTREADY);
995991

996992
if (ret == WH_ERROR_OK) {

test/config/wolfhsm_cfg.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@
6262
#define WOLFHSM_CFG_SERVER_NVM_FLASH_LOG
6363

6464
/* Enable client crypto timeout feature for testing */
65-
#if defined(WOLFHSM_CFG_CLIENT_TIMEOUT) && \
66-
defined(WOLFHSM_CFG_TEST_POSIX)
65+
#if defined(WOLFHSM_CFG_CLIENT_TIMEOUT) && defined(WOLFHSM_CFG_TEST_POSIX)
6766
#define WOLFHSM_CFG_CLIENT_TIMEOUT_USEC (500000) /* 500ms */
6867
#define WOLFHSM_CFG_TEST_CLIENT_TIMEOUT
6968
#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)