On Wed, 2021-01-27 at 12:22 -0600, Denis Kenzior wrote:
On 1/27/21 11:09 AM, Brian Gix wrote:
> Some systems treat pointers as signed values, causing the following
That doesn't seem right. The issue is that pointer arithmetic is a signed type
and the macro assumes that next is unsigned, so the temporary resulting in the
operation left of '>' gets promoted to unsigned type. This breaks if a signed
type is passed in as 'next' argument of the macro. In theory this should
already be fixed by 3d096702811d ("dhcp-util: fix GCC 10 warning").
Yes, I can confirm that James' commit 3d096702811d fixes this problem
on 32 bit Fedora-30 runnint GCC version 9.3.1
Sorry for the redundent fix.
There may be systems that have ptrdiff_t be a non-standard type, so a really
paranoid fix would be an explicit cast, as you have it here...
> 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) >
> | ^
> ell/dhcp-util.c:65:3: note: in expansion of macro ‘LEN_CHECK’
> 65 | LEN_CHECK(builder, 1);
> | ^~~~~~~~~
> ell/dhcp-util.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)