kbuild: use warn()/fatal() consistent in modpost

modpost.c provides warn() and fatal() - so use them all over the place.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
This commit is contained in:
Sam Ravnborg 2006-01-28 16:57:26 +01:00
parent 06300b21f4
commit cb80514d9c
4 changed files with 27 additions and 32 deletions

View File

@ -153,8 +153,8 @@ static void do_usb_table(void *symval, unsigned long size,
const unsigned long id_size = sizeof(struct usb_device_id); const unsigned long id_size = sizeof(struct usb_device_id);
if (size % id_size || size < id_size) { if (size % id_size || size < id_size) {
fprintf(stderr, "*** Warning: %s ids %lu bad size " warn("%s ids %lu bad size "
"(each on %lu)\n", mod->name, size, id_size); "(each on %lu)\n", mod->name, size, id_size);
} }
/* Leave last one: it's the terminator. */ /* Leave last one: it's the terminator. */
size -= id_size; size -= id_size;
@ -217,9 +217,8 @@ static int do_pci_entry(const char *filename,
if ((baseclass_mask != 0 && baseclass_mask != 0xFF) if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
|| (subclass_mask != 0 && subclass_mask != 0xFF) || (subclass_mask != 0 && subclass_mask != 0xFF)
|| (interface_mask != 0 && interface_mask != 0xFF)) { || (interface_mask != 0 && interface_mask != 0xFF)) {
fprintf(stderr, warn("Can't handle masks in %s:%04X\n",
"*** Warning: Can't handle masks in %s:%04X\n", filename, id->class_mask);
filename, id->class_mask);
return 0; return 0;
} }
@ -445,8 +444,8 @@ static void do_table(void *symval, unsigned long size,
int (*do_entry)(const char *, void *entry, char *alias) = function; int (*do_entry)(const char *, void *entry, char *alias) = function;
if (size % id_size || size < id_size) { if (size % id_size || size < id_size) {
fprintf(stderr, "*** Warning: %s ids %lu bad size " warn("%s ids %lu bad size "
"(each on %lu)\n", mod->name, size, id_size); "(each on %lu)\n", mod->name, size, id_size);
} }
/* Leave last one: it's the terminator. */ /* Leave last one: it's the terminator. */
size -= id_size; size -= id_size;

View File

@ -303,8 +303,7 @@ parse_elf(struct elf_info *info, const char *filename)
sechdrs[sechdrs[i].sh_link].sh_offset; sechdrs[sechdrs[i].sh_link].sh_offset;
} }
if (!info->symtab_start) { if (!info->symtab_start) {
fprintf(stderr, "modpost: %s no symtab?\n", filename); fatal("%s has no symtab?\n", filename);
abort();
} }
/* Fix endianness in symbols */ /* Fix endianness in symbols */
for (sym = info->symtab_start; sym < info->symtab_stop; sym++) { for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
@ -316,8 +315,7 @@ parse_elf(struct elf_info *info, const char *filename)
return; return;
truncated: truncated:
fprintf(stderr, "modpost: %s is truncated.\n", filename); fatal("%s is truncated.\n", filename);
abort();
} }
void void
@ -337,8 +335,7 @@ handle_modversions(struct module *mod, struct elf_info *info,
switch (sym->st_shndx) { switch (sym->st_shndx) {
case SHN_COMMON: case SHN_COMMON:
fprintf(stderr, "*** Warning: \"%s\" [%s] is COMMON symbol\n", warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
symname, mod->name);
break; break;
case SHN_ABS: case SHN_ABS:
/* CRC'd symbol */ /* CRC'd symbol */
@ -562,8 +559,8 @@ add_versions(struct buffer *b, struct module *mod)
exp = find_symbol(s->name); exp = find_symbol(s->name);
if (!exp || exp->module == mod) { if (!exp || exp->module == mod) {
if (have_vmlinux && !s->weak) if (have_vmlinux && !s->weak)
fprintf(stderr, "*** Warning: \"%s\" [%s.ko] " warn("\"%s\" [%s.ko] undefined!\n",
"undefined!\n", s->name, mod->name); s->name, mod->name);
continue; continue;
} }
s->module = exp->module; s->module = exp->module;
@ -584,8 +581,7 @@ add_versions(struct buffer *b, struct module *mod)
continue; continue;
} }
if (!s->crc_valid) { if (!s->crc_valid) {
fprintf(stderr, "*** Warning: \"%s\" [%s.ko] " warn("\"%s\" [%s.ko] has no CRC!\n",
"has no CRC!\n",
s->name, mod->name); s->name, mod->name);
continue; continue;
} }

View File

@ -91,17 +91,22 @@ struct elf_info {
unsigned int modinfo_len; unsigned int modinfo_len;
}; };
/* file2alias.c */
void handle_moddevtable(struct module *mod, struct elf_info *info, void handle_moddevtable(struct module *mod, struct elf_info *info,
Elf_Sym *sym, const char *symname); Elf_Sym *sym, const char *symname);
void add_moddevtable(struct buffer *buf, struct module *mod); void add_moddevtable(struct buffer *buf, struct module *mod);
/* sumversion.c */
void maybe_frob_rcs_version(const char *modfilename, void maybe_frob_rcs_version(const char *modfilename,
char *version, char *version,
void *modinfo, void *modinfo,
unsigned long modinfo_offset); unsigned long modinfo_offset);
void get_src_version(const char *modname, char sum[], unsigned sumlen); void get_src_version(const char *modname, char sum[], unsigned sumlen);
/* from modpost.c */
void *grab_file(const char *filename, unsigned long *size); void *grab_file(const char *filename, unsigned long *size);
char* get_next_line(unsigned long *pos, void *file, unsigned long size); char* get_next_line(unsigned long *pos, void *file, unsigned long size);
void release_file(void *file, unsigned long size); void release_file(void *file, unsigned long size);
void fatal(const char *fmt, ...);
void warn(const char *fmt, ...);

