Add more const

While I'm not very fond of "const", it's important for declarations
(it decides whether a symbol is emitted in a read-only or read/write
section). Fix all these cases, so we have writeable global data only
when we really need.
This commit is contained in:
wm4
2014-06-10 23:56:05 +02:00
parent ad4b7a8c96
commit 99f5fef0ea
82 changed files with 202 additions and 206 deletions

View File

@@ -893,7 +893,7 @@ unsigned char *stream_read_line(stream_t *s, unsigned char *mem, int max,
return mem;
}
static const char *bom[3] = {"\xEF\xBB\xBF", "\xFF\xFE", "\xFE\xFF"};
static const char *const bom[3] = {"\xEF\xBB\xBF", "\xFF\xFE", "\xFE\xFF"};
// Return utf16 argument for stream_read_line
int stream_skip_bom(struct stream *s)

View File

@@ -129,12 +129,12 @@ typedef struct stream_info_st {
const char *name;
// opts is set from ->opts
int (*open)(struct stream *st);
const char **protocols;
const char *const *protocols;
int priv_size;
const void *priv_defaults;
void *(*get_defaults)(struct stream *st);
const struct m_option *options;
const char **url_options;
const char *const *url_options;
bool stream_filter;
bool can_write;
} stream_info_t;

View File

@@ -31,5 +31,5 @@ static int open_f(stream_t *stream)
const stream_info_t stream_info_avdevice = {
.name = "avdevice",
.open = open_f,
.protocols = (const char*[]){ "avdevice", "av", NULL },
.protocols = (const char*const[]){ "avdevice", "av", NULL },
};

View File

