From 7c66d87c82ac6b06901e7cb39ed90db43bc4b053 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sat, 19 Mar 2022 14:55:30 -0700 Subject: *: de-constify til_setting_t throughout Now that til_setting_t.desc is not only a thing, but a thing that is intended to be refreshed regularly in the course of things like GUI interactive settings construction, it's not really appropriate to try even act like this these are const anymore. --- src/drm_fb.c | 2 +- src/main.c | 6 +++--- src/modules/compose/compose.c | 4 ++-- src/modules/drizzle/drizzle.c | 2 +- src/modules/flui2d/flui2d.c | 2 +- src/modules/rtv/rtv.c | 6 +++--- src/modules/sparkler/sparkler.c | 2 +- src/modules/stars/stars.c | 2 +- src/modules/submit/submit.c | 2 +- src/sdl_fb.c | 2 +- src/setup.c | 4 ++-- src/setup.h | 2 +- src/til.c | 4 ++-- src/til.h | 4 ++-- src/til_fb.h | 2 +- src/til_settings.c | 12 ++++++------ src/til_settings.h | 8 ++++---- 17 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/drm_fb.c b/src/drm_fb.c index 542192f..02c40bd 100644 --- a/src/drm_fb.c +++ b/src/drm_fb.c @@ -283,7 +283,7 @@ static int mode_desc_generator(void *setup_context, const til_setting_desc_t **r /* setup is called repeatedly as settings is constructed, until 0 is returned. */ /* a negative value is returned on error */ /* positive value indicates another setting is needed, described in next_setting */ -static int drm_fb_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int drm_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { drm_fb_setup_t context = {}; til_setting_desc_generator_t generators[] = { diff --git a/src/main.c b/src/main.c index 28601e9..c6b0362 100644 --- a/src/main.c +++ b/src/main.c @@ -56,10 +56,10 @@ typedef struct setup_t { */ /* select video backend if not yet selected, then setup the selected backend. */ -static int setup_video(til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int setup_video(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { - const til_setting_t *setting; - const char *video; + til_setting_t *setting; + const char *video; video = til_settings_get_key(settings, 0, &setting); if (!video || !setting->desc) { diff --git a/src/modules/compose/compose.c b/src/modules/compose/compose.c index 3e5334b..0f6b8fc 100644 --- a/src/modules/compose/compose.c +++ b/src/modules/compose/compose.c @@ -39,7 +39,7 @@ typedef struct compose_context_t { static void * compose_create_context(unsigned ticks, unsigned num_cpus); static void compose_destroy_context(void *context); static void compose_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter); -static int compose_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc); +static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc); static char *compose_default_layers[] = { "drizzle", "stars", "spiro", "plato", NULL }; static char **compose_layers; @@ -109,7 +109,7 @@ static void compose_prepare_frame(void *context, unsigned ticks, unsigned n_cpus } -static int compose_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int compose_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { const char *layers; int r; diff --git a/src/modules/drizzle/drizzle.c b/src/modules/drizzle/drizzle.c index f8d93bd..294d671 100644 --- a/src/modules/drizzle/drizzle.c +++ b/src/modules/drizzle/drizzle.c @@ -153,7 +153,7 @@ static void drizzle_render_fragment(void *context, unsigned ticks, unsigned cpu, } -static int drizzle_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int drizzle_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { const char *viscosity; const char *values[] = { diff --git a/src/modules/flui2d/flui2d.c b/src/modules/flui2d/flui2d.c index a4025c8..7a30c7e 100644 --- a/src/modules/flui2d/flui2d.c +++ b/src/modules/flui2d/flui2d.c @@ -283,7 +283,7 @@ static void flui2d_render_fragment(void *context, unsigned ticks, unsigned cpu, /* Settings hooks for configurable variables */ -static int flui2d_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int flui2d_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { const char *viscosity; const char *diffusion; diff --git a/src/modules/rtv/rtv.c b/src/modules/rtv/rtv.c index 47905ec..6464a8e 100644 --- a/src/modules/rtv/rtv.c +++ b/src/modules/rtv/rtv.c @@ -48,7 +48,7 @@ static void * rtv_create_context(unsigned ticks, unsigned num_cpus); static void rtv_destroy_context(void *context); static void rtv_prepare_frame(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter); static void rtv_finish_frame(void *context, unsigned ticks, til_fb_fragment_t *fragment); -static int rtv_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc); +static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc); static unsigned rtv_duration = RTV_DURATION_SECS; static unsigned rtv_context_duration = RTV_CONTEXT_DURATION_SECS; @@ -95,7 +95,7 @@ static void randomize_channels(rtv_context_t *ctxt) static char * randomize_module_setup(const til_module_t *module) { til_settings_t *settings; - const til_setting_t *setting; + til_setting_t *setting; const til_setting_desc_t *desc; char *arg; @@ -308,7 +308,7 @@ static void rtv_finish_frame(void *context, unsigned ticks, til_fb_fragment_t *f } -static int rtv_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int rtv_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { const char *channels; const char *duration; diff --git a/src/modules/sparkler/sparkler.c b/src/modules/sparkler/sparkler.c index 5d11a9d..d09b948 100644 --- a/src/modules/sparkler/sparkler.c +++ b/src/modules/sparkler/sparkler.c @@ -96,7 +96,7 @@ static void sparkler_render_fragment(void *context, unsigned ticks, unsigned cpu /* Settings hooks for configurable variables */ -static int sparkler_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int sparkler_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { const char *show_bsp_leafs; const char *show_bsp_matches; diff --git a/src/modules/stars/stars.c b/src/modules/stars/stars.c index 1cc66c4..859fb1f 100644 --- a/src/modules/stars/stars.c +++ b/src/modules/stars/stars.c @@ -201,7 +201,7 @@ static void stars_render_fragment(void *context, unsigned ticks, unsigned cpu, t ctxt->offset_y = tmp_y; } -int stars_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +int stars_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { const char *rot_adj; const char *rot_adj_values[] = { diff --git a/src/modules/submit/submit.c b/src/modules/submit/submit.c index 1389444..db5cf29 100644 --- a/src/modules/submit/submit.c +++ b/src/modules/submit/submit.c @@ -322,7 +322,7 @@ static void submit_render_fragment(void *context, unsigned ticks, unsigned cpu, } -static int submit_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int submit_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { const char *values[] = { "off", diff --git a/src/sdl_fb.c b/src/sdl_fb.c index 304737a..6aa535b 100644 --- a/src/sdl_fb.c +++ b/src/sdl_fb.c @@ -26,7 +26,7 @@ struct sdl_fb_page_t { }; -static int sdl_fb_setup(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +static int sdl_fb_setup(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { const char *fullscreen_values[] = { "off", diff --git a/src/setup.c b/src/setup.c index e027d1d..c811887 100644 --- a/src/setup.c +++ b/src/setup.c @@ -21,11 +21,11 @@ static int add_value(til_settings_t *settings, const char *key, const char *valu /* returns negative on error, otherwise number of additions made to settings */ -int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc), int defaults) +int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc), int defaults) { unsigned additions = 0; char buf[256] = "\n"; - const til_setting_t *setting; + til_setting_t *setting; const til_setting_desc_t *desc; int r; diff --git a/src/setup.h b/src/setup.h index 5135b8e..2c79fed 100644 --- a/src/setup.h +++ b/src/setup.h @@ -3,6 +3,6 @@ #include "til_settings.h" -int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc), int defaults); +int setup_interactively(til_settings_t *settings, int (*setup_func)(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc), int defaults); #endif diff --git a/src/til.c b/src/til.c index b23df19..4d7ef63 100644 --- a/src/til.c +++ b/src/til.c @@ -178,9 +178,9 @@ void * til_module_destroy_context(const til_module_t *module, void *context) /* select module if not yet selected, then setup the module. */ -int til_module_setup(til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { - const til_setting_t *setting; + til_setting_t *setting; const til_module_t *module; const char *name; diff --git a/src/til.h b/src/til.h index bf6b25c..6c6c745 100644 --- a/src/til.h +++ b/src/til.h @@ -17,7 +17,7 @@ typedef struct til_module_t { void (*prepare_frame)(void *context, unsigned ticks, unsigned n_cpus, til_fb_fragment_t *fragment, til_fragmenter_t *res_fragmenter); void (*render_fragment)(void *context, unsigned ticks, unsigned cpu, til_fb_fragment_t *fragment); void (*finish_frame)(void *context, unsigned ticks, til_fb_fragment_t *fragment); - int (*setup)(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc); + int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc); size_t (*knobs)(void *context, til_knob_t **res_knobs); char *name; char *description; @@ -32,6 +32,6 @@ void til_get_modules(const til_module_t ***res_modules, size_t *res_n_modules); void til_module_render(const til_module_t *module, void *context, unsigned ticks, til_fb_fragment_t *fragment); int til_module_create_context(const til_module_t *module, unsigned ticks, void **res_context); void * til_module_destroy_context(const til_module_t *module, void *context); -int til_module_setup(til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc); +int til_module_setup(til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc); #endif diff --git a/src/til_fb.h b/src/til_fb.h index 186324d..f6a2972 100644 --- a/src/til_fb.h +++ b/src/til_fb.h @@ -35,7 +35,7 @@ typedef struct til_fb_t til_fb_t; /* Supply this struct to fb_new() with the appropriate context */ typedef struct til_fb_ops_t { - int (*setup)(const til_settings_t *settings, const til_setting_t **res_setting, const til_setting_desc_t **res_desc); + int (*setup)(const til_settings_t *settings, til_setting_t **res_setting, const til_setting_desc_t **res_desc); int (*init)(const til_settings_t *settings, void **res_context); void (*shutdown)(til_fb_t *fb, void *context); int (*acquire)(til_fb_t *fb, void *context, void *page); diff --git a/src/til_settings.c b/src/til_settings.c index 152060d..0c2eff1 100644 --- a/src/til_settings.c +++ b/src/til_settings.c @@ -139,7 +139,7 @@ til_settings_t * til_settings_free(til_settings_t *settings) /* find key= in settings, return dup of value side or NULL if missing */ -const char * til_settings_get_value(const til_settings_t *settings, const char *key, const til_setting_t **res_setting) +const char * til_settings_get_value(const til_settings_t *settings, const char *key, til_setting_t **res_setting) { assert(settings); assert(key); @@ -158,7 +158,7 @@ const char * til_settings_get_value(const til_settings_t *settings, const char * /* return positional key from settings */ -const char * til_settings_get_key(const til_settings_t *settings, unsigned pos, const til_setting_t **res_setting) +const char * til_settings_get_key(const til_settings_t *settings, unsigned pos, til_setting_t **res_setting) { assert(settings); @@ -179,10 +179,10 @@ const char * til_settings_get_key(const til_settings_t *settings, unsigned pos, * 0 when setting is present and described, res_value and res_setting will be populated w/non-NULL, and res_desc NULL in this case. * 1 when setting is either present but undescribed, or absent (and undescribed), res_* will be populated but res_{value,setting} may be NULL if absent and simply described. */ -int til_settings_get_and_describe_value(const til_settings_t *settings, const til_setting_desc_t *desc, const char **res_value, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +int til_settings_get_and_describe_value(const til_settings_t *settings, const til_setting_desc_t *desc, const char **res_value, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { - const til_setting_t *setting; - const char *value; + til_setting_t *setting; + const char *value; assert(settings); assert(desc); @@ -239,7 +239,7 @@ void til_settings_reset_descs(til_settings_t *settings) /* returns 0 when input settings are complete */ /* returns 1 when input settings are incomplete, storing the next setting's description needed in *next_setting */ /* returns -errno on error */ -int til_settings_apply_desc_generators(const til_settings_t *settings, const til_setting_desc_generator_t generators[], unsigned n_generators, void *setup_context, const til_setting_t **res_setting, const til_setting_desc_t **res_desc) +int til_settings_apply_desc_generators(const til_settings_t *settings, const til_setting_desc_generator_t generators[], unsigned n_generators, void *setup_context, til_setting_t **res_setting, const til_setting_desc_t **res_desc) { assert(settings); assert(generators); diff --git a/src/til_settings.h b/src/til_settings.h index 0ca0c6f..2896405 100644 --- a/src/til_settings.h +++ b/src/til_settings.h @@ -33,13 +33,13 @@ struct til_setting_t { til_settings_t * til_settings_new(const char *settings); til_settings_t * til_settings_free(til_settings_t *settings); -const char * til_settings_get_value(const til_settings_t *settings, const char *key, const til_setting_t **res_setting); -const char * til_settings_get_key(const til_settings_t *settings, unsigned pos, const til_setting_t **res_setting); +const char * til_settings_get_value(const til_settings_t *settings, const char *key, til_setting_t **res_setting); +const char * til_settings_get_key(const til_settings_t *settings, unsigned pos, til_setting_t **res_setting); int til_settings_add_value(til_settings_t *settings, const char *key, const char *value, const til_setting_desc_t *desc); void til_settings_reset_descs(til_settings_t *settings); -int til_settings_get_and_describe_value(const til_settings_t *settings, const til_setting_desc_t *desc, const char **res_value, const til_setting_t **res_setting, const til_setting_desc_t **res_desc); +int til_settings_get_and_describe_value(const til_settings_t *settings, const til_setting_desc_t *desc, const char **res_value, til_setting_t **res_setting, const til_setting_desc_t **res_desc); char * til_settings_as_arg(const til_settings_t *settings); -int til_settings_apply_desc_generators(const til_settings_t *settings, const til_setting_desc_generator_t generators[], unsigned n_generators, void *setup_context, const til_setting_t **res_setting, const til_setting_desc_t **res_desc); +int til_settings_apply_desc_generators(const til_settings_t *settings, const til_setting_desc_generator_t generators[], unsigned n_generators, void *setup_context, til_setting_t **res_setting, const til_setting_desc_t **res_desc); int til_setting_desc_clone(const til_setting_desc_t *desc, const til_setting_desc_t **res_desc); til_setting_desc_t * til_setting_desc_free(const til_setting_desc_t *desc); -- cgit v1.2.3