History

scripts/kallsyms: add const qualifiers where possible

Add 'const' where a function does not write to the pointer dereferenes.

Masahiro Yamada committed 6 years ago

Commit 4bfe2b71 parent 2558c131 file · +14 −14Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/kallsyms.c+14−14
@@ -170,11 +170,11 @@ static int read_symbol(FILE *in, struct sym_entry *s) · 169 unmodified lines
170170 return 0;
171171 }
172172
173−static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges,
174− int entries)
173+static int symbol_in_range(const struct sym_entry *s,
174+ const struct addr_range *ranges, int entries)
175175 {
176176 size_t i;
177− struct addr_range *ar;
177+ const struct addr_range *ar;
178178
179179 for (i = 0; i < entries; ++i) {
180180 ar = &ranges[i];
@@ -186,14 +186,14 @@ static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges, · 5 unmodified lines
186186 return 0;
187187 }
188188
189−static int symbol_valid(struct sym_entry *s)
189+static int symbol_valid(const struct sym_entry *s)
190190 {
191191 /* Symbols which vary between passes. Passes 1 and 2 must have
192192 * identical symbol lists. The kallsyms_* symbols below are only added
193193 * after pass 1, they would be included in pass 2 when --all-symbols is
194194 * specified so exclude them to get a stable symbol list.
195195 */
196− static char *special_symbols[] = {
196+ static const char * const special_symbols[] = {
197197 "kallsyms_addresses",
198198 "kallsyms_offsets",
199199 "kallsyms_relative_base",
@@ -208,12 +208,12 @@ static int symbol_valid(struct sym_entry *s) · 8 unmodified lines
208208 "_SDA2_BASE_", /* ppc */
209209 NULL };
210210
211− static char *special_prefixes[] = {
211+ static const char * const special_prefixes[] = {
212212 "__crc_", /* modversions */
213213 "__efistub_", /* arm64 EFI stub namespace */
214214 NULL };
215215
216− static char *special_suffixes[] = {
216+ static const char * const special_suffixes[] = {
217217 "_veneer", /* arm */
218218 "_from_arm", /* arm */
219219 "_from_thumb", /* arm */
@@ -305,7 +305,7 @@ static void read_map(FILE *in) · 85 unmodified lines
305305 }
306306 }
307307
308−static void output_label(char *label)
308+static void output_label(const char *label)
309309 {
310310 printf(".globl %s\n", label);
311311 printf("\tALGN\n");
@@ -314,7 +314,7 @@ static void output_label(char *label) · 2 unmodified lines
314314
315315 /* uncompress a compressed symbol. When this function is called, the best table
316316 * might still be compressed itself, so the function needs to be recursive */
317−static int expand_symbol(unsigned char *data, int len, char *result)
317+static int expand_symbol(const unsigned char *data, int len, char *result)
318318 {
319319 int c, rlen, total=0;
320320
@@ -339,7 +339,7 @@ static int expand_symbol(unsigned char *data, int len, char *result) · 18 unmodified lines
339339 return total;
340340 }
341341
342−static int symbol_absolute(struct sym_entry *s)
342+static int symbol_absolute(const struct sym_entry *s)
343343 {
344344 return s->percpu_absolute;
345345 }
@@ -477,7 +477,7 @@ static void write_src(void) · 131 unmodified lines
477477 /* table lookup compression functions */
478478
479479 /* count all the possible tokens in a symbol */
480−static void learn_symbol(unsigned char *symbol, int len)
480+static void learn_symbol(const unsigned char *symbol, int len)
481481 {
482482 int i;
483483
@@ -486,7 +486,7 @@ static void learn_symbol(unsigned char *symbol, int len) · 2 unmodified lines
486486 }
487487
488488 /* decrease the count for all the possible tokens in a symbol */
489−static void forget_symbol(unsigned char *symbol, int len)
489+static void forget_symbol(const unsigned char *symbol, int len)
490490 {
491491 int i;
492492
@@ -504,7 +504,7 @@ static void build_initial_tok_table(void) · 11 unmodified lines
504504 }
505505
506506 static unsigned char *find_token(unsigned char *str, int len,
507− unsigned char *token)
507+ const unsigned char *token)
508508 {
509509 int i;
510510
@@ -517,7 +517,7 @@ static unsigned char *find_token(unsigned char *str, int len, · 6 unmodified lines
517517
518518 /* replace a given token in all the valid symbols. Use the sampled symbols
519519 * to update the counts */
520−static void compress_symbols(unsigned char *str, int idx)
520+static void compress_symbols(const unsigned char *str, int idx)
521521 {
522522 unsigned int i, len, size;
523523 unsigned char *p1, *p2;