From be266b43647ef57632d7bcfd07a4441f737b5aed Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Fri, 13 Nov 2009 00:59:34 +0100 Subject: Refactor do/while cycle and multiple while cycles * It makes the code clearer to read/understand * Cppcheck tool doesn't show this anymore: [./util.c:215]: (error) Resource leak: fd [Dan: don't change the coding style] Signed-off-by: Dan McGee --- src/pacman/pacman.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index f4f80449..574a4a8a 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -234,7 +234,9 @@ static void cleanup(int ret) { static ssize_t xwrite(int fd, const void *buf, size_t count) { ssize_t ret; - while((ret = write(fd, buf, count)) == -1 && errno == EINTR); + do { + ret = write(fd, buf, count); + } while(ret == -1 && errno == EINTR); return(ret); } -- cgit v1.2.3-24-g4f1b