mirror of https://github.com/mpv-player/mpv
Remove some unneeded NULL checks
Found by Coverity; also see commit 85fb2af3
.
This commit is contained in:
parent
38f4ec69d1
commit
e082c2c3df
|
@ -78,8 +78,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||||
int mapsize;
|
int mapsize;
|
||||||
|
|
||||||
// Free previous buffers
|
// Free previous buffers
|
||||||
if (s->buf)
|
free(s->buf[0]);
|
||||||
free(s->buf[0]);
|
|
||||||
|
|
||||||
// unmap previous area
|
// unmap previous area
|
||||||
if(s->mmap_area)
|
if(s->mmap_area)
|
||||||
|
@ -94,8 +93,10 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||||
|
|
||||||
// Allocate new buffers (as one continuous block)
|
// Allocate new buffers (as one continuous block)
|
||||||
s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps);
|
s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps);
|
||||||
if(NULL == s->buf[0])
|
if(NULL == s->buf[0]) {
|
||||||
MP_FATAL(af, "Out of memory\n");
|
MP_FATAL(af, "Out of memory\n");
|
||||||
|
return AF_ERROR;
|
||||||
|
}
|
||||||
for(i = 1; i < af->data->nch; i++)
|
for(i = 1; i < af->data->nch; i++)
|
||||||
s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;
|
s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;
|
||||||
|
|
||||||
|
@ -147,8 +148,8 @@ static int control(struct af_instance* af, int cmd, void* arg)
|
||||||
static void uninit( struct af_instance* af )
|
static void uninit( struct af_instance* af )
|
||||||
{
|
{
|
||||||
af_export_t* s = af->priv;
|
af_export_t* s = af->priv;
|
||||||
if (s->buf)
|
|
||||||
free(s->buf[0]);
|
free(s->buf[0]);
|
||||||
|
|
||||||
// Free mmaped area
|
// Free mmaped area
|
||||||
if(s->mmap_area)
|
if(s->mmap_area)
|
||||||
|
|
|
@ -305,7 +305,7 @@ int mp_input_get_keys_from_string(char *name, int max_num_keys,
|
||||||
|
|
||||||
ptr = name;
|
ptr = name;
|
||||||
n = 0;
|
n = 0;
|
||||||
for (end = strchr(ptr, '-'); ptr != NULL; end = strchr(ptr, '-')) {
|
for (end = strchr(ptr, '-'); ; end = strchr(ptr, '-')) {
|
||||||
if (end && end[1] != '\0') {
|
if (end && end[1] != '\0') {
|
||||||
if (end[1] == '-')
|
if (end[1] == '-')
|
||||||
end = &end[1];
|
end = &end[1];
|
||||||
|
|
|
@ -2288,23 +2288,20 @@ bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *l,
|
||||||
if (bstr_equals0(name, dst->name))
|
if (bstr_equals0(name, dst->name))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (l->aliases) {
|
for (int i = 0; l->aliases[i][0]; i++) {
|
||||||
for (int i = 0; l->aliases[i][0]; i++) {
|
const char *aname = l->aliases[i][0];
|
||||||
const char *aname = l->aliases[i][0];
|
const char *alias = l->aliases[i][1];
|
||||||
const char *alias = l->aliases[i][1];
|
const char *opts = l->aliases[i][2];
|
||||||
const char *opts = l->aliases[i][2];
|
if (bstr_equals0(name, aname) && m_obj_list_find(dst, l, bstr0(alias)))
|
||||||
if (bstr_equals0(name, aname) &&
|
{
|
||||||
m_obj_list_find(dst, l, bstr0(alias)))
|
if (opts) {
|
||||||
{
|
dst->init_options = opts;
|
||||||
if (opts) {
|
} else {
|
||||||
dst->init_options = opts;
|
// Assume it's deprecated in this case.
|
||||||
} else {
|
// Also, it's used by the VO code only, so whatever.
|
||||||
// Assume it's deprecated in this case.
|
dst->replaced_name = aname;
|
||||||
// Also, it's used by the VO code only, so whatever.
|
|
||||||
dst->replaced_name = aname;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -438,13 +438,12 @@ ssize_t RarRead(rar_file_t *file, void *data, size_t size)
|
||||||
if (max <= 0)
|
if (max <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
int r = file->s ? stream_read(file->s, data, max) : -1;
|
int r = stream_read(file->s, data, max);
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
total += r;
|
total += r;
|
||||||
if( data )
|
data = (char *)data + r;
|
||||||
data = (char *)data + r;
|
|
||||||
file->i_pos += r;
|
file->i_pos += r;
|
||||||
if (file->i_pos >= chunk_end &&
|
if (file->i_pos >= chunk_end &&
|
||||||
RarSeek(file, file->i_pos))
|
RarSeek(file, file->i_pos))
|
||||||
|
|
Loading…
Reference in New Issue