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
170 return 0;170 return 0;
171}171}
172 172
173static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges,173static int symbol_in_range(const struct sym_entry *s,
174 int entries)174 const struct addr_range *ranges, int entries)
175{175{
176 size_t i;176 size_t i;
177 struct addr_range *ar;177 const struct addr_range *ar;
178 178
179 for (i = 0; i < entries; ++i) {179 for (i = 0; i < entries; ++i) {
180 ar = &ranges[i];180 ar = &ranges[i];
@@ -186,14 +186,14 @@ static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges, · 5 unmodified lines
186 return 0;186 return 0;
187}187}
188 188
189static int symbol_valid(struct sym_entry *s)189static int symbol_valid(const struct sym_entry *s)
190{190{
191 /* Symbols which vary between passes. Passes 1 and 2 must have191 /* Symbols which vary between passes. Passes 1 and 2 must have
192 * identical symbol lists. The kallsyms_* symbols below are only added192 * identical symbol lists. The kallsyms_* symbols below are only added
193 * after pass 1, they would be included in pass 2 when --all-symbols is193 * after pass 1, they would be included in pass 2 when --all-symbols is
194 * specified so exclude them to get a stable symbol list.194 * specified so exclude them to get a stable symbol list.
195 */195 */
196 static char *special_symbols[] = {196 static const char * const special_symbols[] = {
197 "kallsyms_addresses",197 "kallsyms_addresses",
198 "kallsyms_offsets",198 "kallsyms_offsets",
199 "kallsyms_relative_base",199 "kallsyms_relative_base",
@@ -208,12 +208,12 @@ static int symbol_valid(struct sym_entry *s) · 8 unmodified lines
208 "_SDA2_BASE_", /* ppc */208 "_SDA2_BASE_", /* ppc */
209 NULL };209 NULL };
210 210
211 static char *special_prefixes[] = {211 static const char * const special_prefixes[] = {
212 "__crc_", /* modversions */212 "__crc_", /* modversions */
213 "__efistub_", /* arm64 EFI stub namespace */213 "__efistub_", /* arm64 EFI stub namespace */
214 NULL };214 NULL };
215 215
216 static char *special_suffixes[] = {216 static const char * const special_suffixes[] = {
217 "_veneer", /* arm */217 "_veneer", /* arm */
218 "_from_arm", /* arm */218 "_from_arm", /* arm */
219 "_from_thumb", /* arm */219 "_from_thumb", /* arm */
@@ -305,7 +305,7 @@ static void read_map(FILE *in) · 85 unmodified lines
305 }305 }
306}306}
307 307
308static void output_label(char *label)308static void output_label(const char *label)
309{309{
310 printf(".globl %s\n", label);310 printf(".globl %s\n", label);
311 printf("\tALGN\n");311 printf("\tALGN\n");
@@ -314,7 +314,7 @@ static void output_label(char *label) · 2 unmodified lines
314 314
315/* uncompress a compressed symbol. When this function is called, the best table315/* uncompress a compressed symbol. When this function is called, the best table
316 * might still be compressed itself, so the function needs to be recursive */316 * might still be compressed itself, so the function needs to be recursive */
317static int expand_symbol(unsigned char *data, int len, char *result)317static int expand_symbol(const unsigned char *data, int len, char *result)
318{318{
319 int c, rlen, total=0;319 int c, rlen, total=0;
320 320
@@ -339,7 +339,7 @@ static int expand_symbol(unsigned char *data, int len, char *result) · 18 unmodified lines
339 return total;339 return total;
340}340}
341 341
342static int symbol_absolute(struct sym_entry *s)342static int symbol_absolute(const struct sym_entry *s)
343{343{
344 return s->percpu_absolute;344 return s->percpu_absolute;
345}345}
@@ -477,7 +477,7 @@ static void write_src(void) · 131 unmodified lines
477/* table lookup compression functions */477/* table lookup compression functions */
478 478
479/* count all the possible tokens in a symbol */479/* count all the possible tokens in a symbol */
480static void learn_symbol(unsigned char *symbol, int len)480static void learn_symbol(const unsigned char *symbol, int len)
481{481{
482 int i;482 int i;
483 483
@@ -486,7 +486,7 @@ static void learn_symbol(unsigned char *symbol, int len) · 2 unmodified lines
486}486}
487 487
488/* decrease the count for all the possible tokens in a symbol */488/* decrease the count for all the possible tokens in a symbol */
489static void forget_symbol(unsigned char *symbol, int len)489static void forget_symbol(const unsigned char *symbol, int len)
490{490{
491 int i;491 int i;
492 492
@@ -504,7 +504,7 @@ static void build_initial_tok_table(void) · 11 unmodified lines
504}504}
505 505
506static unsigned char *find_token(unsigned char *str, int len,506static unsigned char *find_token(unsigned char *str, int len,
507 unsigned char *token)507 const unsigned char *token)
508{508{
509 int i;509 int i;
510 510
@@ -517,7 +517,7 @@ static unsigned char *find_token(unsigned char *str, int len, · 6 unmodified lines
517 517
518/* replace a given token in all the valid symbols. Use the sampled symbols518/* replace a given token in all the valid symbols. Use the sampled symbols
519 * to update the counts */519 * to update the counts */
520static void compress_symbols(unsigned char *str, int idx)520static void compress_symbols(const unsigned char *str, int idx)
521{521{
522 unsigned int i, len, size;522 unsigned int i, len, size;
523 unsigned char *p1, *p2;523 unsigned char *p1, *p2;