dhcp-util: fix GCC 10 warning
PATCH 1/1 dhcp-util: fix GCC 10 warning
LEN_CHECK was being fed a hardcoded '1' which was being treated as an int. This led GCC 10.2.1 to emit a warning about comparison between signed/unsigned integers because the builder->max member is unsigned:
ell/dhcp-util.c: In function ‘_dhcp_message_builder_append’:ell/dhcp-util.c:55:49: error: comparison of integer expressions of different
signedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare]
55 | if ((builder)->pos - (builder)->start + (next) > (builder)->max) \
| ^ell/dhcp-util.c:65:3: note: in expansion of macro ‘LEN_CHECK’
65 | LEN_CHECK(builder, 1);
| ^~~~~~~~~cc1: all warnings being treated as errors
To fix this explicitly use '1U' so the compiler treats it as unsigned.
--- ell/dhcp-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
ell/dhcp-util.c +1 -1
@@ -62,7 +62,7 @@ bool _dhcp_message_builder_append(struct dhcp_message_builder *builder,switch (code) {case DHCP_OPTION_PAD :case DHCP_OPTION_END : -LEN_CHECK (builder,1 ); +LEN_CHECK (builder,1U ); builder->pos[0 ] = code; builder->pos +=1 ;
Signature · 1 line
2.26.2
Denis Kenzior
AppliedHi James,
Quoted 13 lines · James Prestwood
LEN_CHECKwas being fed a hardcoded '1' which was being treated as an int. This led GCC 10.2.1 to emit a warning about comparison between signed/unsigned integers because thebuilder->maxmember is unsigned:
ell/dhcp-util.c: In function ‘_dhcp_message_builder_append’:ell/dhcp-util.c:55:49: error: comparison of integer expressions of differentsignedness: ‘int’ and ‘unsigned int’ [-Werror=sign-compare] 55 | if ((builder)->pos - (builder)->start + (next) > (builder)->max) \ | ^ ell/dhcp-util.c:65:3: note: in expansion of macro ‘LEN_CHECK’ 65 | LEN_CHECK(builder, 1); | ^~~~~~~~~
Quoted 8 lines
cc1: all warnings being treated as errors
To fix this explicitly use '1U' so the compiler treats it as unsigned.
--- ell/dhcp-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied, thanks.
Regards,
-Denis