[pacman-dev] Possible redudant condition in handle.c
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. I can provide the patch once i know which one is the correct behaviour. Thanks, Helder Martins
On Mon, Aug 29, 2011 at 3:37 PM, Helder Martins <heldermartins89@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
Thank you, i will submit the patch soon Helder Martins. On 08/29/2011 09:43 PM, Dan McGee wrote:
On Mon, Aug 29, 2011 at 3:37 PM, Helder Martins <heldermartins89@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
participants (2)
-
Dan McGee
-
Helder Martins