Commit 6425e3b2 authored by Masahiro Yamada's avatar Masahiro Yamada

kconfig: add const qualifiers to several function arguments

Clarify that the given structures are not modified.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 8bfd6f09
...@@ -1096,7 +1096,7 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2) ...@@ -1096,7 +1096,7 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2)
return 0; return 0;
} }
void expr_print(struct expr *e, void expr_print(const struct expr *e,
void (*fn)(void *, struct symbol *, const char *), void (*fn)(void *, struct symbol *, const char *),
void *data, int prevtoken) void *data, int prevtoken)
{ {
...@@ -1221,7 +1221,7 @@ static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *s ...@@ -1221,7 +1221,7 @@ static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *s
str_printf(gs, " [=%s]", sym_str); str_printf(gs, " [=%s]", sym_str);
} }
void expr_gstr_print(struct expr *e, struct gstr *gs) void expr_gstr_print(const struct expr *e, struct gstr *gs)
{ {
expr_print(e, expr_print_gstr_helper, gs, E_NONE); expr_print(e, expr_print_gstr_helper, gs, E_NONE);
} }
......
...@@ -291,11 +291,11 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb ...@@ -291,11 +291,11 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb
void expr_fprint(struct expr *e, FILE *out); void expr_fprint(struct expr *e, FILE *out);
struct gstr; /* forward */ struct gstr; /* forward */
void expr_gstr_print(struct expr *e, struct gstr *gs); void expr_gstr_print(const struct expr *e, struct gstr *gs);
void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, void expr_gstr_print_revdep(struct expr *e, struct gstr *gs,
tristate pr_type, const char *title); tristate pr_type, const char *title);
static inline int expr_is_yes(struct expr *e) static inline int expr_is_yes(const struct expr *e)
{ {
return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes);
} }
......
...@@ -75,7 +75,7 @@ struct gstr str_new(void); ...@@ -75,7 +75,7 @@ struct gstr str_new(void);
void str_free(struct gstr *gs); void str_free(struct gstr *gs);
void str_append(struct gstr *gs, const char *s); void str_append(struct gstr *gs, const char *s);
void str_printf(struct gstr *gs, const char *fmt, ...); void str_printf(struct gstr *gs, const char *fmt, ...);
char *str_get(struct gstr *gs); char *str_get(const struct gstr *gs);
/* menu.c */ /* menu.c */
struct menu *menu_next(struct menu *menu, struct menu *root); struct menu *menu_next(struct menu *menu, struct menu *root);
...@@ -84,13 +84,14 @@ struct menu *menu_next(struct menu *menu, struct menu *root); ...@@ -84,13 +84,14 @@ struct menu *menu_next(struct menu *menu, struct menu *root);
#define menu_for_each_entry(menu) \ #define menu_for_each_entry(menu) \
menu_for_each_sub_entry(menu, &rootmenu) menu_for_each_sub_entry(menu, &rootmenu)
void _menu_init(void); void _menu_init(void);
void menu_warn(struct menu *menu, const char *fmt, ...); void menu_warn(const struct menu *menu, const char *fmt, ...);
struct menu *menu_add_menu(void); struct menu *menu_add_menu(void);
void menu_end_menu(void); void menu_end_menu(void);
void menu_add_entry(struct symbol *sym); void menu_add_entry(struct symbol *sym);
void menu_add_dep(struct expr *dep); void menu_add_dep(struct expr *dep);
void menu_add_visibility(struct expr *dep); void menu_add_visibility(struct expr *dep);
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); struct property *menu_add_prompt(enum prop_type type, const char *prompt,
struct expr *dep);
void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep);
void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep);
void menu_finalize(void); void menu_finalize(void);
...@@ -100,8 +101,8 @@ extern struct menu rootmenu; ...@@ -100,8 +101,8 @@ extern struct menu rootmenu;
bool menu_is_empty(struct menu *menu); bool menu_is_empty(struct menu *menu);
bool menu_is_visible(struct menu *menu); bool menu_is_visible(struct menu *menu);
bool menu_has_prompt(struct menu *menu); bool menu_has_prompt(const struct menu *menu);
const char *menu_get_prompt(struct menu *menu); const char *menu_get_prompt(const struct menu *menu);
struct menu *menu_get_parent_menu(struct menu *menu); struct menu *menu_get_parent_menu(struct menu *menu);
int get_jump_key_char(void); int get_jump_key_char(void);
struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head);
...@@ -114,25 +115,25 @@ struct symbol *sym_calc_choice(struct menu *choice); ...@@ -114,25 +115,25 @@ struct symbol *sym_calc_choice(struct menu *choice);
struct property *sym_get_range_prop(struct symbol *sym); struct property *sym_get_range_prop(struct symbol *sym);
const char *sym_get_string_default(struct symbol *sym); const char *sym_get_string_default(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym); struct symbol *sym_check_deps(struct symbol *sym);
struct symbol *prop_get_symbol(struct property *prop); struct symbol *prop_get_symbol(const struct property *prop);
static inline tristate sym_get_tristate_value(struct symbol *sym) static inline tristate sym_get_tristate_value(const struct symbol *sym)
{ {
return sym->curr.tri; return sym->curr.tri;
} }
static inline bool sym_is_choice(struct symbol *sym) static inline bool sym_is_choice(const struct symbol *sym)
{ {
/* A choice is a symbol with no name */ /* A choice is a symbol with no name */
return sym->name == NULL; return sym->name == NULL;
} }
static inline bool sym_is_choice_value(struct symbol *sym) static inline bool sym_is_choice_value(const struct symbol *sym)
{ {
return sym->flags & SYMBOL_CHOICEVAL ? true : false; return sym->flags & SYMBOL_CHOICEVAL ? true : false;
} }
static inline bool sym_has_value(struct symbol *sym) static inline bool sym_has_value(const struct symbol *sym)
{ {
return sym->flags & SYMBOL_DEF_USER ? true : false; return sym->flags & SYMBOL_DEF_USER ? true : false;
} }
......
...@@ -25,21 +25,23 @@ struct symbol ** sym_re_search(const char *pattern); ...@@ -25,21 +25,23 @@ struct symbol ** sym_re_search(const char *pattern);
const char * sym_type_name(enum symbol_type type); const char * sym_type_name(enum symbol_type type);
void sym_calc_value(struct symbol *sym); void sym_calc_value(struct symbol *sym);
bool sym_dep_errors(void); bool sym_dep_errors(void);
enum symbol_type sym_get_type(struct symbol *sym); enum symbol_type sym_get_type(const struct symbol *sym);
bool sym_tristate_within_range(struct symbol *sym,tristate tri); bool sym_tristate_within_range(const struct symbol *sym, tristate tri);
bool sym_set_tristate_value(struct symbol *sym,tristate tri); bool sym_set_tristate_value(struct symbol *sym,tristate tri);
void choice_set_value(struct menu *choice, struct symbol *sym); void choice_set_value(struct menu *choice, struct symbol *sym);
tristate sym_toggle_tristate_value(struct symbol *sym); tristate sym_toggle_tristate_value(struct symbol *sym);
bool sym_string_valid(struct symbol *sym, const char *newval); bool sym_string_valid(struct symbol *sym, const char *newval);
bool sym_string_within_range(struct symbol *sym, const char *str); bool sym_string_within_range(struct symbol *sym, const char *str);
bool sym_set_string_value(struct symbol *sym, const char *newval); bool sym_set_string_value(struct symbol *sym, const char *newval);
bool sym_is_changeable(struct symbol *sym); bool sym_is_changeable(const struct symbol *sym);
struct menu *sym_get_choice_menu(struct symbol *sym); struct menu *sym_get_choice_menu(const struct symbol *sym);
const char * sym_get_string_value(struct symbol *sym); const char * sym_get_string_value(struct symbol *sym);
const char * prop_get_type_name(enum prop_type type); const char * prop_get_type_name(enum prop_type type);
/* expr.c */ /* expr.c */
void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); void expr_print(const struct expr *e,
void (*fn)(void *, struct symbol *, const char *),
void *data, int prevtoken);
#endif /* LKC_PROTO_H */ #endif /* LKC_PROTO_H */
...@@ -38,7 +38,7 @@ struct menu *menu_next(struct menu *menu, struct menu *root) ...@@ -38,7 +38,7 @@ struct menu *menu_next(struct menu *menu, struct menu *root)
return menu->next; return menu->next;
} }
void menu_warn(struct menu *menu, const char *fmt, ...) void menu_warn(const struct menu *menu, const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
...@@ -48,7 +48,7 @@ void menu_warn(struct menu *menu, const char *fmt, ...) ...@@ -48,7 +48,7 @@ void menu_warn(struct menu *menu, const char *fmt, ...)
va_end(ap); va_end(ap);
} }
static void prop_warn(struct property *prop, const char *fmt, ...) static void prop_warn(const struct property *prop, const char *fmt, ...)
{ {
va_list ap; va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
...@@ -175,7 +175,7 @@ static struct property *menu_add_prop(enum prop_type type, struct expr *expr, ...@@ -175,7 +175,7 @@ static struct property *menu_add_prop(enum prop_type type, struct expr *expr,
return prop; return prop;
} }
struct property *menu_add_prompt(enum prop_type type, char *prompt, struct property *menu_add_prompt(enum prop_type type, const char *prompt,
struct expr *dep) struct expr *dep)
{ {
struct property *prop = menu_add_prop(type, NULL, dep); struct property *prop = menu_add_prop(type, NULL, dep);
...@@ -527,7 +527,7 @@ void menu_finalize(void) ...@@ -527,7 +527,7 @@ void menu_finalize(void)
_menu_finalize(&rootmenu, false); _menu_finalize(&rootmenu, false);
} }
bool menu_has_prompt(struct menu *menu) bool menu_has_prompt(const struct menu *menu)
{ {
if (!menu->prompt) if (!menu->prompt)
return false; return false;
...@@ -573,7 +573,7 @@ bool menu_is_visible(struct menu *menu) ...@@ -573,7 +573,7 @@ bool menu_is_visible(struct menu *menu)
return visible != no; return visible != no;
} }
const char *menu_get_prompt(struct menu *menu) const char *menu_get_prompt(const struct menu *menu)
{ {
if (menu->prompt) if (menu->prompt)
return menu->prompt->text; return menu->prompt->text;
...@@ -594,13 +594,14 @@ struct menu *menu_get_parent_menu(struct menu *menu) ...@@ -594,13 +594,14 @@ struct menu *menu_get_parent_menu(struct menu *menu)
return menu; return menu;
} }
static void get_def_str(struct gstr *r, struct menu *menu) static void get_def_str(struct gstr *r, const struct menu *menu)
{ {
str_printf(r, "Defined at %s:%d\n", str_printf(r, "Defined at %s:%d\n",
menu->filename, menu->lineno); menu->filename, menu->lineno);
} }
static void get_dep_str(struct gstr *r, struct expr *expr, const char *prefix) static void get_dep_str(struct gstr *r, const struct expr *expr,
const char *prefix)
{ {
if (!expr_is_yes(expr)) { if (!expr_is_yes(expr)) {
str_append(r, prefix); str_append(r, prefix);
......
...@@ -489,7 +489,7 @@ assign_val: ...@@ -489,7 +489,7 @@ assign_val:
* *
* Return: -1 if an error is found, 0 otherwise. * Return: -1 if an error is found, 0 otherwise.
*/ */
static int choice_check_sanity(struct menu *menu) static int choice_check_sanity(const struct menu *menu)
{ {
struct property *prop; struct property *prop;
int ret = 0; int ret = 0;
...@@ -644,7 +644,7 @@ static void print_quoted_string(FILE *out, const char *str) ...@@ -644,7 +644,7 @@ static void print_quoted_string(FILE *out, const char *str)
putc('"', out); putc('"', out);
} }
static void print_symbol(FILE *out, struct menu *menu) static void print_symbol(FILE *out, const struct menu *menu)
{ {
struct symbol *sym = menu->sym; struct symbol *sym = menu->sym;
struct property *prop; struct property *prop;
......
...@@ -40,7 +40,7 @@ struct symbol *modules_sym; ...@@ -40,7 +40,7 @@ struct symbol *modules_sym;
static tristate modules_val; static tristate modules_val;
static int sym_warnings; static int sym_warnings;
enum symbol_type sym_get_type(struct symbol *sym) enum symbol_type sym_get_type(const struct symbol *sym)
{ {
enum symbol_type type = sym->type; enum symbol_type type = sym->type;
...@@ -75,7 +75,7 @@ const char *sym_type_name(enum symbol_type type) ...@@ -75,7 +75,7 @@ const char *sym_type_name(enum symbol_type type)
* *
* Return: a choice menu if this function is called against a choice member. * Return: a choice menu if this function is called against a choice member.
*/ */
struct menu *sym_get_choice_menu(struct symbol *sym) struct menu *sym_get_choice_menu(const struct symbol *sym)
{ {
struct menu *menu = NULL; struct menu *menu = NULL;
struct menu *m; struct menu *m;
...@@ -355,7 +355,7 @@ struct symbol *sym_calc_choice(struct menu *choice) ...@@ -355,7 +355,7 @@ struct symbol *sym_calc_choice(struct menu *choice)
return res; return res;
} }
static void sym_warn_unmet_dep(struct symbol *sym) static void sym_warn_unmet_dep(const struct symbol *sym)
{ {
struct gstr gs = str_new(); struct gstr gs = str_new();
...@@ -521,7 +521,7 @@ void sym_clear_all_valid(void) ...@@ -521,7 +521,7 @@ void sym_clear_all_valid(void)
sym_calc_value(modules_sym); sym_calc_value(modules_sym);
} }
bool sym_tristate_within_range(struct symbol *sym, tristate val) bool sym_tristate_within_range(const struct symbol *sym, tristate val)
{ {
int type = sym_get_type(sym); int type = sym_get_type(sym);
...@@ -866,7 +866,7 @@ const char *sym_get_string_value(struct symbol *sym) ...@@ -866,7 +866,7 @@ const char *sym_get_string_value(struct symbol *sym)
return (const char *)sym->curr.val; return (const char *)sym->curr.val;
} }
bool sym_is_changeable(struct symbol *sym) bool sym_is_changeable(const struct symbol *sym)
{ {
return !sym_is_choice(sym) && sym->visible > sym->rev_dep.tri; return !sym_is_choice(sym) && sym->visible > sym->rev_dep.tri;
} }
...@@ -1150,7 +1150,7 @@ static void sym_check_print_recursive(struct symbol *last_sym) ...@@ -1150,7 +1150,7 @@ static void sym_check_print_recursive(struct symbol *last_sym)
dep_stack_remove(); dep_stack_remove();
} }
static struct symbol *sym_check_expr_deps(struct expr *e) static struct symbol *sym_check_expr_deps(const struct expr *e)
{ {
struct symbol *sym; struct symbol *sym;
...@@ -1309,7 +1309,7 @@ struct symbol *sym_check_deps(struct symbol *sym) ...@@ -1309,7 +1309,7 @@ struct symbol *sym_check_deps(struct symbol *sym)
return sym2; return sym2;
} }
struct symbol *prop_get_symbol(struct property *prop) struct symbol *prop_get_symbol(const struct property *prop)
{ {
if (prop->expr && prop->expr->type == E_SYMBOL) if (prop->expr && prop->expr->type == E_SYMBOL)
return prop->expr->left.sym; return prop->expr->left.sym;
......
...@@ -98,7 +98,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...) ...@@ -98,7 +98,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...)
} }
/* Retrieve value of growable string */ /* Retrieve value of growable string */
char *str_get(struct gstr *gs) char *str_get(const struct gstr *gs)
{ {
return gs->s; return gs->s;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment