summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-05-06 20:58:54 +0200
committerwm4 <wm4@nowhere>2013-05-06 23:11:11 +0200
commit885c6a2610619ad3ee2b01ae7ec7670f8551d388 (patch)
tree7a9d2d4f9516c417e15e16613bb71a87f1feca3f
parentab776adeceb4b9b6ce7adde5a857ffc1e4b2c4ae (diff)
downloadmpv-885c6a2610619ad3ee2b01ae7ec7670f8551d388.tar.bz2
mpv-885c6a2610619ad3ee2b01ae7ec7670f8551d388.tar.xz
Fix some cppcheck / scan-build warnings
These were found by the cppcheck and scan-build static analyzers. Most of these aren't interesting (the 2 previous commits fix some interesting cases found by these analyzers), and they don't nearly fix all warnings. (Most of the unfixed warnings are spam, things MPlayer never cared about, or false positives.)
-rw-r--r--core/timeline/tl_edl.c2
-rw-r--r--demux/demux_mkv.c2
-rw-r--r--demux/demux_ts.c5
-rw-r--r--stream/cookies.c2
-rw-r--r--stream/dvb_tune.c4
-rw-r--r--stream/http.c2
-rw-r--r--stream/stream_cdda.c2
-rw-r--r--stream/tvi_v4l2.c27
-rw-r--r--sub/find_subfiles.c1
-rw-r--r--sub/subreader.c2
-rw-r--r--video/filter/vf_hqdn3d.c2
-rw-r--r--video/filter/vf_yadif.c2
-rw-r--r--video/out/vo_opengl_old.c2
13 files changed, 12 insertions, 43 deletions
diff --git a/core/timeline/tl_edl.c b/core/timeline/tl_edl.c
index fb8441d322..5ec04ac716 100644
--- a/core/timeline/tl_edl.c
+++ b/core/timeline/tl_edl.c
@@ -275,7 +275,7 @@ void build_edl_timeline(struct MPContext *mpctx)
p->end = *t;
if (*t >= 0 && parts[i].duration) {
*t -= parts[i].duration;
- if (t < 0) {
+ if (*t < 0) {
mp_msg(MSGT_CPLAYER, MSGL_ERR, "EDL: Negative time "
"on line %d!\n", parts[i].lineno);
goto out;
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 86c17ea9a8..06db8302b1 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -1824,6 +1824,8 @@ static int demux_mkv_read_block_lacing(bstr *buffer, int *laces,
}
lace_size[i] = buffer->len - total;
break;
+
+ default: abort();
}
}
diff --git a/demux/demux_ts.c b/demux/demux_ts.c
index 40675fa6f5..8b2a2d84ba 100644
--- a/demux/demux_ts.c
+++ b/demux/demux_ts.c
@@ -1024,11 +1024,6 @@ static demuxer_t *demux_open_ts(demuxer_t * demuxer)
demuxer->priv = priv;
- if(demuxer->stream->type != STREAMTYPE_FILE)
- demuxer->seekable = 1;
- else
- demuxer->seekable = 1;
-
params.atype = params.vtype = params.stype = UNKNOWN;
params.apid = demuxer->audio->id;
diff --git a/stream/cookies.c b/stream/cookies.c
index 5d772b8a6a..a7f01ef420 100644
--- a/stream/cookies.c
+++ b/stream/cookies.c
@@ -112,7 +112,7 @@ static int parse_line(char **ptr, char *cols[6])
/* Loads a file into RAM */
static char *load_file(const char *filename, int64_t * length)
{
- int fd = -1;
+ int fd;
char *buffer = NULL;
mp_msg(MSGT_NETWORK, MSGL_V, "Loading cookie file: %s\n", filename);
diff --git a/stream/dvb_tune.c b/stream/dvb_tune.c
index d5ea8c7b1a..8b24e88ede 100644
--- a/stream/dvb_tune.c
+++ b/stream/dvb_tune.c
@@ -325,7 +325,7 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int
fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth,
fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
{
- int res, hi_lo = 0, dfd;
+ int hi_lo = 0, dfd;
struct dvb_frontend_parameters feparams;
struct dvb_frontend_info fe_info;
@@ -334,7 +334,7 @@ static int tune_it(int fd_frontend, int fd_sec, unsigned int freq, unsigned int
memset(&feparams, 0, sizeof(feparams));
- if ( (res = ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0))
+ if ( ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)
{
mp_msg(MSGT_DEMUX, MSGL_FATAL, "FE_GET_INFO FAILED\n");
return -1;
diff --git a/stream/http.c b/stream/http.c
index eb0ea701b6..2ec7c9d58c 100644
--- a/stream/http.c
+++ b/stream/http.c
@@ -187,9 +187,9 @@ static int scast_streaming_start(stream_t *stream) {
int metaint;
scast_data_t *scast_data;
HTTP_header_t *http_hdr = stream->streaming_ctrl->data;
- int is_ultravox = strcasecmp(stream->streaming_ctrl->url->protocol, "unsv") == 0;
if (!stream || stream->fd < 0 || !http_hdr)
return -1;
+ int is_ultravox = strcasecmp(stream->streaming_ctrl->url->protocol, "unsv") == 0;
if (is_ultravox)
metaint = 0;
else {
diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c
index 6fbd18fcc2..a99150f65d 100644
--- a/stream/stream_cdda.c
+++ b/stream/stream_cdda.c
@@ -312,7 +312,7 @@ static int control(stream_t *stream, int cmd, void *arg)
// returning error.
return STREAM_OK;
}
- seek_sector = track <= 0 ? p->start_sector
+ seek_sector = track == 0 ? p->start_sector
: p->cd->disc_toc[track].dwStartSector;
r = seek(stream, seek_sector * CDIO_CD_FRAMESIZE_RAW);
if (r)
diff --git a/stream/tvi_v4l2.c b/stream/tvi_v4l2.c
index abe455d8bf..06344d1fa9 100644
--- a/stream/tvi_v4l2.c
+++ b/stream/tvi_v4l2.c
@@ -1747,29 +1747,6 @@ static int get_video_framesize(priv_t *priv)
return priv->format.fmt.pix.sizeimage;
}
-//#define DOUBLESPEED
-#ifdef DOUBLESPEED
-// for testing purposes only
-static void read_doublespeed(priv_t *priv)
-{
- char *bufx = calloc(priv->audio_in.blocksize, 2);
- short *s;
- short *d;
- int i;
-
- audio_in_read_chunk(&priv->audio_in, bufx);
- audio_in_read_chunk(&priv->audio_in, bufx+priv->audio_in.blocksize);
-
- s = bufx;
- d = priv->audio_ringbuffer+priv->audio_tail*priv->audio_in.blocksize;
- for (i = 0; i < priv->audio_in.blocksize/2; i++) {
- *d++ = *s++;
- *s++;
- }
-
-}
-#endif
-
static void *audio_grabber(void *data)
{
priv_t *priv = (priv_t*)data;
@@ -1788,12 +1765,8 @@ static void *audio_grabber(void *data)
for (; !priv->shutdown;)
{
-#ifdef DOUBLESPEED
- read_doublespeed(priv);
-#else
if (audio_in_read_chunk(&priv->audio_in, priv->audio_ringbuffer+priv->audio_tail*priv->audio_in.blocksize) < 0)
continue;
-#endif
pthread_mutex_lock(&priv->skew_mutex);
if (priv->first_frame == 0) {
// there is no first frame yet (unlikely to happen)
diff --git a/sub/find_subfiles.c b/sub/find_subfiles.c
index aa8df2ea49..e77015114b 100644
--- a/sub/find_subfiles.c
+++ b/sub/find_subfiles.c
@@ -69,7 +69,6 @@ static struct bstr guess_lang_from_filename(struct bstr name)
struct sub_list {
struct subfn subs[MAX_SUBTITLE_FILES];
- int sid;
void *ctx;
};
diff --git a/sub/subreader.c b/sub/subreader.c
index a109d0c362..090cd0a8b4 100644
--- a/sub/subreader.c
+++ b/sub/subreader.c
@@ -1511,7 +1511,7 @@ if ((suboverlap_enabled == 2) ||
// from a block of sub_to_add+1 subs
placeholder = malloc(sizeof(int *) * counter);
for (i = 0; i < counter; ++i) {
- placeholder[i] = malloc(sizeof(int) * lines_to_add);
+ placeholder[i] = malloc(sizeof(int) * lines_to_add + 1);
for (j = 0; j < lines_to_add; ++j) {
placeholder[i][j] = -1;
}
diff --git a/video/filter/vf_hqdn3d.c b/video/filter/vf_hqdn3d.c
index 4f49f12715..c5d99b2ace 100644
--- a/video/filter/vf_hqdn3d.c
+++ b/video/filter/vf_hqdn3d.c
@@ -62,7 +62,7 @@ static int config(struct vf_instance *vf,
unsigned int flags, unsigned int outfmt){
uninit(vf);
- vf->priv->Line = malloc(width*sizeof(int));
+ vf->priv->Line = malloc(width*sizeof(unsigned int));
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
}
diff --git a/video/filter/vf_yadif.c b/video/filter/vf_yadif.c
index 01c3787048..017e7c515c 100644
--- a/video/filter/vf_yadif.c
+++ b/video/filter/vf_yadif.c
@@ -393,7 +393,7 @@ static int config(struct vf_instance *vf,
vf->priv->stride[i]= w;
for(j=0; j<3; j++)
- vf->priv->ref[j][i]= (char *)malloc(w*h*sizeof(uint8_t))+3*w;
+ vf->priv->ref[j][i]= (char *)malloc(w*h)+3*w;
}
return vf_next_config(vf,width,height,d_width,d_height,flags,outfmt);
diff --git a/video/out/vo_opengl_old.c b/video/out/vo_opengl_old.c
index 7556bccdff..cd92acfaa0 100644
--- a/video/out/vo_opengl_old.c
+++ b/video/out/vo_opengl_old.c
@@ -565,7 +565,7 @@ static void replace_var_char(char **text, const char *name, char replace)
// Append template to *text. Possibly initialize *text if it's NULL.
static void append_template(char **text, const char* template)
{
- if (!text)
+ if (!*text)
*text = talloc_strdup(NULL, template);
else
*text = talloc_strdup_append(*text, template);