aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorSam Ravnborg <sam@mars.ravnborg.org>2006-01-28 11:19:35 -0500
committerSam Ravnborg <sam@mars.ravnborg.org>2006-02-19 03:51:17 -0500
commit5c3ead8c72788d36d34c9f1689fb529d1339b405 (patch)
treefe6cfc38c3a210ad403970c59c001e5b746b8053 /scripts/mod/modpost.c
parentcb80514d9c517cc1d101ef304529a0e9b76b4468 (diff)
kbuild: apply CodingStyle to modpost.c
Just some light CodingStyle updates - no functional changes. Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r--scripts/mod/modpost.c124
1 files changed, 54 insertions, 70 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index a3c57ec7d54a..4a2f2e38d27f 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -21,8 +21,7 @@ int have_vmlinux = 0;
21/* Is CONFIG_MODULE_SRCVERSION_ALL set? */ 21/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
22static int all_versions = 0; 22static int all_versions = 0;
23 23
24void 24void fatal(const char *fmt, ...)
25fatal(const char *fmt, ...)
26{ 25{
27 va_list arglist; 26 va_list arglist;
28 27
@@ -35,8 +34,7 @@ fatal(const char *fmt, ...)
35 exit(1); 34 exit(1);
36} 35}
37 36
38void 37void warn(const char *fmt, ...)
39warn(const char *fmt, ...)
40{ 38{
41 va_list arglist; 39 va_list arglist;
42 40
@@ -59,8 +57,7 @@ void *do_nofail(void *ptr, const char *expr)
59 57
60static struct module *modules; 58static struct module *modules;
61 59
62struct module * 60static struct module *find_module(char *modname)
63find_module(char *modname)
64{ 61{
65 struct module *mod; 62 struct module *mod;
66 63
@@ -70,8 +67,7 @@ find_module(char *modname)
70 return mod; 67 return mod;
71} 68}
72 69
73struct module * 70static struct module *new_module(char *modname)
74new_module(char *modname)
75{ 71{
76 struct module *mod; 72 struct module *mod;
77 char *p, *s; 73 char *p, *s;
@@ -122,11 +118,12 @@ static inline unsigned int tdb_hash(const char *name)
122 return (1103515243 * value + 12345); 118 return (1103515243 * value + 12345);
123} 119}
124 120
125/* Allocate a new symbols for use in the hash of exported symbols or 121/**
126 * the list of unresolved symbols per module */ 122 * Allocate a new symbols for use in the hash of exported symbols or
127 123 * the list of unresolved symbols per module
128struct symbol * 124 **/
129alloc_symbol(const char *name, unsigned int weak, struct symbol *next) 125static struct symbol *alloc_symbol(const char *name, unsigned int weak,
126 struct symbol *next)
130{ 127{
131 struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1)); 128 struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
132 129
@@ -138,9 +135,8 @@ alloc_symbol(const char *name, unsigned int weak, struct symbol *next)
138} 135}
139 136
140/* For the hash of exported symbols */ 137/* For the hash of exported symbols */
141 138static void new_symbol(const char *name, struct module *module,
142void 139 unsigned int *crc)
143new_symbol(const char *name, struct module *module, unsigned int *crc)
144{ 140{
145 unsigned int hash; 141 unsigned int hash;
146 struct symbol *new; 142 struct symbol *new;
@@ -154,8 +150,7 @@ new_symbol(const char *name, struct module *module, unsigned int *crc)
154 } 150 }
155} 151}
156 152
157struct symbol * 153static struct symbol *find_symbol(const char *name)
158find_symbol(const char *name)
159{ 154{
160 struct symbol *s; 155 struct symbol *s;
161 156
@@ -170,10 +165,12 @@ find_symbol(const char *name)
170 return NULL; 165 return NULL;
171} 166}
172 167
173/* Add an exported symbol - it may have already been added without a 168/**
174 * CRC, in this case just update the CRC */ 169 * Add an exported symbol - it may have already been added without a
175void 170 * CRC, in this case just update the CRC
176add_exported_symbol(const char *name, struct module *module, unsigned int *crc) 171 **/
172static void add_exported_symbol(const char *name, struct module *module,
173 unsigned int *crc)
177{ 174{
178 struct symbol *s = find_symbol(name); 175 struct symbol *s = find_symbol(name);
179 176
@@ -187,8 +184,7 @@ add_exported_symbol(const char *name, struct module *module, unsigned int *crc)
187 } 184 }
188} 185}
189 186
190void * 187void *grab_file(const char *filename, unsigned long *size)
191grab_file(const char *filename, unsigned long *size)
192{ 188{
193 struct stat st; 189 struct stat st;
194 void *map; 190 void *map;
@@ -207,13 +203,12 @@ grab_file(const char *filename, unsigned long *size)
207 return map; 203 return map;
208} 204}
209 205
210/* 206/**
211 Return a copy of the next line in a mmap'ed file. 207 * Return a copy of the next line in a mmap'ed file.
212 spaces in the beginning of the line is trimmed away. 208 * spaces in the beginning of the line is trimmed away.
213 Return a pointer to a static buffer. 209 * Return a pointer to a static buffer.
214*/ 210 **/
215char* 211char* get_next_line(unsigned long *pos, void *file, unsigned long size)
216get_next_line(unsigned long *pos, void *file, unsigned long size)
217{ 212{
218 static char line[4096]; 213 static char line[4096];
219 int skip = 1; 214 int skip = 1;
@@ -243,14 +238,12 @@ get_next_line(unsigned long *pos, void *file, unsigned long size)
243 return NULL; 238 return NULL;
244} 239}
245 240
246void 241void release_file(void *file, unsigned long size)
247release_file(void *file, unsigned long size)
248{ 242{
249 munmap(file, size); 243 munmap(file, size);
250} 244}
251 245
252void 246static void parse_elf(struct elf_info *info, const char *filename)
253parse_elf(struct elf_info *info, const char *filename)
254{ 247{
255 unsigned int i; 248 unsigned int i;
256 Elf_Ehdr *hdr = info->hdr; 249 Elf_Ehdr *hdr = info->hdr;
@@ -318,8 +311,7 @@ parse_elf(struct elf_info *info, const char *filename)
318 fatal("%s is truncated.\n", filename); 311 fatal("%s is truncated.\n", filename);
319} 312}
320 313
321void 314static void parse_elf_finish(struct elf_info *info)
322parse_elf_finish(struct elf_info *info)
323{ 315{
324 release_file(info->hdr, info->size); 316 release_file(info->hdr, info->size);
325} 317}
@@ -327,9 +319,8 @@ parse_elf_finish(struct elf_info *info)
327#define CRC_PFX "__crc_" 319#define CRC_PFX "__crc_"
328#define KSYMTAB_PFX "__ksymtab_" 320#define KSYMTAB_PFX "__ksymtab_"
329 321
330void 322static void handle_modversions(struct module *mod, struct elf_info *info,
331handle_modversions(struct module *mod, struct elf_info *info, 323 Elf_Sym *sym, const char *symname)
332 Elf_Sym *sym, const char *symname)
333{ 324{
334 unsigned int crc; 325 unsigned int crc;
335 326
@@ -397,8 +388,7 @@ handle_modversions(struct module *mod, struct elf_info *info,
397 } 388 }
398} 389}
399 390
400int 391static int is_vmlinux(const char *modname)
401is_vmlinux(const char *modname)
402{ 392{
403 const char *myname; 393 const char *myname;
404 394
@@ -410,7 +400,9 @@ is_vmlinux(const char *modname)
410 return strcmp(myname, "vmlinux") == 0; 400 return strcmp(myname, "vmlinux") == 0;
411} 401}
412 402
413/* Parse tag=value strings from .modinfo section */ 403/**
404 * Parse tag=value strings from .modinfo section
405 **/
414static char *next_string(char *string, unsigned long *secsize) 406static char *next_string(char *string, unsigned long *secsize)
415{ 407{
416 /* Skip non-zero chars */ 408 /* Skip non-zero chars */
@@ -443,8 +435,7 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
443 return NULL; 435 return NULL;
444} 436}
445 437
446void 438static void read_symbols(char *modname)
447read_symbols(char *modname)
448{ 439{
449 const char *symname; 440 const char *symname;
450 char *version; 441 char *version;
@@ -496,8 +487,8 @@ read_symbols(char *modname)
496 * following helper, then compare to the file on disk and 487 * following helper, then compare to the file on disk and
497 * only update the later if anything changed */ 488 * only update the later if anything changed */
498 489
499void __attribute__((format(printf, 2, 3))) 490void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
500buf_printf(struct buffer *buf, const char *fmt, ...) 491 const char *fmt, ...)
501{ 492{
502 char tmp[SZ]; 493 char tmp[SZ];
503 int len; 494 int len;
@@ -514,8 +505,7 @@ buf_printf(struct buffer *buf, const char *fmt, ...)
514 va_end(ap); 505 va_end(ap);
515} 506}
516 507
517void 508void buf_write(struct buffer *buf, const char *s, int len)
518buf_write(struct buffer *buf, const char *s, int len)
519{ 509{
520 if (buf->size - buf->pos < len) { 510 if (buf->size - buf->pos < len) {
521 buf->size += len; 511 buf->size += len;
@@ -525,10 +515,10 @@ buf_write(struct buffer *buf, const char *s, int len)
525 buf->pos += len; 515 buf->pos += len;
526} 516}
527 517
528/* Header for the generated file */ 518/**
529 519 * Header for the generated file
530void 520 **/
531add_header(struct buffer *b, struct module *mod) 521static void add_header(struct buffer *b, struct module *mod)
532{ 522{
533 buf_printf(b, "#include <linux/module.h>\n"); 523 buf_printf(b, "#include <linux/module.h>\n");
534 buf_printf(b, "#include <linux/vermagic.h>\n"); 524 buf_printf(b, "#include <linux/vermagic.h>\n");
@@ -548,10 +538,10 @@ add_header(struct buffer *b, struct module *mod)
548 buf_printf(b, "};\n"); 538 buf_printf(b, "};\n");
549} 539}
550 540
551/* Record CRCs for unresolved symbols */ 541/**
552 542 * Record CRCs for unresolved symbols
553void 543 **/
554add_versions(struct buffer *b, struct module *mod) 544static void add_versions(struct buffer *b, struct module *mod)
555{ 545{
556 struct symbol *s, *exp; 546 struct symbol *s, *exp;
557 547
@@ -591,8 +581,8 @@ add_versions(struct buffer *b, struct module *mod)
591 buf_printf(b, "};\n"); 581 buf_printf(b, "};\n");
592} 582}
593 583
594void 584static void add_depends(struct buffer *b, struct module *mod,
595add_depends(struct buffer *b, struct module *mod, struct module *modules) 585 struct module *modules)
596{ 586{
597 struct symbol *s; 587 struct symbol *s;
598 struct module *m; 588 struct module *m;
@@ -622,8 +612,7 @@ add_depends(struct buffer *b, struct module *mod, struct module *modules)
622 buf_printf(b, "\";\n"); 612 buf_printf(b, "\";\n");
623} 613}
624 614
625void 615static void add_srcversion(struct buffer *b, struct module *mod)
626add_srcversion(struct buffer *b, struct module *mod)
627{ 616{
628 if (mod->srcversion[0]) { 617 if (mod->srcversion[0]) {
629 buf_printf(b, "\n"); 618 buf_printf(b, "\n");
@@ -632,8 +621,7 @@ add_srcversion(struct buffer *b, struct module *mod)
632 } 621 }
633} 622}
634 623
635void 624static void write_if_changed(struct buffer *b, const char *fname)
636write_if_changed(struct buffer *b, const char *fname)
637{ 625{
638 char *tmp; 626 char *tmp;
639 FILE *file; 627 FILE *file;
@@ -677,8 +665,7 @@ write_if_changed(struct buffer *b, const char *fname)
677 fclose(file); 665 fclose(file);
678} 666}
679 667
680void 668static void read_dump(const char *fname)
681read_dump(const char *fname)
682{ 669{
683 unsigned long size, pos = 0; 670 unsigned long size, pos = 0;
684 void *file = grab_file(fname, &size); 671 void *file = grab_file(fname, &size);
@@ -719,8 +706,7 @@ fail:
719 fatal("parse error in symbol dump file\n"); 706 fatal("parse error in symbol dump file\n");
720} 707}
721 708
722void 709static void write_dump(const char *fname)
723write_dump(const char *fname)
724{ 710{
725 struct buffer buf = { }; 711 struct buffer buf = { };
726 struct symbol *symbol; 712 struct symbol *symbol;
@@ -744,8 +730,7 @@ write_dump(const char *fname)
744 write_if_changed(&buf, fname); 730 write_if_changed(&buf, fname);
745} 731}
746 732
747int 733int main(int argc, char **argv)
748main(int argc, char **argv)
749{ 734{
750 struct module *mod; 735 struct module *mod;
751 struct buffer buf = { }; 736 struct buffer buf = { };
@@ -800,4 +785,3 @@ main(int argc, char **argv)
800 785
801 return 0; 786 return 0;
802} 787}
803