1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-25 16:33:02 +00:00

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,8 +78,7 @@ static int control(struct af_instance* af, int cmd, void* arg)
int mapsize;
// Free previous buffers
if (s->buf)
free(s->buf[0]);
free(s->buf[0]);
// unmap previous 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)
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,8 +148,8 @@ 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(s->buf[0]);
// Free mmaped area
if(s->mmap_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,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))
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 (opts) {
dst->init_options = opts;
} else {
// Assume it's deprecated in this case.
// Also, it's used by the VO code only, so whatever.
dst->replaced_name = aname;
}
return true;
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 (opts) {
dst->init_options = opts;
} else {
// Assume it's deprecated in this case.
// Also, it's used by the VO code only, so whatever.
dst->replaced_name = aname;
}
return true;
}
}
return false;

View File

@ -438,13 +438,12 @@ 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;
data = (char *)data + r;
file->i_pos += r;
if (file->i_pos >= chunk_end &&
RarSeek(file, file->i_pos))