Skip to content

Commit 7372ce8

Browse files
committed
widetree: fix clang-format error
1 parent 5062107 commit 7372ce8

13 files changed

+108
-109
lines changed

src/wh_nvm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ int wh_Nvm_DestroyObjects(whNvmContext* context, whNvmId list_count,
192192

193193

194194
int wh_Nvm_Read(whNvmContext* context, whNvmId id, whNvmSize offset,
195-
whNvmSize data_len, uint8_t* data)
195+
whNvmSize data_len, uint8_t* data)
196196
{
197197
if ( (context == NULL) ||
198198
(context->cb == NULL) ) {

src/wh_nvm_flash.c

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ static int nfObject_Program(whNvmFlashContext* context, int partition,
133133
int object_index, uint32_t epoch, whNvmMetadata* meta, uint32_t start,
134134
const uint8_t* data);
135135
static int nfObject_ReadDataBytes(whNvmFlashContext* context, int partition,
136-
int object_index, uint32_t byte_offset, uint32_t byte_count,
137-
uint8_t* out_data);
136+
int object_index, uint32_t byte_offset,
137+
uint32_t byte_count, uint8_t* out_data);
138138
static int nfObject_Copy(whNvmFlashContext* context, int object_index,
139139
int partition, uint32_t *inout_next_object, uint32_t *inout_next_data);
140140

@@ -651,8 +651,8 @@ static int nfObject_Program(whNvmFlashContext* context, int partition,
651651
}
652652

653653
static int nfObject_ReadDataBytes(whNvmFlashContext* context, int partition,
654-
int object_index,
655-
uint32_t byte_offset, uint32_t byte_count, uint8_t* out_data)
654+
int object_index, uint32_t byte_offset,
655+
uint32_t byte_count, uint8_t* out_data)
656656
{
657657
int start = 0;
658658
uint32_t startOffset = 0;
@@ -675,18 +675,16 @@ static int nfObject_ReadDataBytes(whNvmFlashContext* context, int partition,
675675
}
676676

677677
/* Ensure we don't read off the end of the active partition */
678-
if (WH_ERROR_OK != nfPartition_CheckDataRange(context, partition,
679-
startOffset * WHFU_BYTES_PER_UNIT + byte_offset,
680-
byte_count)) {
678+
if (WH_ERROR_OK != nfPartition_CheckDataRange(
679+
context, partition,
680+
startOffset * WHFU_BYTES_PER_UNIT + byte_offset,
681+
byte_count)) {
681682
return WH_ERROR_BADARGS;
682683
}
683684

684685
return wh_FlashUnit_ReadBytes(
685-
context->cb,
686-
context->flash,
687-
startOffset * WHFU_BYTES_PER_UNIT + byte_offset,
688-
byte_count,
689-
out_data);
686+
context->cb, context->flash,
687+
startOffset * WHFU_BYTES_PER_UNIT + byte_offset, byte_count, out_data);
690688
}
691689

692690
static int nfObject_Copy(whNvmFlashContext* context, int object_index,
@@ -727,13 +725,8 @@ static int nfObject_Copy(whNvmFlashContext* context, int object_index,
727725
}
728726

729727
/* Read the data from the old object. */
730-
ret = nfObject_ReadDataBytes(
731-
context,
732-
context->active,
733-
object_index,
734-
data_offset,
735-
this_len,
736-
buffer);
728+
ret = nfObject_ReadDataBytes(context, context->active, object_index,
729+
data_offset, this_len, buffer);
737730
if (ret != 0) return ret;
738731

739732
/* Write the data to the new object. */
@@ -1242,30 +1235,23 @@ int wh_NvmFlash_DestroyObjects(void* c, whNvmId list_count,
12421235
}
12431236

12441237
/* Read the data of the object starting at the byte offset */
1245-
int wh_NvmFlash_Read(void* c, whNvmId id, whNvmSize offset,
1246-
whNvmSize data_len, uint8_t* data)
1238+
int wh_NvmFlash_Read(void* c, whNvmId id, whNvmSize offset, whNvmSize data_len,
1239+
uint8_t* data)
12471240
{
12481241
whNvmFlashContext* context = c;
12491242
int ret = 0;
1250-
int object_index = -1;
1243+
int object_index = -1;
12511244

12521245
if ( (context == NULL) ||
12531246
((data_len > 0) && (data == NULL)) ){
12541247
return WH_ERROR_BADARGS;
12551248
}
12561249

1257-
ret = nfMemDirectory_FindObjectIndexById(
1258-
&context->directory,
1259-
id,
1260-
&object_index);
1250+
ret = nfMemDirectory_FindObjectIndexById(&context->directory, id,
1251+
&object_index);
12611252
if (ret == 0) {
1262-
ret = nfObject_ReadDataBytes(
1263-
context,
1264-
context->active,
1265-
object_index,
1266-
offset,
1267-
data_len,
1268-
data);
1253+
ret = nfObject_ReadDataBytes(context, context->active, object_index,
1254+
offset, data_len, data);
12691255
}
12701256
return ret;
12711257
}

src/wh_nvm_flash_log.c

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@
6565
*
6666
* Alignment consideration:
6767
*
68-
* The implementation assure that writes are aligned to WRITE_GRANULARITY in FLASH memory space.
69-
* The source data passed on the flash layer might not be aligned.
68+
* The implementation assure that writes are aligned to WRITE_GRANULARITY in
69+
* FLASH memory space. The source data passed on the flash layer might not be
70+
* aligned.
7071
*/
7172

7273
#include "wolfhsm/wh_settings.h"
@@ -138,8 +139,8 @@ static whNvmFlashLogMetadata* nfl_ObjNext(whNvmFlashLogContext* ctx,
138139
{
139140
if (obj == NULL || ctx == NULL)
140141
return NULL;
141-
uint8_t* next = (uint8_t*)obj + sizeof(whNvmFlashLogMetadata) +
142-
PAD_SIZE(obj->meta.len);
142+
uint8_t* next =
143+
(uint8_t*)obj + sizeof(whNvmFlashLogMetadata) + PAD_SIZE(obj->meta.len);
143144
if (next >= ctx->directory.data + ctx->directory.header.size)
144145
return NULL;
145146
return (whNvmFlashLogMetadata*)next;
@@ -189,10 +190,10 @@ static int nfl_PartitionCommit(whNvmFlashLogContext* ctx, uint32_t partition)
189190
if (ctx == NULL || partition > 1)
190191
return WH_ERROR_BADARGS;
191192

192-
off = partition * ctx->partition_size;
193+
off = partition * ctx->partition_size;
193194
f_cb = ctx->flash_cb;
194-
ret = f_cb->BlankCheck(ctx->flash_ctx, off,
195-
sizeof(whNvmFlashLogPartitionHeader));
195+
ret = f_cb->BlankCheck(ctx->flash_ctx, off,
196+
sizeof(whNvmFlashLogPartitionHeader));
196197
if (ret != 0)
197198
return ret;
198199

@@ -216,8 +217,8 @@ static int nfl_PartitionChoose(whNvmFlashLogContext* ctx)
216217
return WH_ERROR_BADARGS;
217218

218219
part1_offset = ctx->partition_size;
219-
f_cb = ctx->flash_cb;
220-
ret = f_cb->BlankCheck(ctx->flash_ctx, 0, sizeof(header0));
220+
f_cb = ctx->flash_cb;
221+
ret = f_cb->BlankCheck(ctx->flash_ctx, 0, sizeof(header0));
221222
if (ret != 0 && ret != WH_ERROR_NOTBLANK) {
222223
return ret;
223224
}
@@ -326,7 +327,8 @@ static int nfl_ObjectCount(whNvmFlashLogContext* ctx,
326327
}
327328

328329
if ((uint8_t*)startObj < ctx->directory.data ||
329-
(uint8_t*)startObj >= ctx->directory.data + ctx->directory.header.size) {
330+
(uint8_t*)startObj >=
331+
ctx->directory.data + ctx->directory.header.size) {
330332
return 0;
331333
}
332334

@@ -351,10 +353,9 @@ static int nfl_PartitionRead(whNvmFlashLogContext* ctx)
351353
return WH_ERROR_BADARGS;
352354

353355
f_cb = ctx->flash_cb;
354-
off = ctx->active_partition * ctx->partition_size;
356+
off = ctx->active_partition * ctx->partition_size;
355357

356-
ret = f_cb->Read(ctx->flash_ctx, off,
357-
sizeof(whNvmFlashLogPartitionHeader),
358+
ret = f_cb->Read(ctx->flash_ctx, off, sizeof(whNvmFlashLogPartitionHeader),
358359
(uint8_t*)&ctx->directory.header);
359360
if (ret != 0)
360361
return ret;
@@ -519,7 +520,8 @@ int wh_NvmFlashLog_List(void* c, whNvmAccess access, whNvmFlags flags,
519520
/* list all obects if start_id is WH_NVM_ID_INVALID */
520521
if (start_id == WH_NVM_ID_INVALID) {
521522
next_obj = (whNvmFlashLogMetadata*)ctx->directory.data;
522-
} else {
523+
}
524+
else {
523525
start_obj = nfl_ObjectFindById(ctx, start_id);
524526
if (start_obj != NULL && start_obj->meta.id != WH_NVM_ID_INVALID)
525527
next_obj = nfl_ObjNext(ctx, start_obj);
@@ -603,7 +605,8 @@ int wh_NvmFlashLog_AddObject(void* c, whNvmMetadata* meta, whNvmSize data_len,
603605
int ret;
604606
uint32_t count;
605607

606-
if (ctx == NULL || !ctx->is_initialized || meta == NULL || (data_len > 0 && data == NULL))
608+
if (ctx == NULL || !ctx->is_initialized || meta == NULL ||
609+
(data_len > 0 && data == NULL))
607610
return WH_ERROR_BADARGS;
608611

609612
count = nfl_ObjectCount(ctx, NULL);
@@ -648,7 +651,8 @@ int wh_NvmFlashLog_DestroyObjects(void* c, whNvmId list_count,
648651
int i;
649652
int ret;
650653

651-
if (ctx == NULL || !ctx->is_initialized || (list_count > 0 && id_list == NULL))
654+
if (ctx == NULL || !ctx->is_initialized ||
655+
(list_count > 0 && id_list == NULL))
652656
return WH_ERROR_BADARGS;
653657

654658
if (list_count == 0)

test/wh_test_cert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ int whTest_CertRamSim(NvmTestBackendType nvmType)
614614
}};
615615
const whFlashCb fcb[1] = {WH_FLASH_RAMSIM_CB};
616616

617-
whNvmUnion nvm_setup;
617+
whNvmUnion nvm_setup;
618618
whNvmConfig n_conf[1];
619619
whNvmContext nvm[1] = {{0}};
620620

test/wh_test_clientserver.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,7 @@ int whTest_ClientServerSequential(NvmTestBackendType nvmType)
778778
}};
779779
const whFlashCb fcb[1] = {WH_FLASH_RAMSIM_CB};
780780

781-
whNvmUnion nvm_setup;
781+
whNvmUnion nvm_setup;
782782
whNvmConfig n_conf[1];
783783
whNvmContext nvm[1] = {{0}};
784784

@@ -1801,11 +1801,12 @@ static int wh_ClientServer_MemThreadTest(NvmTestBackendType nvmType)
18011801
}};
18021802
const whFlashCb fcb[1] = {WH_FLASH_RAMSIM_CB};
18031803

1804-
whNvmUnion nvm_setup;
1804+
whNvmUnion nvm_setup;
18051805
whNvmConfig n_conf[1] = {0};
18061806
whNvmContext nvm[1] = {{0}};
18071807

1808-
WH_TEST_RETURN_ON_FAIL(whTest_NvmSetup(nvmType, &nvm_setup, n_conf, fc_conf, fc, fcb));
1808+
WH_TEST_RETURN_ON_FAIL(
1809+
whTest_NvmSetup(nvmType, &nvm_setup, n_conf, fc_conf, fc, fcb));
18091810

18101811
#ifndef WOLFHSM_CFG_NO_CRYPTO
18111812
/* Crypto context */
@@ -1884,9 +1885,9 @@ static int wh_ClientServer_PosixMemMapThreadTest(NvmTestBackendType nvmType)
18841885
}};
18851886
const whFlashCb fcb[1] = {WH_FLASH_RAMSIM_CB};
18861887

1887-
whNvmUnion nvm_setup;
1888+
whNvmUnion nvm_setup;
18881889
whNvmConfig n_conf[1];
1889-
whNvmContext nvm[1] = {{0}};
1890+
whNvmContext nvm[1] = {{0}};
18901891

18911892
WH_TEST_RETURN_ON_FAIL(
18921893
whTest_NvmSetup(nvmType, &nvm_setup, n_conf, fc_conf, fc, fcb));
@@ -1934,23 +1935,27 @@ int whTest_ClientServer(void)
19341935

19351936
#if defined(WOLFHSM_CFG_SERVER_NVM_FLASH_LOG)
19361937
printf("Testing client/server sequential: mem + flash log...\n");
1937-
WH_TEST_ASSERT(0 == whTest_ClientServerSequential(NVM_TEST_BACKEND_FLASH_LOG));
1938+
WH_TEST_ASSERT(0 ==
1939+
whTest_ClientServerSequential(NVM_TEST_BACKEND_FLASH_LOG));
19381940
#endif /* defined(WOLFHSM_CFG_SERVER_NVM_FLASH_LOG) */
19391941

19401942
#if defined(WOLFHSM_CFG_TEST_POSIX)
19411943
printf("Testing client/server: (pthread) mem...\n");
19421944
WH_TEST_ASSERT(0 == wh_ClientServer_MemThreadTest(NVM_TEST_BACKEND_FLASH));
19431945

19441946
printf("Testing client/server: (pthread) POSIX shared memory ...\n");
1945-
WH_TEST_ASSERT(0 == wh_ClientServer_PosixMemMapThreadTest(NVM_TEST_BACKEND_FLASH));
1947+
WH_TEST_ASSERT(
1948+
0 == wh_ClientServer_PosixMemMapThreadTest(NVM_TEST_BACKEND_FLASH));
19461949

