Skip to content

Commit de16a6a

Browse files
committed
- cleanups, formatting, test housekeeping fixes surrounding macro
protection - TSAN options to fail-fast in CI on error
1 parent a58ca2b commit de16a6a

11 files changed

Lines changed: 132 additions & 190 deletions

.github/workflows/build-and-test-stress.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Test Stress
1+
name: Multi-threaded Stress Test
22

33
on:
44
push:

src/wh_lock.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ int wh_Lock_Init(whLock* lock, const whLockConfig* config)
4444

4545
/* Allow NULL config for single-threaded mode (no-op locking) */
4646
if ((config == NULL) || (config->cb == NULL)) {
47-
lock->cb = NULL;
48-
lock->context = NULL;
47+
lock->cb = NULL;
48+
lock->context = NULL;
4949
lock->initialized = 1; /* Mark as initialized even in no-op mode */
5050
return WH_ERROR_OK;
5151
}

src/wh_server_cert.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,9 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
419419
rc = wh_Server_CertAddTrusted(
420420
server, req.id, req.access, req.flags, req.label,
421421
WH_NVM_LABEL_LEN, cert_data, req.cert_len);
422+
422423
(void)WH_SERVER_NVM_UNLOCK(server);
423-
}
424+
} /* WH_SERVER_NVM_LOCK() */
424425
resp.rc = rc;
425426

426427
/* Convert the response struct */
@@ -441,8 +442,9 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
441442
rc = WH_SERVER_NVM_LOCK(server);
442443
if (rc == WH_ERROR_OK) {
443444
rc = wh_Server_CertEraseTrusted(server, req.id);
445+
444446
(void)WH_SERVER_NVM_UNLOCK(server);
445-
}
447+
} /* WH_SERVER_NVM_LOCK() */
446448
resp.rc = rc;
447449

448450
/* Convert the response struct */
@@ -488,8 +490,9 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
488490
resp.cert_len = cert_len;
489491
}
490492
}
493+
491494
(void)WH_SERVER_NVM_UNLOCK(server);
492-
}
495+
} /* WH_SERVER_NVM_LOCK() */
493496
resp.rc = rc;
494497

495498
/* Convert the response struct */
@@ -529,8 +532,9 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
529532
/* Propagate the keyId back to the client with flags
530533
* preserved */
531534
resp.keyId = wh_KeyId_TranslateToClient(keyId);
535+
532536
(void)WH_SERVER_NVM_UNLOCK(server);
533-
}
537+
} /* WH_SERVER_NVM_LOCK() */
534538
resp.rc = rc;
535539
}
536540

@@ -570,7 +574,7 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
570574
WH_NVM_LABEL_LEN, cert_data, req.cert_len);
571575

572576
(void)WH_SERVER_NVM_UNLOCK(server);
573-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
577+
} /* WH_SERVER_NVM_LOCK() */
574578
}
575579
if (resp.rc == WH_ERROR_OK) {
576580
/* Post-process client address */
@@ -620,12 +624,12 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
620624
/* Clamp cert_len to actual stored length */
621625
cert_len = req.cert_len;
622626
resp.rc = wh_Server_CertReadTrusted(
623-
server, req.id, cert_data, &cert_len);
627+
server, req.id, cert_data, &cert_len);
624628
}
625629
}
626630

627631
(void)WH_SERVER_NVM_UNLOCK(server);
628-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
632+
} /* WH_SERVER_NVM_LOCK() */
629633
}
630634
if (resp.rc == WH_ERROR_OK) {
631635
/* Post-process client address */
@@ -677,7 +681,7 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
677681
resp.keyId = wh_KeyId_TranslateToClient(keyId);
678682

679683
(void)WH_SERVER_NVM_UNLOCK(server);
680-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
684+
} /* WH_SERVER_NVM_LOCK() */
681685
}
682686
if (resp.rc == WH_ERROR_OK) {
683687
/* Post-process client address */
@@ -712,7 +716,7 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
712716
req.trustedRootNvmId);
713717

714718
(void)WH_SERVER_NVM_UNLOCK(server);
715-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
719+
} /* WH_SERVER_NVM_LOCK() */
716720

717721
/* Signature confirmation error is not an error for the server, so
718722
* propagate this error to the client in the response, otherwise
@@ -760,7 +764,7 @@ int wh_Server_HandleCertRequest(whServerContext* server, uint16_t magic,
760764
server, cert_data, req.cert_len, req.trustedRootNvmId);
761765

762766
(void)WH_SERVER_NVM_UNLOCK(server);
763-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
767+
} /* WH_SERVER_NVM_LOCK() */
764768

765769
/* Signature confirmation error is not an error for the server,
766770
* so propagate this error to the client in the response,

src/wh_server_counter.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int wh_Server_HandleCounter(whServerContext* server, uint16_t magic,
8484
}
8585

8686
(void)WH_SERVER_NVM_UNLOCK(server);
87-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
87+
} /* WH_SERVER_NVM_LOCK() */
8888
resp.rc = ret;
8989

9090
(void)wh_MessageCounter_TranslateInitResponse(
@@ -140,7 +140,7 @@ int wh_Server_HandleCounter(whServerContext* server, uint16_t magic,
140140
}
141141

142142
(void)WH_SERVER_NVM_UNLOCK(server);
143-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
143+
} /* WH_SERVER_NVM_LOCK() */
144144
resp.rc = ret;
145145

146146
(void)wh_MessageCounter_TranslateIncrementResponse(
@@ -181,7 +181,7 @@ int wh_Server_HandleCounter(whServerContext* server, uint16_t magic,
181181
}
182182

183183
(void)WH_SERVER_NVM_UNLOCK(server);
184-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
184+
} /* WH_SERVER_NVM_LOCK() */
185185
resp.rc = ret;
186186

187187
(void)wh_MessageCounter_TranslateReadResponse(
@@ -216,7 +216,7 @@ int wh_Server_HandleCounter(whServerContext* server, uint16_t magic,
216216
ret = wh_Nvm_DestroyObjects(server->nvm, 1, &counterId);
217217

218218
(void)WH_SERVER_NVM_UNLOCK(server);
219-
} /* WH_SERVER_NVM_LOCK() == WH_ERROR_OK */
219+
} /* WH_SERVER_NVM_LOCK() */
220220
resp.rc = ret;
221221

222222
(void)wh_MessageCounter_TranslateDestroyResponse(

0 commit comments

Comments
 (0)