Skip to content

Commit 6048cab

Browse files
authored
Merge pull request #1238 from pq-code-package/conv-warnings-again
Add explicit signed -> unsigned conversion
2 parents aed837f + e553cbb commit 6048cab

File tree

11 files changed

+13
-18
lines changed

11 files changed

+13
-18
lines changed

examples/basic/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ CFLAGS := \
6060
-Wpointer-arith \
6161
-Wredundant-decls \
6262
-Wconversion \
63+
-Wsign-conversion \
6364
-Wno-long-long \
6465
-Wno-unknown-pragmas \
6566
-Wno-unused-command-line-argument \

examples/basic_deterministic/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ CFLAGS := \
4848
-Wpointer-arith \
4949
-Wredundant-decls \
5050
-Wconversion \
51+
-Wsign-conversion \
5152
-Wno-long-long \
5253
-Wno-unknown-pragmas \
5354
-Wno-unused-command-line-argument \

examples/bring_your_own_fips202/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ CFLAGS := \
6666
-Wpointer-arith \
6767
-Wredundant-decls \
6868
-Wconversion \
69+
-Wsign-conversion \
6970
-Wno-long-long \
7071
-Wno-unknown-pragmas \
7172
-Wno-unused-command-line-argument \

examples/custom_backend/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CFLAGS := \
6363
-Wpointer-arith \
6464
-Wredundant-decls \
6565
-Wconversion \
66+
-Wsign-conversion \
6667
-Wno-long-long \
6768
-Wno-unknown-pragmas \
6869
-Wno-unused-command-line-argument \

examples/monolithic_build/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ CFLAGS := \
6868
-Wpointer-arith \
6969
-Wredundant-decls \
7070
-Wconversion \
71+
-Wsign-conversion \
7172
-Wno-long-long \
7273
-Wno-unknown-pragmas \
7374
-Wno-unused-command-line-argument \

examples/monolithic_build_multilevel_native/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ CFLAGS := \
9696
-Wno-unknown-pragmas \
9797
-Wredundant-decls \
9898
-Wconversion \
99+
-Wsign-conversion \
99100
-Wno-unused-command-line-argument \
100101
-fomit-frame-pointer \
101102
-std=c99 \

examples/monolithic_build_native/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ CFLAGS := \
104104
-Wpointer-arith \
105105
-Wredundant-decls \
106106
-Wconversion \
107+
-Wsign-conversion \
107108
-Wno-long-long \
108109
-Wno-unknown-pragmas \
109110
-Wno-unused-command-line-argument \

examples/multilevel_build/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ CFLAGS := \
8686
-Wpointer-arith \
8787
-Wredundant-decls \
8888
-Wconversion \
89+
-Wsign-conversion \
8990
-Wno-long-long \
9091
-Wno-unknown-pragmas \
9192
-Wno-unused-command-line-argument \

examples/multilevel_build_native/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ CFLAGS := \
6262
-Wpointer-arith \
6363
-Wredundant-decls \
6464
-Wconversion \
65+
-Wsign-conversion \
6566
-Wno-long-long \
6667
-Wno-unknown-pragmas \
6768
-Wno-unused-command-line-argument \

mlkem/src/poly.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,9 @@ __contract__(
102102
/* check-magic: 62209 == unsigned_mod(pow(MLKEM_Q, -1, 2^16), 2^16) */
103103
const uint32_t QINV = 62209;
104104

105-
/* Compute a*q^{-1} mod 2^16 in unsigned representatives */
106-
const uint16_t a_reduced = (uint16_t)(a & UINT16_MAX);
105+
/* Compute a*q^{-1} mod 2^16 in unsigned representatives. */
106+
const uint16_t a_reduced = (uint16_t)(a & (int32_t)UINT16_MAX);
107+
107108
const uint16_t a_inverted = (a_reduced * QINV) & UINT16_MAX;
108109

109110
/* Lift to signed canonical representative mod 2^16. */

0 commit comments

Comments
 (0)