Merge "Fix static analyzer issues caught by clang" am: c2c0df900d
am: d484e7cef5
* commit 'd484e7cef56133e1957e63f7de3bb6e47602fa85':
Fix static analyzer issues caught by clang
This commit is contained in:
commit
5fff7da71e
1 changed files with 5 additions and 3 deletions
|
@ -199,7 +199,7 @@ static int process_skip_chunk(struct sparse_file *s, unsigned int chunk_size,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int process_crc32_chunk(int fd, unsigned int chunk_size, uint32_t crc32)
|
||||
static int process_crc32_chunk(int fd, unsigned int chunk_size, uint32_t *crc32)
|
||||
{
|
||||
uint32_t file_crc32;
|
||||
int ret;
|
||||
|
@ -213,7 +213,7 @@ static int process_crc32_chunk(int fd, unsigned int chunk_size, uint32_t crc32)
|
|||
return ret;
|
||||
}
|
||||
|
||||
if (file_crc32 != crc32) {
|
||||
if (crc32 != NULL && file_crc32 != *crc32) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ static int process_chunk(struct sparse_file *s, int fd, off64_t offset,
|
|||
}
|
||||
return chunk_header->chunk_sz;
|
||||
case CHUNK_TYPE_CRC32:
|
||||
ret = process_crc32_chunk(fd, chunk_data_size, *crc_ptr);
|
||||
ret = process_crc32_chunk(fd, chunk_data_size, crc_ptr);
|
||||
if (ret < 0) {
|
||||
verbose_error(s->verbose, -EINVAL, "crc block at %" PRId64,
|
||||
offset);
|
||||
|
@ -374,6 +374,7 @@ static int sparse_file_read_normal(struct sparse_file *s, int fd)
|
|||
ret = read_all(fd, buf, to_read);
|
||||
if (ret < 0) {
|
||||
error("failed to read sparse file");
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -401,6 +402,7 @@ static int sparse_file_read_normal(struct sparse_file *s, int fd)
|
|||
block++;
|
||||
}
|
||||
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue