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
7878 int mapsize;
7979
8080 // Free previous buffers
81− if (s->buf)
82− free(s->buf[0]);
81+ free(s->buf[0]);
8382
8483 // unmap previous area
8584 if(s->mmap_area)
@@ -94,8 +93,10 @@ static int control(struct af_instance* af, int cmd, void* arg) · 8 unmodified lines
9493
9594 // Allocate new buffers (as one continuous block)
9695 s->buf[0] = calloc(s->sz*af->data->nch, af->data->bps);
97− if(NULL == s->buf[0])
96+ if(NULL == s->buf[0]) {
9897 MP_FATAL(af, "Out of memory\n");
98+ return AF_ERROR;
99+ }
99100 for(i = 1; i < af->data->nch; i++)
100101 s->buf[i] = (uint8_t *)s->buf[0] + i*s->sz*af->data->bps;
101102
@@ -147,8 +148,8 @@ static int control(struct af_instance* af, int cmd, void* arg) · 45 unmodified lines
147148 static void uninit( struct af_instance* af )
148149 {
149150 af_export_t* s = af->priv;
150− if (s->buf)
151− free(s->buf[0]);
151+
152+ free(s->buf[0]);
152153
153154 // Free mmaped area
154155 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
305305
306306 ptr = name;
307307 n = 0;
308− for (end = strchr(ptr, '-'); ptr != NULL; end = strchr(ptr, '-')) {
308+ for (end = strchr(ptr, '-'); ; end = strchr(ptr, '-')) {
309309 if (end && end[1] != '\0') {
310310 if (end[1] == '-')
311311 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
22882288 if (bstr_equals0(name, dst->name))
22892289 return true;
22902290 }
2291− if (l->aliases) {
2292− for (int i = 0; l->aliases[i][0]; i++) {
2293− const char *aname = l->aliases[i][0];
2294− const char *alias = l->aliases[i][1];
2295− const char *opts = l->aliases[i][2];
2296− if (bstr_equals0(name, aname) &&
2297− m_obj_list_find(dst, l, bstr0(alias)))
2298− {
2299− if (opts) {
2300− dst->init_options = opts;
2301− } else {
2302− // Assume it's deprecated in this case.
2303− // Also, it's used by the VO code only, so whatever.
2304− dst->replaced_name = aname;
2305− }
2306− return true;
2291+ for (int i = 0; l->aliases[i][0]; i++) {
2292+ const char *aname = l->aliases[i][0];
2293+ const char *alias = l->aliases[i][1];
2294+ const char *opts = l->aliases[i][2];
2295+ if (bstr_equals0(name, aname) && m_obj_list_find(dst, l, bstr0(alias)))
2296+ {
2297+ if (opts) {
2298+ dst->init_options = opts;
2299+ } else {
2300+ // Assume it's deprecated in this case.
2301+ // Also, it's used by the VO code only, so whatever.
2302+ dst->replaced_name = aname;
23072303 }
2304+ return true;
23082305 }
23092306 }
23102307 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
438438 if (max <= 0)
439439 break;
440440
441− int r = file->s ? stream_read(file->s, data, max) : -1;
441+ int r = stream_read(file->s, data, max);
442442 if (r <= 0)
443443 break;
444444
445445 total += r;
446− if( data )
447− data = (char *)data + r;
446+ data = (char *)data + r;
448447 file->i_pos += r;
449448 if (file->i_pos >= chunk_end &&
450449 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