Skip to content

Commit 83d85fe

Browse files
authored
Merge pull request #947 from pq-code-package/clang-format-insert-braces
Add and apply "InsertBraces" option for clang-format
2 parents 5cefe9a + 8a9fe83 commit 83d85fe

File tree

15 files changed

+67
-0
lines changed

15 files changed

+67
-0
lines changed

.clang-format

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ IncludeBlocks: Preserve
1616
# Designate CBMC contracts/macros that appear in .h files
1717
# as "attributes" so they don't get increasingly indented line after line
1818
BreakBeforeBraces: Allman
19+
InsertBraces: true
1920
WhitespaceSensitiveMacros: ['__contract__', '__loop__' ]
2021
Macros:
2122
# Make this artifically long to avoid function bodies after short contracts

dev/x86_64/src/rej_uniform_avx2.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,13 @@ unsigned mlk_rej_uniform_avx2(int16_t *MLK_RESTRICT r, const uint8_t *buf)
118118
pos += 3;
119119

120120
if (val0 < MLKEM_Q)
121+
{
121122
r[ctr++] = val0;
123+
}
122124
if (val1 < MLKEM_Q && ctr < MLKEM_N)
125+
{
123126
r[ctr++] = val1;
127+
}
124128
}
125129

126130
return ctr;

examples/bring_your_own_fips202/custom_fips202/tiny_sha3/sha3.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,17 @@ void sha3_keccakf(uint64_t st[25])
5050
{
5151
/* Theta */
5252
for (i = 0; i < 5; i++)
53+
{
5354
bc[i] = st[i] ^ st[i + 5] ^ st[i + 10] ^ st[i + 15] ^ st[i + 20];
55+
}
5456

5557
for (i = 0; i < 5; i++)
5658
{
5759
t = bc[(i + 4) % 5] ^ ROTL64(bc[(i + 1) % 5], 1);
5860
for (j = 0; j < 25; j += 5)
61+
{
5962
st[j + i] ^= t;
63+
}
6064
}
6165

6266
/* Rho Pi */
@@ -73,9 +77,13 @@ void sha3_keccakf(uint64_t st[25])
7377
for (j = 0; j < 25; j += 5)
7478
{
7579
for (i = 0; i < 5; i++)
80+
{
7681
bc[i] = st[j + i];
82+
}
7783
for (i = 0; i < 5; i++)
84+
{
7885
st[j + i] ^= (~bc[(i + 1) % 5]) & bc[(i + 2) % 5];
86+
}
7987
}
8088

8189
/* Iota */
@@ -107,7 +115,9 @@ int sha3_init(sha3_ctx_t *c, int mdlen)
107115
int i;
108116

109117
for (i = 0; i < 25; i++)
118+
{
110119
c->st.q[i] = 0;
120+
}
111121
c->mdlen = mdlen;
112122
c->rsiz = 200 - 2 * mdlen;
113123
c->pt = 0;

examples/bring_your_own_fips202/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ int main(void)
9292
{
9393
size_t i;
9494
for (i = 0; i < sizeof(key_a); i++)
95+
{
9596
printf("%02x", key_a[i]);
97+
}
9698
}
9799
printf("\n");
98100

examples/custom_backend/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,9 @@ int main(void)
9292
{
9393
size_t i;
9494
for (i = 0; i < sizeof(key_a); i++)
95+
{
9596
printf("%02x", key_a[i]);
97+
}
9698
}
9799
printf("\n");
98100

examples/custom_backend/mlkem_native/mlkem/fips202/native/custom/src/sha3.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,17 @@ void tiny_sha3_keccakf(uint64_t st[25])
5656
{
5757
/* Theta */
5858
for (i = 0; i < 5; i++)
59+
{
5960
bc[i] = st[i] ^ st[i + 5] ^ st[i + 10] ^ st[i + 15] ^ st[i + 20];
61+
}
6062

6163
for (i = 0; i < 5; i++)
6264
{
6365
t = bc[(i + 4) % 5] ^ ROTL64(bc[(i + 1) % 5], 1);
6466
for (j = 0; j < 25; j += 5)
67+
{
6568
st[j + i] ^= t;
69+
}
6670
}
6771

6872
/* Rho Pi */
@@ -79,9 +83,13 @@ void tiny_sha3_keccakf(uint64_t st[25])
7983
for (j = 0; j < 25; j += 5)
8084
{
8185
for (i = 0; i < 5; i++)
86+
{
8287
bc[i] = st[j + i];
88+
}
8389
for (i = 0; i < 5; i++)
90+
{
8491
st[j + i] ^= (~bc[(i + 1) % 5]) & bc[(i + 2) % 5];
92+
}
8593
}
8694

8795
/* Iota */
@@ -119,7 +127,9 @@ int tiny_sha3_init(sha3_ctx_t *c, int mdlen)
119127
int i;
120128

121129
for (i = 0; i < 25; i++)
130+
{
122131
c->st.q[i] = 0;
132+
}
123133
c->mdlen = mdlen;
124134
c->rsiz = 200 - 2 * mdlen;
125135
c->pt = 0;

examples/mlkem_native_as_code_package/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ int main(void)
8888
{
8989
size_t i;
9090
for (i = 0; i < sizeof(key_a); i++)
91+
{
9192
printf("%02x", key_a[i]);
93+
}
9294
}
9395
printf("\n");
9496

examples/monolithic_build/main.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ static int test_keys_mlkem(void)
7878
{
7979
size_t i;
8080
for (i = 0; i < sizeof(key_a); i++)
81+
{
8182
printf("%02x", key_a[i]);
83+
}
8284
}
8385
printf("\n");
8486

examples/monolithic_build_multilevel/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ static int test_keys_mlkem512(void)
5858
{
5959
size_t i;
6060
for (i = 0; i < sizeof(key_a); i++)
61+
{
6162
printf("%02x", key_a[i]);
63+
}
6264
}
6365
printf("\n");
6466

@@ -111,7 +113,9 @@ static int test_keys_mlkem768(void)
111113
{
112114
size_t i;
113115
for (i = 0; i < sizeof(key_a); i++)
116+
{
114117
printf("%02x", key_a[i]);
118+
}
115119
}
116120
printf("\n");
117121

@@ -165,7 +169,9 @@ static int test_keys_mlkem1024(void)
165169
{
166170
size_t i;
167171
for (i = 0; i < sizeof(key_a); i++)
172+
{
168173
printf("%02x", key_a[i]);
174+
}
169175
}
170176
printf("\n");
171177

examples/monolithic_build_multilevel_native/main.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ static int test_keys_mlkem512(void)
6262
{
6363
size_t i;
6464
for (i = 0; i < sizeof(key_a); i++)
65+
{
6566
printf("%02x", key_a[i]);
67+
}
6668
}
6769
printf("\n");
6870

@@ -115,7 +117,9 @@ static int test_keys_mlkem768(void)
115117
{
116118
size_t i;
117119
for (i = 0; i < sizeof(key_a); i++)
120+
{
118121
printf("%02x", key_a[i]);
122+
}
119123
}
120124
printf("\n");
121125

@@ -169,7 +173,9 @@ static int test_keys_mlkem1024(void)
169173
{
170174
size_t i;
171175
for (i = 0; i < sizeof(key_a); i++)
176+
{
172177
printf("%02x", key_a[i]);
178+
}
173179
}
174180
printf("\n");
175181

0 commit comments

Comments
 (0)