summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
diff options
context:
space:
mode:
authorEmil Velikov <emil.l.velikov@gmail.com>2021-10-03 18:31:45 +0100
committerDudemanguy <random342@airmail.cc>2021-11-15 14:02:08 +0000
commitb44f522dba55c9e9031328e70209493111eea757 (patch)
tree1b7e417f32dca16c753fc4d8a5c46345c4bceec6 /options/m_option.c
parentf09396ab7d584311a9784006eca53f6379e7218b (diff)
downloadmpv-b44f522dba55c9e9031328e70209493111eea757.tar.bz2
mpv-b44f522dba55c9e9031328e70209493111eea757.tar.xz
options: const annotate all m_opt_choice_alternatives accessors
Constant data, most accessors are good but some were missing the explicit notation. Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'options/m_option.c')
-rw-r--r--options/m_option.c29
1 files changed, 15 insertions, 14 deletions
diff --git a/options/m_option.c b/options/m_option.c
index ec84200ad7..898d0da4f6 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -111,7 +111,7 @@ int m_option_required_params(const m_option_t *opt)
if (opt->flags & M_OPT_OPTIONAL_PARAM)
return 0;
if (opt->type == &m_option_type_choice) {
- struct m_opt_choice_alternatives *alt;
+ const struct m_opt_choice_alternatives *alt;
for (alt = opt->priv; alt->name; alt++) {
if (strcmp(alt->name, "yes") == 0)
return 0;
@@ -620,7 +620,7 @@ const char *m_opt_choice_str(const struct m_opt_choice_alternatives *choices,
static void print_choice_values(struct mp_log *log, const struct m_option *opt)
{
- struct m_opt_choice_alternatives *alt = opt->priv;
+ const struct m_opt_choice_alternatives *alt = opt->priv;
for ( ; alt->name; alt++)
mp_info(log, " %s\n", alt->name[0] ? alt->name : "(passing nothing)");
if (opt->min < opt->max)
@@ -630,7 +630,7 @@ static void print_choice_values(struct mp_log *log, const struct m_option *opt)
static int parse_choice(struct mp_log *log, const struct m_option *opt,
struct bstr name, struct bstr param, void *dst)
{
- struct m_opt_choice_alternatives *alt = opt->priv;
+ const struct m_opt_choice_alternatives *alt = opt->priv;
for ( ; alt->name; alt++) {
if (!bstrcmp0(param, alt->name))
break;
@@ -677,7 +677,7 @@ static void choice_get_min_max(const struct m_option *opt, int *min, int *max)
assert(opt->type == &m_option_type_choice);
*min = INT_MAX;
*max = INT_MIN;
- for (struct m_opt_choice_alternatives *alt = opt->priv; alt->name; alt++) {
+ for (const struct m_opt_choice_alternatives *alt = opt->priv; alt->name; alt++) {
*min = MPMIN(*min, alt->value);
*max = MPMAX(*max, alt->value);
}
@@ -721,7 +721,7 @@ static void add_choice(const m_option_t *opt, void *val, double add, bool wrap)
}
}
- for (struct m_opt_choice_alternatives *alt = opt->priv; alt->name; alt++)
+ for (const struct m_opt_choice_alternatives *alt = opt->priv; alt->name; alt++)
check_choice(dir, ival, &found, &best, alt->value);
if (!found) {
@@ -754,11 +754,12 @@ static int choice_set(const m_option_t *opt, void *dst, struct mpv_node *src)
return r;
}
-static struct m_opt_choice_alternatives *get_choice(const m_option_t *opt,
- const void *val, int *out_val)
+static const struct m_opt_choice_alternatives *get_choice(const m_option_t *opt,
+ const void *val,
+ int *out_val)
{
int v = *(int *)val;
- struct m_opt_choice_alternatives *alt;
+ const struct m_opt_choice_alternatives *alt;
for (alt = opt->priv; alt->name; alt++) {
if (alt->value == v)
return alt;
@@ -776,7 +777,7 @@ static int choice_get(const m_option_t *opt, void *ta_parent,
struct mpv_node *dst, void *src)
{
int ival = 0;
- struct m_opt_choice_alternatives *alt = get_choice(opt, src, &ival);
+ const struct m_opt_choice_alternatives *alt = get_choice(opt, src, &ival);
// If a choice string looks like a number, return it as number
if (alt) {
char *end = NULL;
@@ -808,7 +809,7 @@ static int choice_get(const m_option_t *opt, void *ta_parent,
static char *print_choice(const m_option_t *opt, const void *val)
{
int ival = 0;
- struct m_opt_choice_alternatives *alt = get_choice(opt, val, &ival);
+ const struct m_opt_choice_alternatives *alt = get_choice(opt, val, &ival);
return alt ? talloc_strdup(NULL, alt->name)
: talloc_asprintf(NULL, "%d", ival);
}
@@ -828,7 +829,7 @@ const struct m_option_type m_option_type_choice = {
static int apply_flag(const struct m_option *opt, int *val, bstr flag)
{
- struct m_opt_choice_alternatives *alt;
+ const struct m_opt_choice_alternatives *alt;
for (alt = opt->priv; alt->name; alt++) {
if (bstr_equals0(flag, alt->name)) {
if (*val & alt->value)
@@ -842,8 +843,8 @@ static int apply_flag(const struct m_option *opt, int *val, bstr flag)
static const char *find_next_flag(const struct m_option *opt, int *val)
{
- struct m_opt_choice_alternatives *best = NULL;
- struct m_opt_choice_alternatives *alt;
+ const struct m_opt_choice_alternatives *best = NULL;
+ const struct m_opt_choice_alternatives *alt;
for (alt = opt->priv; alt->name; alt++) {
if (alt->value && (alt->value & (*val)) == alt->value) {
if (!best || av_popcount64(alt->value) > av_popcount64(best->value))
@@ -870,7 +871,7 @@ static int parse_flags(struct mp_log *log, const struct m_option *opt,
mp_fatal(log, "Invalid flag for option %.*s: %.*s\n",
BSTR_P(name), BSTR_P(flag));
mp_info(log, "Valid flags are:\n");
- struct m_opt_choice_alternatives *alt;
+ const struct m_opt_choice_alternatives *alt;
for (alt = opt->priv; alt->name; alt++)
mp_info(log, " %s\n", alt->name);
mp_info(log, "Flags can usually be combined with '+'.\n");