View File

@ -316,8 +316,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
file = grab_file(cmd, &flen); file = grab_file(cmd, &flen);
if (!file) { if (!file) {
fprintf(stderr, "Warning: could not find %s for %s\n", warn("could not find %s for %s\n", cmd, objfile);
cmd, objfile);
goto out; goto out;
} }
@ -355,9 +354,8 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
/* Check if this file is in same dir as objfile */ /* Check if this file is in same dir as objfile */
if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) { if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) {
if (!parse_file(line, md)) { if (!parse_file(line, md)) {
fprintf(stderr, warn("could not open %s: %s\n",
"Warning: could not open %s: %s\n", line, strerror(errno));
line, strerror(errno));
goto out_file; goto out_file;
} }
@ -397,23 +395,20 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
file = grab_file(filelist, &len); file = grab_file(filelist, &len);
if (!file) { if (!file) {
fprintf(stderr, "Warning: could not find versions for %s\n", warn("could not find versions for %s\n", filelist);
filelist);
return; return;
} }
sources = strchr(file, '\n'); sources = strchr(file, '\n');
if (!sources) { if (!sources) {
fprintf(stderr, "Warning: malformed versions file for %s\n", warn("malformed versions file for %s\n", modname);
modname);
goto release; goto release;
} }
sources++; sources++;
end = strchr(sources, '\n'); end = strchr(sources, '\n');
if (!end) { if (!end) {
fprintf(stderr, "Warning: bad ending versions file for %s\n", warn("bad ending versions file for %s\n", modname);
modname);
goto release; goto release;
} }
*end = '\0'; *end = '\0';
@ -438,19 +433,19 @@ static void write_version(const char *filename, const char *sum,
fd = open(filename, O_RDWR); fd = open(filename, O_RDWR);
if (fd < 0) { if (fd < 0) {
fprintf(stderr, "Warning: changing sum in %s failed: %s\n", warn("changing sum in %s failed: %s\n",
filename, strerror(errno)); filename, strerror(errno));
return; return;
} }
if (lseek(fd, offset, SEEK_SET) == (off_t)-1) { if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n", warn("changing sum in %s:%lu failed: %s\n",
filename, offset, strerror(errno)); filename, offset, strerror(errno));
goto out; goto out;
} }
if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) { if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
fprintf(stderr, "Warning: writing sum in %s failed: %s\n", warn("writing sum in %s failed: %s\n",
filename, strerror(errno)); filename, strerror(errno));
goto out; goto out;
} }