@@ -97,7 +97,7 @@ const struct m_sub_options stream_cdda_conf = {
},
};
static const char *cdtext_name[] = {
static const char *const cdtext_name[] = {
#ifdef OLD_API
[CDTEXT_ARRANGER] = "Arranger",
[CDTEXT_COMPOSER] = "Composer",
@@ -411,11 +411,11 @@ static void *get_defaults(stream_t *st)
const stream_info_t stream_info_cdda = {
.name = "cdda",
.open = open_cdda,
.protocols = (const char*[]){"cdda", NULL },
.protocols = (const char*const[]){"cdda", NULL },
.priv_size = sizeof(cdda_priv),
.get_defaults = get_defaults,
.options = cdda_params_fields,
.url_options = (const char*[]){
.url_options = (const char*const[]){
"hostname=span",
"port=speed",
"filename=device",

View File

@@ -823,11 +823,11 @@ static void *get_defaults(stream_t *st)
const stream_info_t stream_info_dvb = {
.name = "dvbin",
.open = dvb_open,
.protocols = (const char*[]){ "dvb", NULL },
.protocols = (const char*const[]){ "dvb", NULL },
.priv_size = sizeof(dvb_priv_t),
.get_defaults = get_defaults,
.options = stream_params,
.url_options = (const char*[]){
.url_options = (const char*const[]){
"hostname=prog",
"username=card",
NULL

View File

@@ -947,11 +947,11 @@ static int ifo_stream_open (stream_t *stream)
const stream_info_t stream_info_dvd = {
.name = "dvd",
.open = open_s,
.protocols = (const char*[]){ "dvd", NULL },
.protocols = (const char*const[]){ "dvd", NULL },
.priv_size = sizeof(dvd_priv_t),
.priv_defaults = &stream_priv_dflts,
.options = stream_opts_fields,
.url_options = (const char*[]){
.url_options = (const char*const[]){
"hostname=title",
"filename=device",
NULL
@@ -961,5 +961,5 @@ const stream_info_t stream_info_dvd = {
const stream_info_t stream_info_ifo = {
.name = "ifo",
.open = ifo_stream_open,
.protocols = (const char*[]){ "file", "", NULL },
.protocols = (const char*const[]){ "file", "", NULL },
};

View File

@@ -125,7 +125,7 @@ void dvd_set_speed(stream_t *stream, char *device, unsigned speed)
*/
int mp_dvdtimetomsec(dvd_time_t *dt)
{
static int framerates[4] = {0, 2500, 0, 2997};
int framerates[4] = {0, 2500, 0, 2997};
int framerate = framerates[(dt->frame_u & 0xc0) >> 6];
int msec = (((dt->hour & 0xf0) >> 3) * 5 + (dt->hour & 0x0f)) * 3600000;
msec += (((dt->minute & 0xf0) >> 3) * 5 + (dt->minute & 0x0f)) * 60000;

View File

@@ -77,7 +77,7 @@ static const m_option_t stream_opts_fields[] = {
};
#define DNE(e) [e] = # e
static char *mp_dvdnav_events[] = {
static const char *const mp_dvdnav_events[] = {
DNE(DVDNAV_BLOCK_OK),
DNE(DVDNAV_NOP),
DNE(DVDNAV_STILL_FRAME),
@@ -93,7 +93,7 @@ static char *mp_dvdnav_events[] = {
DNE(DVDNAV_WAIT),
};
static char *mp_nav_cmd_types[] = {
static const char *const mp_nav_cmd_types[] = {
DNE(MP_NAV_CMD_NONE),
DNE(MP_NAV_CMD_ENABLE),
DNE(MP_NAV_CMD_DRAIN_OK),
@@ -103,7 +103,7 @@ static char *mp_nav_cmd_types[] = {
DNE(MP_NAV_CMD_MOUSE_POS),
};
static char *mp_nav_event_types[] = {
static const char *const mp_nav_event_types[] = {
DNE(MP_NAV_EVENT_NONE),
DNE(MP_NAV_EVENT_RESET),
DNE(MP_NAV_EVENT_RESET_CLUT),
@@ -737,11 +737,11 @@ static int open_s(stream_t *stream)
const stream_info_t stream_info_dvdnav = {
.name = "dvdnav",
.open = open_s,
.protocols = (const char*[]){ "dvdnav", NULL },
.protocols = (const char*const[]){ "dvdnav", NULL },
.priv_size = sizeof(struct priv),
.priv_defaults = &stream_priv_dflts,
.options = stream_opts_fields,
.url_options = (const char*[]){
.url_options = (const char*const[]){
"hostname=title",
"filename=device",
NULL

View File

@@ -14,5 +14,5 @@ static int s_open (struct stream *stream)
const stream_info_t stream_info_edl = {
.name = "edl",
.open = s_open,
.protocols = (const char*[]){"edl", NULL},
.protocols = (const char*const[]){"edl", NULL},
};

View File

@@ -279,6 +279,6 @@ static int open_f(stream_t *stream)
const stream_info_t stream_info_file = {
.name = "file",
.open = open_f,
.protocols = (const char*[]){ "file", "", NULL },
.protocols = (const char*const[]){ "file", "", NULL },
.can_write = true,
};

View File

@@ -315,7 +315,7 @@ done:
const stream_info_t stream_info_ffmpeg = {
.name = "ffmpeg",
.open = open_f,
.protocols = (const char*[]){
.protocols = (const char *const[]){
"lavf", "ffmpeg", "rtmp", "rtsp", "http", "https", "mms", "mmst", "mmsh",
"mmshttp", "udp", "ftp", "rtp", "httpproxy", "hls", "rtmpe", "rtmps",
"rtmpt", "rtmpte", "rtmpts", "srtp", "tcp", "udp", "tls", "unix", "sftp",

View File

@@ -77,5 +77,5 @@ static int open_f(stream_t *stream)
const stream_info_t stream_info_memory = {
.name = "memory",
.open = open_f,
.protocols = (const char*[]){ "memory", NULL },
.protocols = (const char*const[]){ "memory", NULL },
};

View File

@@ -41,5 +41,5 @@ mf_stream_open (stream_t *stream)
const stream_info_t stream_info_mf = {
.name = "mf",
.open = mf_stream_open,
.protocols = (const char*[]){ "mf", NULL },
.protocols = (const char*const[]){ "mf", NULL },
};

View File

@@ -33,6 +33,6 @@ static int open_s(stream_t *stream)
const stream_info_t stream_info_null = {
.name = "null",
.open = open_s,
.protocols = (const char*[]){ "null", NULL },
.protocols = (const char*const[]){ "null", NULL },
.can_write = true,
};

View File

@@ -1722,5 +1722,5 @@ static int pvr_stream_control(struct stream *s, int cmd, void *arg)
const stream_info_t stream_info_pvr = {
.name = "pvr",
.open = pvr_stream_open,
.protocols = (const char*[]){ "pvr", NULL },
.protocols = (const char*const[]){ "pvr", NULL },
};

View File

@@ -199,7 +199,7 @@ static int rar_filter_open(stream_t *stream)
const stream_info_t stream_info_rar_entry = {
.name = "rar_entry",
.open = rar_entry_open,
.protocols = (const char*[]){ "rar", NULL },
.protocols = (const char*const[]){ "rar", NULL },
};
const stream_info_t stream_info_rar_filter = {

View File

@@ -140,6 +140,6 @@ static int open_f (stream_t *stream)
const stream_info_t stream_info_smb = {
.name = "smb",
.open = open_f,
.protocols = (const char*[]){"smb", NULL},
.protocols = (const char*const[]){"smb", NULL},
.can_write = true, //who's gonna do that?
};

View File

@@ -58,13 +58,13 @@ tv_stream_open (stream_t *stream)
const stream_info_t stream_info_tv = {
.name = "tv",
.open = tv_stream_open,
.protocols = (const char*[]){ "tv", NULL },
.protocols = (const char*const[]){ "tv", NULL },
.priv_size = sizeof(tv_param_t),
.priv_defaults = &(const struct tv_stream_params){
.input = -1,
},
.options = stream_opts_fields,
.url_options = (const char*[]){
.url_options = (const char*const[]){
"hostname=channel",
"filename=input",
NULL

View File

@@ -60,7 +60,7 @@ extern const tvi_info_t tvi_info_dummy;
extern const tvi_info_t tvi_info_v4l2;
/** List of drivers in autodetection order */
static const tvi_info_t* tvi_driver_list[]={
static const tvi_info_t *const tvi_driver_list[]={
#if HAVE_TV_V4L2
&tvi_info_v4l2,
#endif
@@ -1225,7 +1225,7 @@ static int demux_tv_control(demuxer_t *demuxer, int cmd, void *arg)
return DEMUXER_CTRL_OK;
}
demuxer_desc_t demuxer_desc_tv = {
const demuxer_desc_t demuxer_desc_tv = {
.name = "tv",
.desc = "TV card demuxer",
.type = DEMUXER_TYPE_TV,