Skip to content

Commit 3655e5c

Browse files
committed
Clang-format crypto affinity feature
1 parent c9821ae commit 3655e5c

File tree

7 files changed

+140
-140
lines changed

7 files changed

+140
-140
lines changed

src/wh_client.c

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -424,36 +424,34 @@ int wh_Client_SetCryptoAffinityRequest(whClientContext* c, uint32_t affinity)
424424

425425
msg.affinity = affinity;
426426

427-
return wh_Client_SendRequest(c,
428-
WH_MESSAGE_GROUP_COMM,
429-
WH_MESSAGE_COMM_ACTION_SET_CRYPTO_AFFINITY,
430-
sizeof(msg), &msg);
427+
return wh_Client_SendRequest(c, WH_MESSAGE_GROUP_COMM,
428+
WH_MESSAGE_COMM_ACTION_SET_CRYPTO_AFFINITY,
429+
sizeof(msg), &msg);
431430
}
432431

433432
int wh_Client_SetCryptoAffinityResponse(whClientContext* c, int32_t* out_rc,
434-
uint32_t* out_affinity)
433+
uint32_t* out_affinity)
435434
{
436-
int rc = 0;
437-
whMessageCommSetCryptoAffinityResponse msg = {0};
438-
uint16_t resp_group = 0;
439-
uint16_t resp_action = 0;
440-
uint16_t resp_size = 0;
435+
int rc = 0;
436+
whMessageCommSetCryptoAffinityResponse msg = {0};
437+
uint16_t resp_group = 0;
438+
uint16_t resp_action = 0;
439+
uint16_t resp_size = 0;
441440

442441
if (c == NULL) {
443442
return WH_ERROR_BADARGS;
444443
}
445444

446-
rc = wh_Client_RecvResponse(c,
447-
&resp_group, &resp_action,
448-
&resp_size, &msg);
445+
rc = wh_Client_RecvResponse(c, &resp_group, &resp_action, &resp_size, &msg);
449446
if (rc == 0) {
450447
/* Validate response */
451-
if ( (resp_group != WH_MESSAGE_GROUP_COMM) ||
452-
(resp_action != WH_MESSAGE_COMM_ACTION_SET_CRYPTO_AFFINITY) ||
453-
(resp_size != sizeof(msg)) ){
448+
if ((resp_group != WH_MESSAGE_GROUP_COMM) ||
449+
(resp_action != WH_MESSAGE_COMM_ACTION_SET_CRYPTO_AFFINITY) ||
450+
(resp_size != sizeof(msg))) {
454451
/* Invalid message */
455452
rc = WH_ERROR_ABORTED;
456-
} else {
453+
}
454+
else {
457455
/* Valid message */
458456
if (out_rc != NULL) {
459457
*out_rc = msg.rc;
@@ -467,7 +465,7 @@ int wh_Client_SetCryptoAffinityResponse(whClientContext* c, int32_t* out_rc,
467465
}
468466

469467
int wh_Client_SetCryptoAffinity(whClientContext* c, uint32_t affinity,
470-
int32_t* out_rc, uint32_t* out_affinity)
468+
int32_t* out_rc, uint32_t* out_affinity)
471469
{
472470
int rc = 0;
473471
if (c == NULL) {

src/wh_message_comm.c

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,28 +83,25 @@ int wh_MessageComm_TranslateInfoResponse(uint16_t magic,
8383
return 0;
8484
}
8585

86-
int wh_MessageComm_TranslateSetCryptoAffinityRequest(uint16_t magic,
87-
const whMessageCommSetCryptoAffinityRequest* src,
88-
whMessageCommSetCryptoAffinityRequest* dest)
86+
int wh_MessageComm_TranslateSetCryptoAffinityRequest(
87+
uint16_t magic, const whMessageCommSetCryptoAffinityRequest* src,
88+
whMessageCommSetCryptoAffinityRequest* dest)
8989
{
90-
if ( (src == NULL) ||
91-
(dest == NULL) ) {
90+
if ((src == NULL) || (dest == NULL)) {
9291
return WH_ERROR_BADARGS;
9392
}
9493
WH_T32(magic, dest, src, affinity);
9594
return 0;
9695
}
9796

98-
int wh_MessageComm_TranslateSetCryptoAffinityResponse(uint16_t magic,
99-
const whMessageCommSetCryptoAffinityResponse* src,
100-
whMessageCommSetCryptoAffinityResponse* dest)
97+
int wh_MessageComm_TranslateSetCryptoAffinityResponse(
98+
uint16_t magic, const whMessageCommSetCryptoAffinityResponse* src,
99+
whMessageCommSetCryptoAffinityResponse* dest)
101100
{
102-
if ( (src == NULL) ||
103-
(dest == NULL) ) {
101+
if ((src == NULL) || (dest == NULL)) {
104102
return WH_ERROR_BADARGS;
105103
}
106104
WH_T32(magic, dest, src, rc);
107105
WH_T32(magic, dest, src, affinity);
108106
return 0;
109107
}
110-

src/wh_server.c

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -268,52 +268,54 @@ static int _wh_Server_HandleCommRequest(whServerContext* server,
268268
*out_resp_size = sizeof(resp);
269269
}; break;
270270

271-
case WH_MESSAGE_COMM_ACTION_SET_CRYPTO_AFFINITY:
272-
{
273-
whMessageCommSetCryptoAffinityRequest req = {0};
271+
case WH_MESSAGE_COMM_ACTION_SET_CRYPTO_AFFINITY: {
272+
whMessageCommSetCryptoAffinityRequest req = {0};
274273
whMessageCommSetCryptoAffinityResponse resp = {0};
275274

276-
wh_MessageComm_TranslateSetCryptoAffinityRequest(magic,
277-
(const whMessageCommSetCryptoAffinityRequest*)req_packet,
278-
&req);
275+
wh_MessageComm_TranslateSetCryptoAffinityRequest(
276+
magic, (const whMessageCommSetCryptoAffinityRequest*)req_packet,
277+
&req);
279278

280279
#ifndef WOLFHSM_CFG_NO_CRYPTO
281280
if (server->crypto == NULL) {
282-
resp.rc = WH_ERROR_ABORTED;
281+
resp.rc = WH_ERROR_ABORTED;
283282
resp.affinity = WH_CRYPTO_AFFINITY_SW;
284-
} else {
283+
}
284+
else {
285285
switch (req.affinity) {
286-
case WH_CRYPTO_AFFINITY_SW:
287-
server->crypto->devId = INVALID_DEVID;
288-
resp.rc = WH_ERROR_OK;
289-
break;
290-
case WH_CRYPTO_AFFINITY_HW:
286+
case WH_CRYPTO_AFFINITY_SW:
287+
server->crypto->devId = INVALID_DEVID;
288+
resp.rc = WH_ERROR_OK;
289+
break;
290+
case WH_CRYPTO_AFFINITY_HW:
291291
#ifdef WOLF_CRYPTO_CB
292-
if (server->crypto->configDevId != INVALID_DEVID) {
293-
server->crypto->devId = server->crypto->configDevId;
294-
resp.rc = WH_ERROR_OK;
295-
} else {
296-
resp.rc = WH_ERROR_BADCONFIG;
297-
}
298-
break;
292+
if (server->crypto->configDevId != INVALID_DEVID) {
293+
server->crypto->devId = server->crypto->configDevId;
294+
resp.rc = WH_ERROR_OK;
295+
}
296+
else {
297+
resp.rc = WH_ERROR_BADCONFIG;
298+
}
299+
break;
299300
#else
300-
resp.rc = WH_ERROR_NOTIMPL;
301-
break;
301+
resp.rc = WH_ERROR_NOTIMPL;
302+
break;
302303
#endif
303-
default:
304-
resp.rc = WH_ERROR_BADARGS;
305-
break;
304+
default:
305+
resp.rc = WH_ERROR_BADARGS;
306+
break;
306307
}
307-
resp.affinity = (server->crypto->devId == INVALID_DEVID) ?
308-
WH_CRYPTO_AFFINITY_SW : WH_CRYPTO_AFFINITY_HW;
308+
resp.affinity = (server->crypto->devId == INVALID_DEVID)
309+
? WH_CRYPTO_AFFINITY_SW
310+
: WH_CRYPTO_AFFINITY_HW;
309311
}
310312
#else
311-
resp.rc = WH_ERROR_NOTIMPL;
313+
resp.rc = WH_ERROR_NOTIMPL;
312314
resp.affinity = WH_CRYPTO_AFFINITY_SW;
313315
#endif
314316

315-
wh_MessageComm_TranslateSetCryptoAffinityResponse(magic,
316-
&resp, (whMessageCommSetCryptoAffinityResponse*)resp_packet);
317+
wh_MessageComm_TranslateSetCryptoAffinityResponse(
318+
magic, &resp, (whMessageCommSetCryptoAffinityResponse*)resp_packet);
317319
*out_resp_size = sizeof(resp);
318320
}; break;
319321

0 commit comments

Comments
 (0)