From 99f5fef0ea5671d41fb7b737fbc3e4236542a757 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Jun 2014 23:56:05 +0200 Subject: 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. --- stream/stream.c | 2 +- stream/stream.h | 4 ++-- stream/stream_avdevice.c | 2 +- stream/stream_cdda.c | 6 +++--- stream/stream_dvb.c | 4 ++-- stream/stream_dvd.c | 6 +++--- stream/stream_dvd_common.c | 2 +- stream/stream_dvdnav.c | 10 +++++----- stream/stream_edl.c | 2 +- stream/stream_file.c | 2 +- stream/stream_lavf.c | 2 +- stream/stream_memory.c | 2 +- stream/stream_mf.c | 2 +- stream/stream_null.c | 2 +- stream/stream_pvr.c | 2 +- stream/stream_rar.c | 2 +- stream/stream_smb.c | 2 +- stream/stream_tv.c | 4 ++-- stream/tv.c | 4 ++-- 19 files changed, 31 insertions(+), 31 deletions(-) (limited to 'stream') diff --git a/stream/stream.c b/stream/stream.c index 171d6781a1..2a6136f036 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -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) diff --git a/stream/stream.h b/stream/stream.h index cd81e7daeb..fc8969d649 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -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; diff --git a/stream/stream_avdevice.c b/stream/stream_avdevice.c index b4983b507a..cd6fd1a572 100644 --- a/stream/stream_avdevice.c +++ b/stream/stream_avdevice.c @@ -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 }, }; diff --git a/stream/stream_cdda.c b/stream/stream_cdda.c index b11671333a..8ad7608604 100644 --- a/stream/stream_cdda.c +++ b/stream/stream_cdda.c @@ -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", diff --git a/stream/stream_dvb.c b/stream/stream_dvb.c index e71a41e960..1462d568e7 100644 --- a/stream/stream_dvb.c +++ b/stream/stream_dvb.c @@ -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 diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index 3ab7149a46..d67f14a5c1 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -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 }, }; diff --git a/stream/stream_dvd_common.c b/stream/stream_dvd_common.c index 677b70a1bc..a9a6895384 100644 --- a/stream/stream_dvd_common.c +++ b/stream/stream_dvd_common.c @@ -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; diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index 20382a14e4..b2b10d5bf4 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -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 diff --git a/stream/stream_edl.c b/stream/stream_edl.c index ac1e1f9406..4873047cc2 100644 --- a/stream/stream_edl.c +++ b/stream/stream_edl.c @@ -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}, }; diff --git a/stream/stream_file.c b/stream/stream_file.c index 6b9c6d5471..12bea3554c 100644 --- a/stream/stream_file.c +++ b/stream/stream_file.c @@ -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, }; diff --git a/stream/stream_lavf.c b/stream/stream_lavf.c index b8f90cc9b1..82aa4ab820 100644 --- a/stream/stream_lavf.c +++ b/stream/stream_lavf.c @@ -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", diff --git a/stream/stream_memory.c b/stream/stream_memory.c index b748c9264c..a451e0f722 100644 --- a/stream/stream_memory.c +++ b/stream/stream_memory.c @@ -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 }, }; diff --git a/stream/stream_mf.c b/stream/stream_mf.c index 05c5bb60bd..ac2751b031 100644 --- a/stream/stream_mf.c +++ b/stream/stream_mf.c @@ -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 }, }; diff --git a/stream/stream_null.c b/stream/stream_null.c index 8fca1282a5..8bd0fb7c51 100644 --- a/stream/stream_null.c +++ b/stream/stream_null.c @@ -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, }; diff --git a/stream/stream_pvr.c b/stream/stream_pvr.c index 5ba42c4048..7fc521fa28 100644 --- a/stream/stream_pvr.c +++ b/stream/stream_pvr.c @@ -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 }, }; diff --git a/stream/stream_rar.c b/stream/stream_rar.c index d40a8ca545..ee76d62909 100644 --- a/stream/stream_rar.c +++ b/stream/stream_rar.c @@ -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 = { diff --git a/stream/stream_smb.c b/stream/stream_smb.c index f2fb2fd01a..96f8ec69bd 100644 --- a/stream/stream_smb.c +++ b/stream/stream_smb.c @@ -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? }; diff --git a/stream/stream_tv.c b/stream/stream_tv.c index 3ca4973d1e..b4181ac286 100644 --- a/stream/stream_tv.c +++ b/stream/stream_tv.c @@ -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 diff --git a/stream/tv.c b/stream/tv.c index c9791a2b50..17b1f9ecb9 100644 --- a/stream/tv.c +++ b/stream/tv.c @@ -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, -- cgit v1.2.3