{"thread":{"id":"7838","subject":"[PATCH 3/5] read_cache_from(): small simplification","startedAt":"2007-04-25T14:18:17Z","lastAt":"2007-04-25T14:18:17Z","messageCount":1,"participants":["Luiz Fernando N. Capitulino"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"40407","messageId":"20070425111817.4d4e4af5@localhost","threadId":"7838","inReplyTo":null,"subject":"[PATCH 3/5] read_cache_from(): small simplification","fromName":"Luiz Fernando N. Capitulino","fromEmail":"lcapitulino@mandriva.com.br","sentAt":"2007-04-25T14:18:17Z","receivedAt":"2007-04-25T14:18:17Z","isPatch":true,"sender":{"key":"lcapitulino@mandriva.com.br","avatar":null},"body":"This change 'opens' the code block which maps the index file into\nmemory, making the code clearer and easier to read.\n\nSigned-off-by: Luiz Fernando N. Capitulino <lcapitulino@mandriva.com.br>\n---\n read-cache.c |   16 ++++++++--------\n 1 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/read-cache.c b/read-cache.c\nindex d2f332a..24e5581 100644\n--- a/read-cache.c\n+++ b/read-cache.c\n@@ -856,15 +856,15 @@ int read_cache_from(const char *path)\n \t\tdie(\"index file open failed (%s)\", strerror(errno));\n \t}\n \n-\tif (!fstat(fd, &st)) {\n-\t\tcache_mmap_size = xsize_t(st.st_size);\n-\t\terrno = EINVAL;\n-\t\tif (cache_mmap_size >= sizeof(struct cache_header) + 20)\n-\t\t\tcache_mmap = xmmap(NULL, cache_mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);\n-\t\telse\n-\t\t\tdie(\"index file smaller than expected\");\n-\t} else\n+\tif (fstat(fd, &st))\n \t\tdie(\"cannot stat the open index (%s)\", strerror(errno));\n+\n+\terrno = EINVAL;\n+\tcache_mmap_size = xsize_t(st.st_size);\n+\tif (cache_mmap_size < sizeof(struct cache_header) + 20)\n+\t\tdie(\"index file smaller than expected\");\n+\n+\tcache_mmap = xmmap(NULL, cache_mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);\n \tclose(fd);\n \n \thdr = cache_mmap;\n-- \n1.5.1.1.320.g1cf2\n"}]}