aboutsummaryrefslogtreecommitdiffhomepage
path: root/options/m_config.c
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2015-11-06 21:12:20 +0100
committerGravatar wm4 <wm4@nowhere>2015-11-06 21:12:20 +0100
commit9693e0f57ac75bd5c5d8313dd933989dd3e64d31 (patch)
treed60148c9d7906da869157f8d9b5aa49042af5543 /options/m_config.c
parent647b360a0aa0a3f8cce75812f9d7eac5a78b7a06 (diff)
Remove some VLAs
They are evil and should be eradicated. Some of these were pretty dumb anyway. There are probably some more around in platform specific code or other code not enabled by default on Linux.
Diffstat (limited to 'options/m_config.c')
-rw-r--r--options/m_config.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/options/m_config.c b/options/m_config.c
index c39f3ab41a..0f112dcefb 100644
--- a/options/m_config.c
+++ b/options/m_config.c
@@ -115,7 +115,6 @@ static int parse_profile(struct m_config *config, const struct m_option *opt,
static int show_profile(struct m_config *config, bstr param)
{
struct m_profile *p;
- int i, j;
if (!param.len)
return M_OPT_MISSING_PARAM;
if (!(p = m_config_get_profile(config, param))) {
@@ -126,25 +125,18 @@ static int show_profile(struct m_config *config, bstr param)
MP_INFO(config, "Profile %s: %s\n", p->name,
p->desc ? p->desc : "");
config->profile_depth++;
- for (i = 0; i < p->num_opts; i++) {
- char spc[config->profile_depth + 1];
- for (j = 0; j < config->profile_depth; j++)
- spc[j] = ' ';
- spc[config->profile_depth] = '\0';
-
- MP_INFO(config, "%s%s=%s\n", spc, p->opts[2 * i], p->opts[2 * i + 1]);
+ for (int i = 0; i < p->num_opts; i++) {
+ MP_INFO(config, "%*s%s=%s\n", config->profile_depth, "",
+ p->opts[2 * i], p->opts[2 * i + 1]);
if (config->profile_depth < MAX_PROFILE_DEPTH
&& !strcmp(p->opts[2*i], "profile")) {
char *e, *list = p->opts[2 * i + 1];
while ((e = strchr(list, ','))) {
int l = e - list;
- char tmp[l+1];
if (!l)
continue;
- memcpy(tmp, list, l);
- tmp[l] = '\0';
- show_profile(config, bstr0(tmp));
+ show_profile(config, (bstr){list, e - list});
list = e + 1;
}
if (list[0] != '\0')