History

Remove some unneeded NULL checks

Found by Coverity; also see commit 85fb2af3.

wm4 committed 11 years ago

Commit e082c2c1 parent 38f4ec64 files · +22 −25Browse files

Unified · Split

4 files
  1. audio/filter/af_export.c +6 −5
  2. input/keycodes.c +1 −1
  3. options/m_option.c +13 −16
  4. stream/rar.c +2 −3
audio/filter/af_export.c+6−5
@@ -78,8 +78,7 @@ static int control(struct af_instance* af, int cmd, void* arg) · 77 unmodified lines
78 int mapsize;78 int mapsize;
79 79
80 // Free previous buffers80 // Free previous buffers
81 if (s->buf)81 free(s->buf[0]);
82 free(s->buf[0]);
83 82
84 // unmap previous area83 // unmap previous area
85 if(s->mmap_area)84 if(s->mmap_area)
@@ -94,8 +93,10 @@ static int control(struct af_instance* af, int cmd, void* arg) · 8 unmodified lines
94 93
95 // Allocate new buffers (as one continuous block)94 // Allocate new buffers (as one continuous block)
96 s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps);95 s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps);
97 if(NULL == s->buf[0])96 if(NULL == s->buf[0]) {
98 MP_FATAL(af, "Out of memory\n");97 MP_FATAL(af, "Out of memory\n");
98 return AF_ERROR;
99 }
99 for(i = 1; i < af->data->nch; i++)100 for(i = 1; i < af->data->nch; i++)
100 s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;101 s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;
101 102
@@ -147,8 +148,8 @@ static int control(struct af_instance* af, int cmd, void* arg) · 45 unmodified lines
147static void uninit( struct af_instance* af )148static void uninit( struct af_instance* af )
148{149{
149 af_export_t* s = af->priv;150 af_export_t* s = af->priv;
150 if (s->buf)151
151 free(s->buf[0]);152 free(s->buf[0]);
152 153
153 // Free mmaped area154 // Free mmaped area
154 if(s->mmap_area)155 if(s->mmap_area)
input/keycodes.c+1−1
@@ -305,7 +305,7 @@ int mp_input_get_keys_from_string(char *name, int max_num_keys, · 304 unmodified lines
305 305
306 ptr = name;306 ptr = name;
307 n = 0;307 n = 0;
308 for (end = strchr(ptr, '-'); ptr != NULL; end = strchr(ptr, '-')) {308 for (end = strchr(ptr, '-'); ; end = strchr(ptr, '-')) {
309 if (end && end[1] != '\0') {309 if (end && end[1] != '\0') {
310 if (end[1] == '-')310 if (end[1] == '-')
311 end = &end[1];311 end = &end[1];
options/m_option.c+13−16
@@ -2288,23 +2288,20 @@ bool m_obj_list_find(struct m_obj_desc *dst, const struct m_obj_list *l, · 2287 unmodified lines
2288 if (bstr_equals0(name, dst->name))2288 if (bstr_equals0(name, dst->name))
2289 return true;2289 return true;
2290 }2290 }
2291 if (l->aliases) {2291 for (int i = 0; l->aliases[i][0]; i++) {
2292 for (int i = 0; l->aliases[i][0]; i++) {2292 const char *aname = l->aliases[i][0];
2293 const char *aname = l->aliases[i][0];2293 const char *alias = l->aliases[i][1];
2294 const char *alias = l->aliases[i][1];2294 const char *opts = l->aliases[i][2];
2295 const char *opts = l->aliases[i][2];2295 if (bstr_equals0(name, aname) && m_obj_list_find(dst, l, bstr0(alias)))
2296 if (bstr_equals0(name, aname) &&2296 {
2297 m_obj_list_find(dst, l, bstr0(alias)))2297 if (opts) {
2298 {2298 dst->init_options = opts;
2299 if (opts) {2299 } else {
2300 dst->init_options = opts;2300 // Assume it's deprecated in this case.
2301 } else {2301 // Also, it's used by the VO code only, so whatever.
2302 // Assume it's deprecated in this case.2302 dst->replaced_name = aname;
2303 // Also, it's used by the VO code only, so whatever.
2304 dst->replaced_name = aname;
2305 }
2306 return true;
2307 }2303 }
2304 return true;
2308 }2305 }
2309 }2306 }
2310 return false;2307 return false;
stream/rar.c+2−3
@@ -438,13 +438,12 @@ ssize_t RarRead(rar_file_t *file, void *data, size_t size) · 437 unmodified lines
438 if (max <= 0)438 if (max <= 0)
439 break;439 break;
440 440
441 int r = file->s ? stream_read(file->s, data, max) : -1;441 int r = stream_read(file->s, data, max);
442 if (r <= 0)442 if (r <= 0)
443 break;443 break;
444 444
445 total += r;445 total += r;
446 if( data )446 data = (char *)data + r;
447 data = (char *)data + r;
448 file->i_pos += r;447 file->i_pos += r;
449 if (file->i_pos >= chunk_end &&448 if (file->i_pos >= chunk_end &&
450 RarSeek(file, file->i_pos))449 RarSeek(file, file->i_pos))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t