Re: [PATCH] dnsproxy: fix signedness warnings

Marcel Holtmann <[email protected]>
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
Hi Brian,

> This fixes the signdness warnings in dnsproxy.c
> ---
> src/dnsproxy.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/src/dnsproxy.c b/src/dnsproxy.c
> index d4242560..72e77f96 100644
> --- a/src/dnsproxy.c
> +++ b/src/dnsproxy.c
> @@ -436,7 +436,7 @@ static void update_cached_ttl(unsigned char *ptr, int len, int new_ttl)
> ptr += DNS_HEADER_SIZE;
> len -= DNS_HEADER_SIZE;
> 
> - if (len < DNS_QUESTION_SIZE + 1)
> + if (len < 0 || (unsigned int)len < DNS_QUESTION_SIZE + 1)
> return;

I love that you are trying to address these warnings. However just casting the issue away is not really helpful. Lets us proper types for the variables and have the checks make sense.

Background is that I want the compiler to keep warning us about these. Once you cast, the warning is gone forever.

Regards

Marcel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.