From 63af0c66bdb04d8730a2da7c86d365f2cd107139 Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Thu, 5 Mar 2009 10:27:17 +0330 Subject: [PATCH] quran: report if open or mmap fails --- quran.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/quran.c b/quran.c index e4713e5..361c57b 100644 --- a/quran.c +++ b/quran.c @@ -30,8 +30,12 @@ struct quran *quran_alloc(char *path) struct quran *quran = xmalloc(sizeof(struct quran)); memset(quran, 0, sizeof(quran)); quran->fd = open(path, O_RDONLY); + if (quran->fd == -1) + xerror("open: "); quran->text = mmap(NULL, file_size(quran->fd), PROT_READ, MAP_SHARED, quran->fd, 0); + if (quran->text == MAP_FAILED) + xerror("mmap: "); nayas = newlines(quran->text); quran->ayas = xmalloc(sizeof(quran->ayas) * nayas); quran->ayas[0] = quran->text; -- 2.11.4.GIT