mirror of https://github.com/mpv-player/mpv
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.)
This commit is contained in:
parent
ab776adece
commit
885c6a2610
|
@ -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;
|
||||
|
|
|
@ -1824,6 +1824,8 @@ static int demux_mkv_read_block_lacing(bstr *buffer, int *laces,
|
|||
}
|
||||
lace_size[i] = buffer->len - total;
|
||||
break;
|
||||
|
||||
default: abort();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue