From 8bdda86ab4ac3092a53df2de303ba60b0352b16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Borgstr=C3=B6m?= Date: Wed, 3 Jul 2013 13:08:48 +0200 Subject: [PATCH] Removed unused include and added missing close()-call. --- darc/_hashindex.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/darc/_hashindex.c b/darc/_hashindex.c index 9a7ee28c5..dd2caa486 100644 --- a/darc/_hashindex.c +++ b/darc/_hashindex.c @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -154,12 +153,18 @@ hashindex_open(const char *path) } if((length = lseek(fd, 0, SEEK_END)) < 0) { EPRINTF_PATH(path, "lseek failed"); - close(fd); + if(close(fd) < 0) { + EPRINTF_PATH(path, "close failed"); + } return NULL; } - if((addr = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { + addr = mmap(0, length, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); + if(close(fd) < 0) { + EPRINTF_PATH(path, "close failed"); + return NULL; + } + if(addr == MAP_FAILED) { EPRINTF_PATH(path, "mmap failed"); - close(fd); return NULL; } header = (HashHeader *)addr;