Remove some unneeded NULL checks

Found by Coverity; also see commit 85fb2af3.
This commit is contained in:
wm4 2014-11-21 09:58:09 +01:00
parent 38f4ec69d1
commit e082c2c3df
4 changed files with 22 additions and 25 deletions

View File

@ -78,7 +78,6 @@ static int control(struct af_instance* af, int cmd, void* arg)
int mapsize;
// Free previous buffers
if (s->buf)
free(s->buf[0]);
// unmap previous area
@ -94,8 +93,10 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Allocate new buffers (as one continuous block)
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");
return AF_ERROR;
}
for(i = 1; i < af->data->nch; i++)
s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;
@ -147,7 +148,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
static void uninit( struct af_instance* af )
{
af_export_t* s = af->priv;
if (s->buf)
free(s->buf[0]);
// Free mmaped area

View File

@ -305,7 +305,7 @@ int mp_input_get_keys_from_string(char *name, int max_num_keys,
ptr = name;
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[1] == '-')
end = &end[1];

View File

@ -2288,13 +2288,11 @@ bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *l,
if (bstr_equals0(name, dst->name))
return true;
}
if (l->aliases) {
for (int i = 0; l->aliases[i][0]; i++) {
const char *aname = l->aliases[i][0];
const char *alias = l->aliases[i][1];
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;
@ -2306,7 +2304,6 @@ bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *l,
return true;
}
}
}
return false;
}

View File

@ -438,12 +438,11 @@ ssize_t RarRead(rar_file_t *file, void *data, size_t size)
if (max <= 0)
break;
int r = file->s ? stream_read(file->s, data, max) : -1;
int r = stream_read(file->s, data, max);
if (r <= 0)
break;
total += r;
if( data )
data = (char *)data + r;
file->i_pos += r;
if (file->i_pos >= chunk_end &&