[pacman-dev] Possible redudant condition in handle.c

Dan McGee dpmcgee at gmail.com
Mon Aug 29 16:43:59 EDT 2011


On Mon, Aug 29, 2011 at 3:37 PM, Helder Martins
<heldermartins89 at gmail.com> wrote:
> Hi.
>
> I saw this little piece of code in handle.c in libpalm, starts at line 130:
>
>
>        ASSERT(handle->lockfile != NULL, return -1);
>     -> ASSERT(handle->lckstream != NULL, return 0);
>
>     -> if(handle->lckstream != NULL) {
>                fclose(handle->lckstream);
>                handle->lckstream = NULL;
>        }
>
> So i was wondering if that assert or the if condition are redundant, and
> if yes which one has the correct behaviour for the objective of this
> function.

Good catch. Looks like when I refactored this stuff I added the assert
without removing the now redundant conditional- you should be able to
kill the if check here completely.

-Dan


More information about the pacman-dev mailing list