projects
/
blerg.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
bfc01c1
)
Clean up some error handling in tag listing
author
Chip Black
<bytex64@bytex64.net>
Mon, 21 Feb 2011 21:28:03 +0000
(15:28 -0600)
committer
Chip Black
<bytex64@bytex64.net>
Mon, 21 Feb 2011 21:28:03 +0000
(15:28 -0600)
database/tags.c
patch
|
blob
|
history
diff --git
a/database/tags.c
b/database/tags.c
index
d15f8b8
..
5b3b3ce
100644
(file)
--- a/
database/tags.c
+++ b/
database/tags.c
@@
-128,26
+128,28
@@
struct tag * tag_list(const char *tag, uint64_t offset, int *count, int directio
fstat(tag_fd, &st);
if (st.st_size == 0) {
fstat(tag_fd, &st);
if (st.st_size == 0) {
- close(tag_fd);
*count = 0;
*count = 0;
-
return NULL
;
+
goto tag_list_map_failed
;
}
n_tag_records = st.st_size / sizeof(struct tag);
}
n_tag_records = st.st_size / sizeof(struct tag);
- if (*count > n_tag_records)
- *count = n_tag_records;
+ if (*count > n_tag_records
- offset
)
+ *count = n_tag_records
- offset
;
if (offset > n_tag_records) {
fprintf(stderr, "Cannot access tag record beyond end\n");
if (offset > n_tag_records) {
fprintf(stderr, "Cannot access tag record beyond end\n");
- return NULL;
+ *count = 0;
+ goto tag_list_map_failed;
}
taglist = (struct tag *) mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, tag_fd, 0);
if (taglist == MAP_FAILED) {
perror("Could not mmap tag file");
}
taglist = (struct tag *) mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, tag_fd, 0);
if (taglist == MAP_FAILED) {
perror("Could not mmap tag file");
+ *count = 0;
goto tag_list_map_failed;
}
retlist = (struct tag *) malloc(sizeof(struct tag) * *count);
if (retlist == NULL) {
perror("Could not allocate memory for tag list");
goto tag_list_map_failed;
}
retlist = (struct tag *) malloc(sizeof(struct tag) * *count);
if (retlist == NULL) {
perror("Could not allocate memory for tag list");
+ *count = 0;
goto tag_list_malloc_failed;
}
switch(direction) {
goto tag_list_malloc_failed;
}
switch(direction) {