summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYi Kong2018-07-23 18:31:11 -0500
committerYi Kong2018-07-23 18:32:01 -0500
commit17ba95ed9e65099db60e1e14ce6be51e87675707 (patch)
treee650ef5d7da0621e36ccdc7ca776869831cd2947 /libsparse
parent7e7cefa2c7972be72b915512b12bcab1e9f36a36 (diff)
downloadplatform-system-core-17ba95ed9e65099db60e1e14ce6be51e87675707.tar.gz
platform-system-core-17ba95ed9e65099db60e1e14ce6be51e87675707.tar.xz
platform-system-core-17ba95ed9e65099db60e1e14ce6be51e87675707.zip
[libsparse] Modernize codebase by replacing NULL with nullptr
Fixes -Wzero-as-null-pointer-constant warning. Test: m Bug: 68236239 Change-Id: I43dae734817cae7a260ffc7afcd85fbd4451eddf
Diffstat (limited to 'libsparse')
-rw-r--r--libsparse/backed_block.cpp32
-rw-r--r--libsparse/output_file.cpp18
-rw-r--r--libsparse/simg2simg.cpp2
-rw-r--r--libsparse/sparse.cpp14
-rw-r--r--libsparse/sparse_read.cpp28
5 files changed, 47 insertions, 47 deletions
diff --git a/libsparse/backed_block.cpp b/libsparse/backed_block.cpp
index 7f5632eea..f3d8022ac 100644
--- a/libsparse/backed_block.cpp
+++ b/libsparse/backed_block.cpp
@@ -133,7 +133,7 @@ void backed_block_list_move(struct backed_block_list* from, struct backed_block_
133 struct backed_block* start, struct backed_block* end) { 133 struct backed_block* start, struct backed_block* end) {
134 struct backed_block* bb; 134 struct backed_block* bb;
135 135
136 if (start == NULL) { 136 if (start == nullptr) {
137 start = from->data_blocks; 137 start = from->data_blocks;
138 } 138 }
139 139
@@ -142,12 +142,12 @@ void backed_block_list_move(struct backed_block_list* from, struct backed_block_
142 ; 142 ;
143 } 143 }
144 144
145 if (start == NULL || end == NULL) { 145 if (start == nullptr || end == nullptr) {
146 return; 146 return;
147 } 147 }
148 148
149 from->last_used = NULL; 149 from->last_used = nullptr;
150 to->last_used = NULL; 150 to->last_used = nullptr;
151 if (from->data_blocks == start) { 151 if (from->data_blocks == start) {
152 from->data_blocks = end->next; 152 from->data_blocks = end->next;
153 } else { 153 } else {
@@ -161,7 +161,7 @@ void backed_block_list_move(struct backed_block_list* from, struct backed_block_
161 161
162 if (!to->data_blocks) { 162 if (!to->data_blocks) {
163 to->data_blocks = start; 163 to->data_blocks = start;
164 end->next = NULL; 164 end->next = nullptr;
165 } else { 165 } else {
166 for (bb = to->data_blocks; bb; bb = bb->next) { 166 for (bb = to->data_blocks; bb; bb = bb->next) {
167 if (!bb->next || bb->next->block > start->block) { 167 if (!bb->next || bb->next->block > start->block) {
@@ -230,7 +230,7 @@ static int merge_bb(struct backed_block_list* bbl, struct backed_block* a, struc
230static int queue_bb(struct backed_block_list* bbl, struct backed_block* new_bb) { 230static int queue_bb(struct backed_block_list* bbl, struct backed_block* new_bb) {
231 struct backed_block* bb; 231 struct backed_block* bb;
232 232
233 if (bbl->data_blocks == NULL) { 233 if (bbl->data_blocks == nullptr) {
234 bbl->data_blocks = new_bb; 234 bbl->data_blocks = new_bb;
235 return 0; 235 return 0;
236 } 236 }
@@ -253,7 +253,7 @@ static int queue_bb(struct backed_block_list* bbl, struct backed_block* new_bb)
253 for (; bb->next && bb->next->block < new_bb->block; bb = bb->next) 253 for (; bb->next && bb->next->block < new_bb->block; bb = bb->next)
254 ; 254 ;
255 255
256 if (bb->next == NULL) { 256 if (bb->next == nullptr) {
257 bb->next = new_bb; 257 bb->next = new_bb;
258 } else { 258 } else {
259 new_bb->next = bb->next; 259 new_bb->next = bb->next;
@@ -273,7 +273,7 @@ static int queue_bb(struct backed_block_list* bbl, struct backed_block* new_bb)
273int backed_block_add_fill(struct backed_block_list* bbl, unsigned int fill_val, unsigned int len, 273int backed_block_add_fill(struct backed_block_list* bbl, unsigned int fill_val, unsigned int len,
274 unsigned int block) { 274 unsigned int block) {
275 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block))); 275 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block)));
276 if (bb == NULL) { 276 if (bb == nullptr) {
277 return -ENOMEM; 277 return -ENOMEM;
278 } 278 }
279 279
@@ -281,7 +281,7 @@ int backed_block_add_fill(struct backed_block_list* bbl, unsigned int fill_val,
281 bb->len = len; 281 bb->len = len;
282 bb->type = BACKED_BLOCK_FILL; 282 bb->type = BACKED_BLOCK_FILL;
283 bb->fill.val = fill_val; 283 bb->fill.val = fill_val;
284 bb->next = NULL; 284 bb->next = nullptr;
285 285
286 return queue_bb(bbl, bb); 286 return queue_bb(bbl, bb);
287} 287}
@@ -290,7 +290,7 @@ int backed_block_add_fill(struct backed_block_list* bbl, unsigned int fill_val,
290int backed_block_add_data(struct backed_block_list* bbl, void* data, unsigned int len, 290int backed_block_add_data(struct backed_block_list* bbl, void* data, unsigned int len,
291 unsigned int block) { 291 unsigned int block) {
292 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block))); 292 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block)));
293 if (bb == NULL) { 293 if (bb == nullptr) {
294 return -ENOMEM; 294 return -ENOMEM;
295 } 295 }
296 296
@@ -298,7 +298,7 @@ int backed_block_add_data(struct backed_block_list* bbl, void* data, unsigned in
298 bb->len = len; 298 bb->len = len;
299 bb->type = BACKED_BLOCK_DATA; 299 bb->type = BACKED_BLOCK_DATA;
300 bb->data.data = data; 300 bb->data.data = data;
301 bb->next = NULL; 301 bb->next = nullptr;
302 302
303 return queue_bb(bbl, bb); 303 return queue_bb(bbl, bb);
304} 304}
@@ -307,7 +307,7 @@ int backed_block_add_data(struct backed_block_list* bbl, void* data, unsigned in
307int backed_block_add_file(struct backed_block_list* bbl, const char* filename, int64_t offset, 307int backed_block_add_file(struct backed_block_list* bbl, const char* filename, int64_t offset,
308 unsigned int len, unsigned int block) { 308 unsigned int len, unsigned int block) {
309 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block))); 309 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block)));
310 if (bb == NULL) { 310 if (bb == nullptr) {
311 return -ENOMEM; 311 return -ENOMEM;
312 } 312 }
313 313
@@ -316,7 +316,7 @@ int backed_block_add_file(struct backed_block_list* bbl, const char* filename, i
316 bb->type = BACKED_BLOCK_FILE; 316 bb->type = BACKED_BLOCK_FILE;
317 bb->file.filename = strdup(filename); 317 bb->file.filename = strdup(filename);
318 bb->file.offset = offset; 318 bb->file.offset = offset;
319 bb->next = NULL; 319 bb->next = nullptr;
320 320
321 return queue_bb(bbl, bb); 321 return queue_bb(bbl, bb);
322} 322}
@@ -325,7 +325,7 @@ int backed_block_add_file(struct backed_block_list* bbl, const char* filename, i
325int backed_block_add_fd(struct backed_block_list* bbl, int fd, int64_t offset, unsigned int len, 325int backed_block_add_fd(struct backed_block_list* bbl, int fd, int64_t offset, unsigned int len,
326 unsigned int block) { 326 unsigned int block) {
327 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block))); 327 struct backed_block* bb = reinterpret_cast<backed_block*>(calloc(1, sizeof(struct backed_block)));
328 if (bb == NULL) { 328 if (bb == nullptr) {
329 return -ENOMEM; 329 return -ENOMEM;
330 } 330 }
331 331
@@ -334,7 +334,7 @@ int backed_block_add_fd(struct backed_block_list* bbl, int fd, int64_t offset, u
334 bb->type = BACKED_BLOCK_FD; 334 bb->type = BACKED_BLOCK_FD;
335 bb->fd.fd = fd; 335 bb->fd.fd = fd;
336 bb->fd.offset = offset; 336 bb->fd.offset = offset;
337 bb->next = NULL; 337 bb->next = nullptr;
338 338
339 return queue_bb(bbl, bb); 339 return queue_bb(bbl, bb);
340} 340}
@@ -350,7 +350,7 @@ int backed_block_split(struct backed_block_list* bbl, struct backed_block* bb,
350 } 350 }
351 351
352 new_bb = reinterpret_cast<backed_block*>(malloc(sizeof(struct backed_block))); 352 new_bb = reinterpret_cast<backed_block*>(malloc(sizeof(struct backed_block)));
353 if (new_bb == NULL) { 353 if (new_bb == nullptr) {
354 return -ENOMEM; 354 return -ENOMEM;
355 } 355 }
356 356
diff --git a/libsparse/output_file.cpp b/libsparse/output_file.cpp
index 5388e7742..fe314b30e 100644
--- a/libsparse/output_file.cpp
+++ b/libsparse/output_file.cpp
@@ -233,7 +233,7 @@ static int gz_file_write(struct output_file* out, void* data, size_t len) {
233 while (len > 0) { 233 while (len > 0) {
234 ret = gzwrite(outgz->gz_fd, data, min(len, (unsigned int)INT_MAX)); 234 ret = gzwrite(outgz->gz_fd, data, min(len, (unsigned int)INT_MAX));
235 if (ret == 0) { 235 if (ret == 0) {
236 error("gzwrite %s", gzerror(outgz->gz_fd, NULL)); 236 error("gzwrite %s", gzerror(outgz->gz_fd, nullptr));
237 return -1; 237 return -1;
238 } 238 }
239 len -= ret; 239 len -= ret;
@@ -269,7 +269,7 @@ static int callback_file_skip(struct output_file* out, int64_t off) {
269 269
270 while (off > 0) { 270 while (off > 0) {
271 to_write = min(off, (int64_t)INT_MAX); 271 to_write = min(off, (int64_t)INT_MAX);
272 ret = outc->write(outc->priv, NULL, to_write); 272 ret = outc->write(outc->priv, nullptr, to_write);
273 if (ret < 0) { 273 if (ret < 0) {
274 return ret; 274 return ret;
275 } 275 }
@@ -568,7 +568,7 @@ static struct output_file* output_file_new_gz(void) {
568 reinterpret_cast<struct output_file_gz*>(calloc(1, sizeof(struct output_file_gz))); 568 reinterpret_cast<struct output_file_gz*>(calloc(1, sizeof(struct output_file_gz)));
569 if (!outgz) { 569 if (!outgz) {
570 error_errno("malloc struct outgz"); 570 error_errno("malloc struct outgz");
571 return NULL; 571 return nullptr;
572 } 572 }
573 573
574 outgz->out.ops = &gz_file_ops; 574 outgz->out.ops = &gz_file_ops;
@@ -581,7 +581,7 @@ static struct output_file* output_file_new_normal(void) {
581 reinterpret_cast<struct output_file_normal*>(calloc(1, sizeof(struct output_file_normal))); 581 reinterpret_cast<struct output_file_normal*>(calloc(1, sizeof(struct output_file_normal)));
582 if (!outn) { 582 if (!outn) {
583 error_errno("malloc struct outn"); 583 error_errno("malloc struct outn");
584 return NULL; 584 return nullptr;
585 } 585 }
586 586
587 outn->out.ops = &file_ops; 587 outn->out.ops = &file_ops;
@@ -599,7 +599,7 @@ struct output_file* output_file_open_callback(int (*write)(void*, const void*, s
599 reinterpret_cast<struct output_file_callback*>(calloc(1, sizeof(struct output_file_callback))); 599 reinterpret_cast<struct output_file_callback*>(calloc(1, sizeof(struct output_file_callback)));
600 if (!outc) { 600 if (!outc) {
601 error_errno("malloc struct outc"); 601 error_errno("malloc struct outc");
602 return NULL; 602 return nullptr;
603 } 603 }
604 604
605 outc->out.ops = &callback_file_ops; 605 outc->out.ops = &callback_file_ops;
@@ -609,7 +609,7 @@ struct output_file* output_file_open_callback(int (*write)(void*, const void*, s
609 ret = output_file_init(&outc->out, block_size, len, sparse, chunks, crc); 609 ret = output_file_init(&outc->out, block_size, len, sparse, chunks, crc);
610 if (ret < 0) { 610 if (ret < 0) {
611 free(outc); 611 free(outc);
612 return NULL; 612 return nullptr;
613 } 613 }
614 614
615 return &outc->out; 615 return &outc->out;
@@ -626,7 +626,7 @@ struct output_file* output_file_open_fd(int fd, unsigned int block_size, int64_t
626 out = output_file_new_normal(); 626 out = output_file_new_normal();
627 } 627 }
628 if (!out) { 628 if (!out) {
629 return NULL; 629 return nullptr;
630 } 630 }
631 631
632 out->ops->open(out, fd); 632 out->ops->open(out, fd);
@@ -634,7 +634,7 @@ struct output_file* output_file_open_fd(int fd, unsigned int block_size, int64_t
634 ret = output_file_init(out, block_size, len, sparse, chunks, crc); 634 ret = output_file_init(out, block_size, len, sparse, chunks, crc);
635 if (ret < 0) { 635 if (ret < 0) {
636 free(out); 636 free(out);
637 return NULL; 637 return nullptr;
638 } 638 }
639 639
640 return out; 640 return out;
@@ -664,7 +664,7 @@ int write_fd_chunk(struct output_file* out, unsigned int len, int fd, int64_t of
664#ifndef _WIN32 664#ifndef _WIN32
665 if (buffer_size > SIZE_MAX) return -E2BIG; 665 if (buffer_size > SIZE_MAX) return -E2BIG;
666 char* data = 666 char* data =
667 reinterpret_cast<char*>(mmap64(NULL, buffer_size, PROT_READ, MAP_SHARED, fd, aligned_offset)); 667 reinterpret_cast<char*>(mmap64(nullptr, buffer_size, PROT_READ, MAP_SHARED, fd, aligned_offset));
668 if (data == MAP_FAILED) { 668 if (data == MAP_FAILED) {
669 return -errno; 669 return -errno;
670 } 670 }
diff --git a/libsparse/simg2simg.cpp b/libsparse/simg2simg.cpp
index 7e6570159..a2c296e89 100644
--- a/libsparse/simg2simg.cpp
+++ b/libsparse/simg2simg.cpp
@@ -66,7 +66,7 @@ int main(int argc, char* argv[]) {
66 exit(-1); 66 exit(-1);
67 } 67 }
68 68
69 files = sparse_file_resparse(s, max_size, NULL, 0); 69 files = sparse_file_resparse(s, max_size, nullptr, 0);
70 if (files < 0) { 70 if (files < 0) {
71 fprintf(stderr, "Failed to resparse\n"); 71 fprintf(stderr, "Failed to resparse\n");
72 exit(-1); 72 exit(-1);
diff --git a/libsparse/sparse.cpp b/libsparse/sparse.cpp
index 6ff97b6ab..cb288c555 100644
--- a/libsparse/sparse.cpp
+++ b/libsparse/sparse.cpp
@@ -30,13 +30,13 @@
30struct sparse_file* sparse_file_new(unsigned int block_size, int64_t len) { 30struct sparse_file* sparse_file_new(unsigned int block_size, int64_t len) {
31 struct sparse_file* s = reinterpret_cast<sparse_file*>(calloc(sizeof(struct sparse_file), 1)); 31 struct sparse_file* s = reinterpret_cast<sparse_file*>(calloc(sizeof(struct sparse_file), 1));
32 if (!s) { 32 if (!s) {
33 return NULL; 33 return nullptr;
34 } 34 }
35 35
36 s->backed_block_list = backed_block_list_new(block_size); 36 s->backed_block_list = backed_block_list_new(block_size);
37 if (!s->backed_block_list) { 37 if (!s->backed_block_list) {
38 free(s); 38 free(s);
39 return NULL; 39 return nullptr;
40 } 40 }
41 41
42 s->block_size = block_size; 42 s->block_size = block_size;
@@ -252,7 +252,7 @@ static struct backed_block* move_chunks_up_to_len(struct sparse_file* from, stru
252 unsigned int len) { 252 unsigned int len) {
253 int64_t count = 0; 253 int64_t count = 0;
254 struct output_file* out_counter; 254 struct output_file* out_counter;
255 struct backed_block* last_bb = NULL; 255 struct backed_block* last_bb = nullptr;
256 struct backed_block* bb; 256 struct backed_block* bb;
257 struct backed_block* start; 257 struct backed_block* start;
258 unsigned int last_block = 0; 258 unsigned int last_block = 0;
@@ -270,7 +270,7 @@ static struct backed_block* move_chunks_up_to_len(struct sparse_file* from, stru
270 out_counter = output_file_open_callback(out_counter_write, &count, to->block_size, to->len, false, 270 out_counter = output_file_open_callback(out_counter_write, &count, to->block_size, to->len, false,
271 true, 0, false); 271 true, 0, false);
272 if (!out_counter) { 272 if (!out_counter) {
273 return NULL; 273 return nullptr;
274 } 274 }
275 275
276 for (bb = start; bb; bb = backed_block_iter_next(bb)) { 276 for (bb = start; bb; bb = backed_block_iter_next(bb)) {
@@ -281,7 +281,7 @@ static struct backed_block* move_chunks_up_to_len(struct sparse_file* from, stru
281 /* will call out_counter_write to update count */ 281 /* will call out_counter_write to update count */
282 ret = sparse_file_write_block(out_counter, bb); 282 ret = sparse_file_write_block(out_counter, bb);
283 if (ret) { 283 if (ret) {
284 bb = NULL; 284 bb = nullptr;
285 goto out; 285 goto out;
286 } 286 }
287 if (file_len + count > len) { 287 if (file_len + count > len) {
@@ -330,13 +330,13 @@ int sparse_file_resparse(struct sparse_file* in_s, unsigned int max_len, struct
330 if (c < out_s_count) { 330 if (c < out_s_count) {
331 out_s[c] = s; 331 out_s[c] = s;
332 } else { 332 } else {
333 backed_block_list_move(s->backed_block_list, tmp->backed_block_list, NULL, NULL); 333 backed_block_list_move(s->backed_block_list, tmp->backed_block_list, nullptr, nullptr);
334 sparse_file_destroy(s); 334 sparse_file_destroy(s);
335 } 335 }
336 c++; 336 c++;
337 } while (bb); 337 } while (bb);
338 338
339 backed_block_list_move(tmp->backed_block_list, in_s->backed_block_list, NULL, NULL); 339 backed_block_list_move(tmp->backed_block_list, in_s->backed_block_list, nullptr, nullptr);
340 340
341 sparse_file_destroy(tmp); 341 sparse_file_destroy(tmp);
342 342
diff --git a/libsparse/sparse_read.cpp b/libsparse/sparse_read.cpp
index 56e2c9a0b..c4c182358 100644
--- a/libsparse/sparse_read.cpp
+++ b/libsparse/sparse_read.cpp
@@ -276,7 +276,7 @@ static int process_crc32_chunk(SparseFileSource* source, unsigned int chunk_size
276 return ret; 276 return ret;
277 } 277 }
278 278
279 if (crc32 != NULL && file_crc32 != *crc32) { 279 if (crc32 != nullptr && file_crc32 != *crc32) {
280 return -EINVAL; 280 return -EINVAL;
281 } 281 }
282 282
@@ -339,7 +339,7 @@ static int sparse_file_read_sparse(struct sparse_file* s, SparseFileSource* sour
339 sparse_header_t sparse_header; 339 sparse_header_t sparse_header;
340 chunk_header_t chunk_header; 340 chunk_header_t chunk_header;
341 uint32_t crc32 = 0; 341 uint32_t crc32 = 0;
342 uint32_t* crc_ptr = 0; 342 uint32_t* crc_ptr = nullptr;
343 unsigned int cur_block = 0; 343 unsigned int cur_block = 0;
344 344
345 if (!copybuf) { 345 if (!copybuf) {
@@ -489,39 +489,39 @@ static struct sparse_file* sparse_file_import_source(SparseFileSource* source, b
489 ret = source->ReadValue(&sparse_header, sizeof(sparse_header)); 489 ret = source->ReadValue(&sparse_header, sizeof(sparse_header));
490 if (ret < 0) { 490 if (ret < 0) {
491 verbose_error(verbose, ret, "header"); 491 verbose_error(verbose, ret, "header");
492 return NULL; 492 return nullptr;
493 } 493 }
494 494
495 if (sparse_header.magic != SPARSE_HEADER_MAGIC) { 495 if (sparse_header.magic != SPARSE_HEADER_MAGIC) {
496 verbose_error(verbose, -EINVAL, "header magic"); 496 verbose_error(verbose, -EINVAL, "header magic");
497 return NULL; 497 return nullptr;
498 } 498 }
499 499
500 if (sparse_header.major_version != SPARSE_HEADER_MAJOR_VER) { 500 if (sparse_header.major_version != SPARSE_HEADER_MAJOR_VER) {
501 verbose_error(verbose, -EINVAL, "header major version"); 501 verbose_error(verbose, -EINVAL, "header major version");
502 return NULL; 502 return nullptr;
503 } 503 }
504 504
505 if (sparse_header.file_hdr_sz < SPARSE_HEADER_LEN) { 505 if (sparse_header.file_hdr_sz < SPARSE_HEADER_LEN) {
506 return NULL; 506 return nullptr;
507 } 507 }
508 508
509 if (sparse_header.chunk_hdr_sz < sizeof(chunk_header_t)) { 509 if (sparse_header.chunk_hdr_sz < sizeof(chunk_header_t)) {
510 return NULL; 510 return nullptr;
511 } 511 }
512 512
513 len = (int64_t)sparse_header.total_blks * sparse_header.blk_sz; 513 len = (int64_t)sparse_header.total_blks * sparse_header.blk_sz;
514 s = sparse_file_new(sparse_header.blk_sz, len); 514 s = sparse_file_new(sparse_header.blk_sz, len);
515 if (!s) { 515 if (!s) {
516 verbose_error(verbose, -EINVAL, NULL); 516 verbose_error(verbose, -EINVAL, nullptr);
517 return NULL; 517 return nullptr;
518 } 518 }
519 519
520 ret = source->SetOffset(0); 520 ret = source->SetOffset(0);
521 if (ret < 0) { 521 if (ret < 0) {
522 verbose_error(verbose, ret, "seeking"); 522 verbose_error(verbose, ret, "seeking");
523 sparse_file_destroy(s); 523 sparse_file_destroy(s);
524 return NULL; 524 return nullptr;
525 } 525 }
526 526
527 s->verbose = verbose; 527 s->verbose = verbose;
@@ -529,7 +529,7 @@ static struct sparse_file* sparse_file_import_source(SparseFileSource* source, b
529 ret = sparse_file_read_sparse(s, source, crc); 529 ret = sparse_file_read_sparse(s, source, crc);
530 if (ret < 0) { 530 if (ret < 0) {
531 sparse_file_destroy(s); 531 sparse_file_destroy(s);
532 return NULL; 532 return nullptr;
533 } 533 }
534 534
535 return s; 535 return s;
@@ -557,20 +557,20 @@ struct sparse_file* sparse_file_import_auto(int fd, bool crc, bool verbose) {
557 557
558 len = lseek64(fd, 0, SEEK_END); 558 len = lseek64(fd, 0, SEEK_END);
559 if (len < 0) { 559 if (len < 0) {
560 return NULL; 560 return nullptr;
561 } 561 }
562 562
563 lseek64(fd, 0, SEEK_SET); 563 lseek64(fd, 0, SEEK_SET);
564 564
565 s = sparse_file_new(4096, len); 565 s = sparse_file_new(4096, len);
566 if (!s) { 566 if (!s) {
567 return NULL; 567 return nullptr;
568 } 568 }
569 569
570 ret = sparse_file_read_normal(s, fd); 570 ret = sparse_file_read_normal(s, fd);
571 if (ret < 0) { 571 if (ret < 0) {
572 sparse_file_destroy(s); 572 sparse_file_destroy(s);
573 return NULL; 573 return nullptr;
574 } 574 }
575 575
576 return s; 576 return s;