style fixes

This commit is contained in:
Denis Vlasenko 2006-10-12 20:06:18 +00:00
parent 98ae2160b6
commit 9c267b851e
3 changed files with 276 additions and 286 deletions

View File

@ -37,8 +37,8 @@ int bunzip2_main(int argc, char **argv)
/* Check that the input is sane. */
if (isatty(src_fd) && (opt & BUNZIP2_OPT_FORCE) == 0) {
bb_error_msg_and_die("Compressed data not read from terminal. "
"Use -f to force it.");
bb_error_msg_and_die("compressed data not read from terminal, "
"use -f to force it");
}
if (filename) {

View File

@ -65,9 +65,8 @@ int gunzip_main(int argc, char **argv)
optind = argc; /* we don't handle "gunzip - a.gz b.gz" */
} else {
src_fd = xopen(old_path, O_RDONLY);
/* Get the time stamp on the input file. */
xstat(old_path, &stat_buf);
fstat(src_fd, &stat_buf);
}
/* Check that the input is sane. */
@ -131,11 +130,11 @@ int gunzip_main(int argc, char **argv)
}
else if (ENABLE_DESKTOP && (opt & GUNZIP_OPT_VERBOSE)) {
fprintf(stderr, "%s: %u%% - replaced with %s\n",
// TODO: LARGEFILE support for stat_buf.st_size?
old_path, (unsigned)(stat_buf.st_size*100 / (status+1)), new_path);
}
} else {
bb_error_msg("invalid magic"); exitcode = 1;
bb_error_msg("invalid magic");
exitcode = 1;
}
if (status < 0 && new_path) {
/* Unzip failed, remove new path instead of old path */

View File

@ -368,23 +368,20 @@ enum {
/* The structures used in Linux 2.1. */
/* Note: new_module_symbol does not use tgt_long intentionally */
struct new_module_symbol
{
struct new_module_symbol {
unsigned long value;
unsigned long name;
};
struct new_module_persist;
struct new_module_ref
{
struct new_module_ref {
unsigned tgt_long dep; /* kernel addresses */
unsigned tgt_long ref;
unsigned tgt_long next_ref;
};
struct new_module
{
struct new_module {
unsigned tgt_long size_of_struct; /* == sizeof(module) */
unsigned tgt_long next;
unsigned tgt_long name;
@ -426,8 +423,7 @@ struct new_module
#define KALLSYMS_SEC_NAME "__kallsyms"
struct new_module_info
{
struct new_module_info {
unsigned long addr;
unsigned long size;
unsigned long flags;
@ -561,8 +557,7 @@ struct obj_symbol
#define HASH_BUCKETS 521
struct obj_file
{
struct obj_file {
ElfW(Ehdr) header;
ElfW(Addr) baseaddr;
struct obj_section **sections;
@ -577,24 +572,21 @@ struct obj_file
struct obj_symbol *symtab[HASH_BUCKETS];
};
enum obj_reloc
{
enum obj_reloc {
obj_reloc_ok,
obj_reloc_overflow,
obj_reloc_dangerous,
obj_reloc_unhandled
};
struct obj_string_patch
{
struct obj_string_patch {
struct obj_string_patch *next;
int reloc_secidx;
ElfW(Addr) reloc_offset;
ElfW(Addr) string_offset;
};
struct obj_symbol_patch
{
struct obj_symbol_patch {
struct obj_symbol_patch *next;
int reloc_secidx;
ElfW(Addr) reloc_offset;
@ -805,7 +797,6 @@ static char *m_filename;
static char *m_fullName;
/*======================================================================*/
@ -2153,8 +2144,7 @@ obj_find_symbol(struct obj_file *f, const char *name)
return NULL;
}
static ElfW(Addr)
obj_symbol_final_value(struct obj_file * f, struct obj_symbol * sym)
static ElfW(Addr) obj_symbol_final_value(struct obj_file * f, struct obj_symbol * sym)
{
if (sym) {
if (sym->secidx >= SHN_LORESERVE)
@ -2712,7 +2702,7 @@ retry_modules_load:
/* Collect the modules' symbols. */
if (nmod){
if (nmod) {
ext_modules = modules = xmalloc(nmod * sizeof(*modules));
memset(modules, 0, nmod * sizeof(*modules));
for (i = 0, mn = module_names, m = modules;
@ -2878,9 +2868,7 @@ static int new_create_module_ksymtab(struct obj_file *f)
size_t nsyms;
int *loaded;
sec =
obj_create_alloced_section(f, "__ksymtab", tgt_sizeof_void_p,
0);
sec = obj_create_alloced_section(f, "__ksymtab", tgt_sizeof_void_p, 0);
/* We don't want to export symbols residing in sections that
aren't loaded. There are a number of these created so that
@ -3269,7 +3257,8 @@ static int obj_relocate(struct obj_file *f, ElfW(Addr) base)
/* Do it! */
switch (arch_apply_relocation
(f, targsec, symsec, intsym, rel, value)) {
(f, targsec, symsec, intsym, rel, value)
) {
case obj_reloc_ok:
break;
@ -3419,7 +3408,8 @@ static struct obj_file *obj_load(FILE * fp, int loadprogbits)
sec->header = section_headers[i];
sec->idx = i;
if(sec->header.sh_size) switch (sec->header.sh_type) {
if(sec->header.sh_size) {
switch (sec->header.sh_type) {
case SHT_NULL:
case SHT_NOTE:
case SHT_NOBITS:
@ -3472,6 +3462,7 @@ static struct obj_file *obj_load(FILE * fp, int loadprogbits)
return NULL;
}
}
}
/* Do what sort of interpretation as needed by each section. */
@ -3526,7 +3517,6 @@ static struct obj_file *obj_load(FILE * fp, int loadprogbits)
name = f->sections[sym->st_shndx]->name;
else
continue;
#if defined(__SH5__)
/*
* For sh64 it is possible that the target of a branch
@ -3606,10 +3596,11 @@ static void hide_special_symbols(struct obj_file *f)
struct obj_symbol *sym;
const char *const *p;
for (p = specials; *p; ++p)
if ((sym = obj_find_symbol(f, *p)) != NULL)
sym->info =
ELF_ST_INFO(STB_LOCAL, ELF_ST_TYPE(sym->info));
for (p = specials; *p; ++p) {
sym = obj_find_symbol(f, *p);
if (sym != NULL)
sym->info = ELF_ST_INFO(STB_LOCAL, ELF_ST_TYPE(sym->info));
}
}
@ -3629,12 +3620,14 @@ static int obj_gpl_license(struct obj_file *f, const char **license)
"Dual MPL/GPL",
};
if ((sec = obj_find_section(f, ".modinfo"))) {
sec = obj_find_section(f, ".modinfo");
if (sec) {
const char *value, *ptr, *endptr;
ptr = sec->contents;
endptr = ptr + sec->header.sh_size;
while (ptr < endptr) {
if ((value = strchr(ptr, '=')) && strncmp(ptr, "license", value-ptr) == 0) {
value = strchr(ptr, '=');
if (value && strncmp(ptr, "license", value-ptr) == 0) {
int i;
if (license)
*license = value+1;
@ -3690,7 +3683,8 @@ static void check_tainted_module(struct obj_file *f, char *m_name)
const char *ptr;
kernel_has_tainted = 1;
if ((fd = open(tainted_file, O_RDWR)) < 0) {
fd = open(tainted_file, O_RDWR);
if (fd < 0) {
if (errno == ENOENT)
kernel_has_tainted = 0;
else if (errno == EACCES)
@ -3957,7 +3951,7 @@ void print_load_map(struct obj_file *f);
int insmod_main( int argc, char **argv)
{
char *opt_o;
char *opt_o, *arg1;
int len;
int k_crcs;
char *tmp, *tmp1;
@ -3983,17 +3977,18 @@ int insmod_main( int argc, char **argv)
/* Parse any options */
getopt32(argc, argv, OPTION_STR, &opt_o);
arg1 = argv[optind];
if (option_mask32 & OPT_o) { // -o /* name the output module */
free(m_name);
m_name = xstrdup(opt_o);
}
if (argv[optind] == NULL) {
if (arg1 == NULL) {
bb_show_usage();
}
/* Grab the module name */
tmp1 = xstrdup(argv[optind]);
tmp1 = xstrdup(arg1);
tmp = basename(tmp1);
len = strlen(tmp);
@ -4004,15 +3999,15 @@ int insmod_main( int argc, char **argv)
}
#if defined(CONFIG_FEATURE_2_6_MODULES)
if (k_version > 4 && len > 3 && tmp[len - 3] == '.' &&
tmp[len - 2] == 'k' && tmp[len - 1] == 'o') {
len-=3;
if (k_version > 4 && len > 3 && tmp[len - 3] == '.'
&& tmp[len - 2] == 'k' && tmp[len - 1] == 'o'
) {
len -= 3;
tmp[len] = '\0';
}
else
} else
#endif
if (len > 2 && tmp[len - 2] == '.' && tmp[len - 1] == 'o') {
len-=2;
len -= 2;
tmp[len] = '\0';
}
@ -4032,8 +4027,9 @@ int insmod_main( int argc, char **argv)
}
/* Get a filedesc for the module. Check we we have a complete path */
if (stat(argv[optind], &st) < 0 || !S_ISREG(st.st_mode) ||
(fp = fopen(argv[optind], "r")) == NULL) {
if (stat(arg1, &st) < 0 || !S_ISREG(st.st_mode)
|| (fp = fopen(arg1, "r")) == NULL
) {
/* Hmm. Could not open it. First search under /lib/modules/`uname -r`,
* but do not error out yet if we fail to find it... */
if (k_version) { /* uname succeedd */
@ -4047,7 +4043,7 @@ int insmod_main( int argc, char **argv)
* follow symlinks, but we do want to follow the
* /lib/modules/`uname -r` dir, So resolve it ourselves
* if it is a link... */
if (realpath (tmdn, real_module_dir) == NULL)
if (realpath(tmdn, real_module_dir) == NULL)
module_dir = tmdn;
else
module_dir = real_module_dir;
@ -4057,8 +4053,7 @@ int insmod_main( int argc, char **argv)
}
/* Check if we have found anything yet */
if (m_filename == 0 || ((fp = fopen(m_filename, "r")) == NULL))
{
if (m_filename == 0 || ((fp = fopen(m_filename, "r")) == NULL)) {
char module_dir[FILENAME_MAX];
free(m_filename);
@ -4067,12 +4062,12 @@ int insmod_main( int argc, char **argv)
strcpy(module_dir, _PATH_MODULES);
/* No module found under /lib/modules/`uname -r`, this
* time cast the net a bit wider. Search /lib/modules/ */
if (! recursive_action(module_dir, TRUE, FALSE, FALSE,
check_module_name_match, 0, m_fullName))
{
if (!recursive_action(module_dir, TRUE, FALSE, FALSE,
check_module_name_match, 0, m_fullName)
) {
if (m_filename == 0
|| ((fp = fopen(m_filename, "r")) == NULL))
{
|| ((fp = fopen(m_filename, "r")) == NULL)
) {
bb_error_msg("%s: no module by that name found", m_fullName);
goto out;
}
@ -4080,22 +4075,22 @@ int insmod_main( int argc, char **argv)
bb_error_msg_and_die("%s: no module by that name found", m_fullName);
}
} else
m_filename = xstrdup(argv[optind]);
m_filename = xstrdup(arg1);
if (flag_verbose)
printf("Using %s\n", m_filename);
#ifdef CONFIG_FEATURE_2_6_MODULES
if (k_version > 4)
{
if (k_version > 4) {
argv[optind] = m_filename;
optind--;
argv[optind + 1] = m_filename;
return insmod_ng_main(argc - optind, argv + optind);
}
#endif
if ((f = obj_load(fp, LOADBITS)) == NULL)
bb_perror_msg_and_die("Could not load the module");
f = obj_load(fp, LOADBITS);
if (f == NULL)
bb_perror_msg_and_die("cannot load the module");
if (get_modinfo_value(f, "kernel_version") == NULL)
m_has_modinfo = 0;
@ -4157,8 +4152,7 @@ int insmod_main( int argc, char **argv)
/* Allocate common symbols, symbol tables, and string tables. */
if (!new_create_this_module(f, m_name))
{
if (!new_create_this_module(f, m_name)) {
goto out;
}
@ -4170,10 +4164,8 @@ int insmod_main( int argc, char **argv)
/* done with the module name, on to the optional var=value arguments */
++optind;
if (optind < argc) {
if (!new_process_module_arguments(f, argc - optind, argv + optind))
{
if (!new_process_module_arguments(f, argc - optind, argv + optind)) {
goto out;
}
}
@ -4221,8 +4213,7 @@ int insmod_main( int argc, char **argv)
goto out;
}
if (!new_init_module(m_name, f, m_size))
{
if (!new_init_module(m_name, f, m_size)) {
delete_module(m_name);
goto out;
}