bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] [PATCH] Fix some clang-analyzer warnings


From: Darshit Shah
Subject: Re: [Bug-wget] [PATCH] Fix some clang-analyzer warnings
Date: Wed, 19 Nov 2014 07:20:55 +0530

Thanking You,
Darshit Shah
Sent from mobile device. Please excuse my brevity
On 19-Nov-2014 1:24 am, "Tim Rühsen" <address@hidden> wrote:
>
> Fixes these warnings:
>
>         gnutls.c:457:3: warning: Value stored to 'err' is never read
>           err = 0;
>
>         http-ntlm.c:477:5: warning: Value stored to 'size' is never read
>           size = (size_t) snprintf (ntlmbuf, sizeof(ntlmbuf),
>
>         http.c:1479:3: warning: Attempt to free released memory
>           xfree_null (hs->error);
>
> The last one *might* result in a crash under special circumstances.
>
>
> I think we should just have one xfree() macro instead of two (xfree and
> xfree_null, some parts of the code even use free() directly).
>
I was looking into such things yesterday. Maybe we can write git hooks to
prevent known bad coding conventions from being pushed into the repository
in the future?

I already have a few sanity checks for Wget in my pre-commit hook. Such
things can be restyled for a server side update hook too.
> IMHO, a free'd pointer should always be set to NULL afterwards (as a good
> programming convention). I suggest the following macro
>
> #define xfree(a) do { if (a) { free ((void *) (a)); a = NULL; } } while
(0)
>
> What do you think ?
>
> Tim


reply via email to

[Prev in Thread] Current Thread [Next in Thread]