Skip to content

Commit 4904878

Browse files
author
Rafael Vanoni
committed
revert s/assert/exit changes
1 parent df70249 commit 4904878

3 files changed

Lines changed: 9 additions & 45 deletions

File tree

mtbl/compression.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -482,14 +482,8 @@ _mtbl_decompress_zlib(
482482

483483
do {
484484
zret = inflate(&zs, Z_FINISH);
485-
if (zret != Z_STREAM_END && zret != Z_BUF_ERROR) {
486-
goto fail;
487-
}
488-
485+
assert(zret == Z_STREAM_END || zret == Z_BUF_ERROR);
489486
if (zret != Z_STREAM_END) {
490-
if (*output_size > SIZE_MAX / 2) {
491-
goto fail;
492-
}
493487
*output = my_realloc(*output, *output_size * 2);
494488
zs.next_out = *output + *output_size;
495489
zs.avail_out = *output_size;
@@ -499,11 +493,6 @@ _mtbl_decompress_zlib(
499493

500494
*output_size = zs.total_out;
501495
inflateEnd(&zs);
496+
502497
return (mtbl_res_success);
503-
fail:
504-
free(*output);
505-
*output = NULL;
506-
*output_size = 0;
507-
inflateEnd(&zs);
508-
return (mtbl_res_failure);
509498
}

mtbl/sorter.c

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,7 @@ mtbl_sorter_init(const struct mtbl_sorter_options *opt)
140140
if (s->opt.pool != NULL) {
141141
s->pool = s->opt.pool->pool;
142142
s->rhandler = result_handler_init(_collect_readers_cb, s);
143-
if (s->rhandler == NULL) {
144-
entry_vec_destroy(&s->vec);
145-
reader_vec_destroy(&s->readers);
146-
return (NULL);
147-
}
143+
assert (s->rhandler != NULL);
148144
}
149145

150146
return (s);
@@ -198,18 +194,9 @@ _mtbl_sorter_write_chunk(struct entry_batch *b)
198194
ubuf_append(tmp_fname, (const uint8_t *) "\x00", 1);
199195

200196
int fd = mkstemp((char *) ubuf_data(tmp_fname));
201-
if (fd < 0) {
202-
ubuf_destroy(&tmp_fname);
203-
return (NULL);
204-
}
205-
197+
assert(fd >= 0);
206198
int unlink_ret = unlink((char *) ubuf_data(tmp_fname));
207-
if (unlink_ret == -1) {
208-
ubuf_destroy(&tmp_fname);
209-
close(fd);
210-
return (NULL);
211-
}
212-
199+
assert(unlink_ret == 0);
213200
ubuf_destroy(&tmp_fname);
214201

215202
struct mtbl_writer_options *wopt = mtbl_writer_options_init();

mtbl/writer.c

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,7 @@ mtbl_writer_init_fd(int orig_fd, const struct mtbl_writer_options *opt)
146146
int fd;
147147

148148
fd = dup(orig_fd);
149-
if (fd < 0) {
150-
return (NULL);
151-
}
152-
149+
assert(fd >= 0);
153150
w = my_calloc(1, sizeof(*w));
154151
if (opt == NULL) {
155152
w->opt.compression_type = DEFAULT_COMPRESSION_TYPE;
@@ -166,14 +163,9 @@ mtbl_writer_init_fd(int orig_fd, const struct mtbl_writer_options *opt)
166163
* to reserve some initial bytes in the file.
167164
*/
168165
off_t offset = lseek(fd, 0, SEEK_CUR);
169-
if (offset == (off_t)-1) {
170-
close(fd);
171-
free(w);
172-
return (NULL);
173-
}
174-
w->last_offset = (uint64_t)offset;
166+
assert(offset != (off_t)-1);
175167

176-
w->pending_offset = w->last_offset;
168+
w->pending_offset = (uint64_t)offset;
177169
w->last_key = ubuf_init(256);
178170
w->m.file_version = MTBL_FORMAT_V2;
179171
w->m.compression_algorithm = w->opt.compression_type;
@@ -185,11 +177,7 @@ mtbl_writer_init_fd(int orig_fd, const struct mtbl_writer_options *opt)
185177
if (w->opt.pool != NULL) {
186178
w->pool = w->opt.pool->pool;
187179
w->rhandler = result_handler_init(_write_data_block_wrapper, w);
188-
if (w->rhandler == NULL) {
189-
close(fd);
190-
free(w);
191-
return (NULL);
192-
}
180+
assert (w->rhandler != NULL);
193181
}
194182

195183
return (w);

0 commit comments

Comments
 (0)