Skip to content

Commit bff8c8f

Browse files
committed
apply clang-format
1 parent 3df413b commit bff8c8f

10 files changed

Lines changed: 155 additions & 152 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);
@@ -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
@@ -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)