19471950
#if defined(WOLFHSM_CFG_SERVER_NVM_FLASH_LOG)
19481951
printf("Testing client/server: (pthread) mem + flash log...\n");
19491952
WH_TEST_ASSERT(0 ==
19501953
wh_ClientServer_MemThreadTest(NVM_TEST_BACKEND_FLASH_LOG));
19511954

1952-
printf("Testing client/server: (pthread) POSIX shared memory + flash log...\n");
1953-
WH_TEST_ASSERT(0 == wh_ClientServer_PosixMemMapThreadTest(NVM_TEST_BACKEND_FLASH_LOG));
1955+
printf("Testing client/server: (pthread) POSIX shared memory + flash "
1956+
"log...\n");
1957+
WH_TEST_ASSERT(
1958+
0 == wh_ClientServer_PosixMemMapThreadTest(NVM_TEST_BACKEND_FLASH_LOG));
19541959
#endif /* defined(WOLFHSM_CFG_SERVER_NVM_FLASH_LOG) */
19551960

19561961
#endif /* defined(WOLFHSM_CFG_TEST_POSIX) */

test/wh_test_common.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,11 @@
3131
/**
3232
* Helper function to configure and select an NVM backend for testing.
3333
*
34-
* @param type The type of NVM backend to configure (see NvmTestBackendType).
34+
* @param type The type of NVM backend to configure (see
35+
* NvmTestBackendType).
3536
* @param nvmSetup Pointer to a union of NVM backend setup structures (output).
36-
* @param nvmCfg Pointer to the NVM configuration structure to populate (output).
37+
* @param nvmCfg Pointer to the NVM configuration structure to populate
38+
* (output).
3739
* @param fCfg Pointer to the RamSim flash configuration structure.
3840
* @param fCtx Pointer to the RamSim flash context structure.
3941
* @param fCb Pointer to the RamSim flash callback structure.

test/wh_test_common.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@
2626
#include <assert.h>
2727
#endif
2828

29-
#include<wolfhsm/wh_nvm.h>
30-
#include<wolfhsm/wh_flash_ramsim.h>
31-
#include<wolfhsm/wh_nvm_flash.h>
32-
#include<wolfhsm/wh_nvm_flash_log.h>
29+
#include <wolfhsm/wh_nvm.h>
30+
#include <wolfhsm/wh_flash_ramsim.h>
31+
#include <wolfhsm/wh_nvm_flash.h>
32+
#include <wolfhsm/wh_nvm_flash_log.h>
3333

3434
#define WH_TEST_FAIL (-1)
3535
#define WH_TEST_SUCCESS (0)
@@ -108,7 +108,6 @@
108108
} while (0)
109109

110110

111-
112111
typedef enum {
113112
NVM_TEST_BACKEND_FLASH = 0,
114113
#if defined(WOLFHSM_CFG_SERVER_NVM_FLASH_LOG)

test/wh_test_crypto.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3658,9 +3658,9 @@ static int wh_ClientServer_MemThreadTest(NvmTestBackendType nvmType)
36583658
}};
36593659
const whFlashCb fcb[1] = {WH_FLASH_RAMSIM_CB};
36603660

3661-
whNvmUnion nvm_setup;
3661+
whNvmUnion nvm_setup;
36623662
whNvmConfig n_conf[1];
3663-
whNvmContext nvm[1] = {{0}};
3663+
whNvmContext nvm[1] = {{0}};
36643664

36653665
WH_TEST_RETURN_ON_FAIL(
36663666
whTest_NvmSetup(nvmType, &nvm_setup, n_conf, fc_conf, fc, fcb));
@@ -3697,11 +3697,13 @@ static int wh_ClientServer_MemThreadTest(NvmTestBackendType nvmType)
36973697
int whTest_Crypto(void)
36983698
{
36993699
printf("Testing crypto: (pthread) mem...\n");
3700-
WH_TEST_RETURN_ON_FAIL(wh_ClientServer_MemThreadTest(NVM_TEST_BACKEND_FLASH));
3700+
WH_TEST_RETURN_ON_FAIL(
3701+
wh_ClientServer_MemThreadTest(NVM_TEST_BACKEND_FLASH));
37013702

37023703
#if defined(WOLFHSM_CFG_SERVER_NVM_FLASH_LOG)
37033704
printf("Testing crypto: (pthread) mem (flash log)...\n");
3704-
WH_TEST_RETURN_ON_FAIL(wh_ClientServer_MemThreadTest(NVM_TEST_BACKEND_FLASH_LOG));
3705+
WH_TEST_RETURN_ON_FAIL(
3706+
wh_ClientServer_MemThreadTest(NVM_TEST_BACKEND_FLASH_LOG));
37053707
#endif
37063708

37073709
return 0;

0 commit comments

Comments
 (0)