|
diff --git a/cache.c b/cache.c index add647e..6847202 100644 --- a/ cache.c+++ b/ cache.c |
|
@@ -68,8 +68,12 @@ static int open_slot(struct cache_slot *slot) |
68 | /* Close the active cache slot */ |
68 | /* Close the active cache slot */ |
69 | static void close_slot(struct cache_slot *slot) |
69 | static int close_slot(struct cache_slot *slot) |
70 | { |
70 | { |
| |
71 | int err = 0; |
71 | if (slot->cache_fd > 0) { |
72 | if (slot->cache_fd > 0) { |
72 | close(slot->cache_fd); |
73 | if (close(slot->cache_fd)) |
73 | slot->cache_fd = -1; |
74 | err = errno; |
| |
75 | else |
| |
76 | slot->cache_fd = -1; |
74 | } |
77 | } |
| |
78 | return err; |
75 | } |
79 | } |
@@ -118,8 +122,12 @@ static int is_modified(struct cache_slot *slot) |
118 | /* Close an open lockfile */ |
122 | /* Close an open lockfile */ |
119 | static void close_lock(struct cache_slot *slot) |
123 | static int close_lock(struct cache_slot *slot) |
120 | { |
124 | { |
| |
125 | int err = 0; |
121 | if (slot->lock_fd > 0) { |
126 | if (slot->lock_fd > 0) { |
122 | close(slot->lock_fd); |
127 | if (close(slot->lock_fd)) |
123 | slot->lock_fd = -1; |
128 | err = errno; |
| |
129 | else |
| |
130 | slot->lock_fd = -1; |
124 | } |
131 | } |
| |
132 | return err; |
125 | } |
133 | } |
@@ -136,3 +144,4 @@ static int lock_slot(struct cache_slot *slot) |
136 | return errno; |
144 | return errno; |
137 | write(slot->lock_fd, slot->key, slot->keylen + 1); |
145 | if (write(slot->lock_fd, slot->key, slot->keylen + 1) < 0) |
| |
146 | return errno; |
138 | return 0; |
147 | return 0; |
@@ -152,3 +161,7 @@ static int unlock_slot(struct cache_slot *slot, int replace_old_slot) |
152 | err = unlink(slot->lock_name); |
161 | err = unlink(slot->lock_name); |
153 | return err; |
162 | |
| |
163 | if (err) |
| |
164 | return errno; |
| |
165 | |
| |
166 | return 0; |
154 | } |
167 | } |
@@ -179,3 +192,5 @@ static int fill_slot(struct cache_slot *slot) |
179 | /* Close the temporary filedescriptor */ |
192 | /* Close the temporary filedescriptor */ |
180 | close(tmp); |
193 | if (close(tmp)) |
| |
194 | return errno; |
| |
195 | |
181 | return 0; |
196 | return 0; |
|