summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-06-10 23:56:05 +0200
committerwm4 <wm4@nowhere>2014-06-11 00:39:14 +0200
commit99f5fef0ea5671d41fb7b737fbc3e4236542a757 (patch)
treec01912d00e64a7783cb7109b3d1e2dc2390b3a7d /player
parentad4b7a8c967f9d13ceeaffff25d156d848b68445 (diff)
downloadmpv-99f5fef0ea5671d41fb7b737fbc3e4236542a757.tar.bz2
mpv-99f5fef0ea5671d41fb7b737fbc3e4236542a757.tar.xz
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.
Diffstat (limited to 'player')
-rw-r--r--player/client.c6
-rw-r--r--player/client.h2
-rw-r--r--player/command.c10
-rw-r--r--player/configfiles.c2
-rw-r--r--player/loadfile.c4
-rw-r--r--player/lua.c4
-rw-r--r--player/scripting.c2
7 files changed, 15 insertions, 15 deletions
diff --git a/player/client.c b/player/client.c
index ed99f6f34e..ececec37f6 100644
--- a/player/client.c
+++ b/player/client.c
@@ -1169,7 +1169,7 @@ static bool match_property(const char *a, const char *b)
}
// Broadcast that properties have changed.
-void mp_client_property_change(struct MPContext *mpctx, const char **list)
+void mp_client_property_change(struct MPContext *mpctx, const char *const *list)
{
struct mp_client_api *clients = mpctx->clients;
@@ -1340,7 +1340,7 @@ unsigned long mpv_client_api_version(void)
return MPV_CLIENT_API_VERSION;
}
-static const char *err_table[] = {
+static const char *const err_table[] = {
[-MPV_ERROR_SUCCESS] = "success",
[-MPV_ERROR_EVENT_QUEUE_FULL] = "event queue full",
[-MPV_ERROR_NOMEM] = "memory allocation failed",
@@ -1367,7 +1367,7 @@ const char *mpv_error_string(int error)
return name ? name : "unknown error";
}
-static const char *event_table[] = {
+static const char *const event_table[] = {
[MPV_EVENT_NONE] = "none",
[MPV_EVENT_SHUTDOWN] = "shutdown",
[MPV_EVENT_LOG_MESSAGE] = "log-message",
diff --git a/player/client.h b/player/client.h
index e9d41d8c09..af94778a55 100644
--- a/player/client.h
+++ b/player/client.h
@@ -17,7 +17,7 @@ int mp_clients_num(struct MPContext *mpctx);
void mp_client_broadcast_event(struct MPContext *mpctx, int event, void *data);
int mp_client_send_event(struct MPContext *mpctx, const char *client_name,
int event, void *data);
-void mp_client_property_change(struct MPContext *mpctx, const char **list);
+void mp_client_property_change(struct MPContext *mpctx, const char *const *list);
struct mpv_handle *mp_new_client(struct mp_client_api *clients, const char *name);
struct mp_log *mp_client_get_log(struct mpv_handle *ctx);
diff --git a/player/command.c b/player/command.c
index 315013b0e8..87c91f295e 100644
--- a/player/command.c
+++ b/player/command.c
@@ -2597,8 +2597,8 @@ static const m_option_t mp_properties[] = {
};
// Each entry describes which properties an event (possibly) changes.
-#define E(x, ...) [x] = (const char*[]){__VA_ARGS__, NULL}
-const char **mp_event_property_change[] = {
+#define E(x, ...) [x] = (const char*const[]){__VA_ARGS__, NULL}
+static const char *const *const mp_event_property_change[] = {
E(MPV_EVENT_START_FILE, "*"),
E(MPV_EVENT_END_FILE, "*"),
E(MPV_EVENT_FILE_LOADED, "*"),
@@ -2690,7 +2690,7 @@ void property_print_help(struct mp_log *log)
* terminal output if there is no video; it'll be a label shown together with
* percentage.
*/
-static struct property_osd_display {
+static const struct property_osd_display {
// property name
const char *name;
// name used on OSD
@@ -2763,7 +2763,7 @@ static void show_property_osd(MPContext *mpctx, const char *pname, int osd_mode)
{
struct MPOpts *opts = mpctx->opts;
struct m_option prop = {0};
- struct property_osd_display *p;
+ const struct property_osd_display *p;
const char *name = pname;
if (mp_property_do(pname, M_PROPERTY_GET_TYPE, &prop, mpctx) <= 0)
@@ -2875,7 +2875,7 @@ static bool reinit_filters(MPContext *mpctx, enum stream_type mediatype)
return false;
}
-static const char *filter_opt[STREAM_TYPE_COUNT] = {
+static const char *const filter_opt[STREAM_TYPE_COUNT] = {
[STREAM_VIDEO] = "vf",
[STREAM_AUDIO] = "af",
};
diff --git a/player/configfiles.c b/player/configfiles.c
index 94b8e33f85..9b20f5af71 100644
--- a/player/configfiles.c
+++ b/player/configfiles.c
@@ -207,7 +207,7 @@ exit:
return res;
}
-static const char *backup_properties[] = {
+static const char *const backup_properties[] = {
"options/osd-level",
//"loop",
"options/speed",
diff --git a/player/loadfile.c b/player/loadfile.c
index 712ba58f02..43cb127e5a 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -826,7 +826,7 @@ static void open_subtitles_from_resolve(struct MPContext *mpctx)
}
}
-static const char *font_mimetypes[] = {
+static const char *const font_mimetypes[] = {
"application/x-truetype-font",
"application/vnd.ms-opentype",
"application/x-font-ttf",
@@ -834,7 +834,7 @@ static const char *font_mimetypes[] = {
NULL
};
-static const char *font_exts[] = {".ttf", ".ttc", ".otf", NULL};
+static const char *const font_exts[] = {".ttf", ".ttc", ".otf", NULL};
static bool attachment_is_font(struct mp_log *log, struct demux_attachment *att)
{
diff --git a/player/lua.c b/player/lua.c
index 689be1896b..1da26f9f2b 100644
--- a/player/lua.c
+++ b/player/lua.c
@@ -49,7 +49,7 @@
// List of builtin modules and their contents as strings.
// All these are generated from player/lua/*.lua
-static const char *builtin_lua_scripts[][2] = {
+static const char * const builtin_lua_scripts[][2] = {
{"mp.defaults",
# include "player/lua/defaults.inc"
},
@@ -1106,7 +1106,7 @@ static const struct fn_entry main_fns[] = {
{0}
};
-static struct fn_entry utils_fns[] = {
+static const struct fn_entry utils_fns[] = {
FN_ENTRY(readdir),
FN_ENTRY(split_path),
FN_ENTRY(join_path),
diff --git a/player/scripting.c b/player/scripting.c
index 5f072be1ca..7b3d408030 100644
--- a/player/scripting.c
+++ b/player/scripting.c
@@ -36,7 +36,7 @@
extern const struct mp_scripting mp_scripting_lua;
-static const struct mp_scripting *scripting_backends[] = {
+static const struct mp_scripting *const scripting_backends[] = {
#if HAVE_LUA
&mp_scripting_lua,
#endif