[pacman-dev] [PATCH] Refactor do/while cycle and multiple while cycles
Xavier
shiningxc at gmail.com
Thu Nov 12 18:50:20 EST 2009
On Fri, Nov 13, 2009 at 12:10 AM, Laszlo Papp <djszapi2 at gmail.com> wrote:
> * It makes the code clearer to read/understand
> * Cppcheck tool doesn't show this anymore: [./util.c:215]: (error) Resource leak: fd
> ---
> lib/libalpm/trans.c | 4 +++-
> lib/libalpm/util.c | 11 +++++++----
> src/pacman/pacman.c | 4 +++-
> 3 files changed, 13 insertions(+), 6 deletions(-)
>
> diff --git a/lib/libalpm/trans.c b/lib/libalpm/trans.c
> index aea71db..bc594f9 100644
> --- a/lib/libalpm/trans.c
> +++ b/lib/libalpm/trans.c
> @@ -261,7 +261,9 @@ int SYMEXPORT alpm_trans_release()
> /* unlock db */
> if(!nolock_flag) {
> if(handle->lckfd != -1) {
> - while(close(handle->lckfd) == -1 && errno == EINTR);
> + int fd;
> + fd = close(handle->lckfd);
> + while( fd == -1 && errno == EINTR);
> handle->lckfd = -1;
> }
Hmmmmmmmmmmm ok.
Thanks ? Bye ?
More information about the pacman-dev
mailing list