diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-08-27 22:29:43 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-08-27 22:29:43 +0000 |
commit | 18c93029fdd80cca3a6baafe125de2254ebe4cfc (patch) | |
tree | 4f09a65dbb055cdb5779e6ec80364bdab1527ebd | |
parent | 8f0e34280342f069cbd026112a7012e5edb356b2 (diff) | |
download | busybox-w32-18c93029fdd80cca3a6baafe125de2254ebe4cfc.tar.gz busybox-w32-18c93029fdd80cca3a6baafe125de2254ebe4cfc.tar.bz2 busybox-w32-18c93029fdd80cca3a6baafe125de2254ebe4cfc.zip |
insmod: shrink
function old new delta
obj_allocate_commons 488 462 -26
insmod_main 3830 3714 -116
-rw-r--r-- | modutils/insmod.c | 31 | ||||
-rw-r--r-- | networking/udhcp/dhcpc.c | 5 |
2 files changed, 16 insertions, 20 deletions
diff --git a/modutils/insmod.c b/modutils/insmod.c index 9dcc5b02d..120feabf3 100644 --- a/modutils/insmod.c +++ b/modutils/insmod.c | |||
@@ -2212,7 +2212,7 @@ static struct obj_section *obj_create_alloced_section(struct obj_file *f, | |||
2212 | sec->name = name; | 2212 | sec->name = name; |
2213 | sec->idx = newidx; | 2213 | sec->idx = newidx; |
2214 | if (size) | 2214 | if (size) |
2215 | sec->contents = xmalloc(size); | 2215 | sec->contents = xzalloc(size); |
2216 | 2216 | ||
2217 | obj_insert_section_load_order(f, sec); | 2217 | obj_insert_section_load_order(f, sec); |
2218 | 2218 | ||
@@ -2227,7 +2227,7 @@ static struct obj_section *obj_create_alloced_section_first(struct obj_file *f, | |||
2227 | int newidx = f->header.e_shnum++; | 2227 | int newidx = f->header.e_shnum++; |
2228 | struct obj_section *sec; | 2228 | struct obj_section *sec; |
2229 | 2229 | ||
2230 | f->sections = xrealloc(f->sections, (newidx + 1) * sizeof(sec)); | 2230 | f->sections = xrealloc_vector(f->sections, 2, newidx); |
2231 | f->sections[newidx] = sec = arch_new_section(); | 2231 | f->sections[newidx] = sec = arch_new_section(); |
2232 | 2232 | ||
2233 | sec->header.sh_type = SHT_PROGBITS; | 2233 | sec->header.sh_type = SHT_PROGBITS; |
@@ -2237,7 +2237,7 @@ static struct obj_section *obj_create_alloced_section_first(struct obj_file *f, | |||
2237 | sec->name = name; | 2237 | sec->name = name; |
2238 | sec->idx = newidx; | 2238 | sec->idx = newidx; |
2239 | if (size) | 2239 | if (size) |
2240 | sec->contents = xmalloc(size); | 2240 | sec->contents = xzalloc(size); |
2241 | 2241 | ||
2242 | sec->load_next = f->load_order; | 2242 | sec->load_next = f->load_order; |
2243 | f->load_order = sec; | 2243 | f->load_order = sec; |
@@ -2689,8 +2689,7 @@ static void new_get_kernel_symbols(void) | |||
2689 | /* Collect the modules' symbols. */ | 2689 | /* Collect the modules' symbols. */ |
2690 | 2690 | ||
2691 | if (nmod) { | 2691 | if (nmod) { |
2692 | ext_modules = modules = xmalloc(nmod * sizeof(*modules)); | 2692 | ext_modules = modules = xzalloc(nmod * sizeof(*modules)); |
2693 | memset(modules, 0, nmod * sizeof(*modules)); | ||
2694 | for (i = 0, mn = module_names, m = modules; | 2693 | for (i = 0, mn = module_names, m = modules; |
2695 | i < nmod; ++i, ++m, mn += strlen(mn) + 1) { | 2694 | i < nmod; ++i, ++m, mn += strlen(mn) + 1) { |
2696 | struct new_module_info info; | 2695 | struct new_module_info info; |
@@ -2770,13 +2769,14 @@ static int new_is_kernel_checksummed(void) | |||
2770 | } | 2769 | } |
2771 | 2770 | ||
2772 | 2771 | ||
2773 | static void new_create_this_module(struct obj_file *f, const char *m_name) | 2772 | static void new_create_this_module(struct obj_file *f, const char *m_name) |
2774 | { | 2773 | { |
2775 | struct obj_section *sec; | 2774 | struct obj_section *sec; |
2776 | 2775 | ||
2777 | sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long, | 2776 | sec = obj_create_alloced_section_first(f, ".this", tgt_sizeof_long, |
2778 | sizeof(struct new_module)); | 2777 | sizeof(struct new_module)); |
2779 | memset(sec->contents, 0, sizeof(struct new_module)); | 2778 | /* done by obj_create_alloced_section_first: */ |
2779 | /*memset(sec->contents, 0, sizeof(struct new_module));*/ | ||
2780 | 2780 | ||
2781 | obj_add_symbol(f, SPFX "__this_module", -1, | 2781 | obj_add_symbol(f, SPFX "__this_module", -1, |
2782 | ELF_ST_INFO(STB_LOCAL, STT_OBJECT), sec->idx, 0, | 2782 | ELF_ST_INFO(STB_LOCAL, STT_OBJECT), sec->idx, 0, |
@@ -3083,9 +3083,9 @@ static void obj_allocate_commons(struct obj_file *f) | |||
3083 | if (i == f->header.e_shnum) { | 3083 | if (i == f->header.e_shnum) { |
3084 | struct obj_section *sec; | 3084 | struct obj_section *sec; |
3085 | 3085 | ||
3086 | f->header.e_shnum++; | ||
3086 | f->sections = xrealloc_vector(f->sections, 2, i); | 3087 | f->sections = xrealloc_vector(f->sections, 2, i); |
3087 | f->sections[i] = sec = arch_new_section(); | 3088 | f->sections[i] = sec = arch_new_section(); |
3088 | f->header.e_shnum = i + 1; | ||
3089 | 3089 | ||
3090 | sec->header.sh_type = SHT_PROGBITS; | 3090 | sec->header.sh_type = SHT_PROGBITS; |
3091 | sec->header.sh_flags = SHF_WRITE | SHF_ALLOC; | 3091 | sec->header.sh_flags = SHF_WRITE | SHF_ALLOC; |
@@ -3124,12 +3124,9 @@ static void obj_allocate_commons(struct obj_file *f) | |||
3124 | for (i = 0; i < f->header.e_shnum; ++i) { | 3124 | for (i = 0; i < f->header.e_shnum; ++i) { |
3125 | struct obj_section *s = f->sections[i]; | 3125 | struct obj_section *s = f->sections[i]; |
3126 | if (s->header.sh_type == SHT_NOBITS) { | 3126 | if (s->header.sh_type == SHT_NOBITS) { |
3127 | s->contents = NULL; | ||
3127 | if (s->header.sh_size != 0) | 3128 | if (s->header.sh_size != 0) |
3128 | s->contents = memset(xmalloc(s->header.sh_size), | 3129 | s->contents = xzalloc(s->header.sh_size), |
3129 | 0, s->header.sh_size); | ||
3130 | else | ||
3131 | s->contents = NULL; | ||
3132 | |||
3133 | s->header.sh_type = SHT_PROGBITS; | 3130 | s->header.sh_type = SHT_PROGBITS; |
3134 | } | 3131 | } |
3135 | } | 3132 | } |
@@ -3354,8 +3351,7 @@ static struct obj_file *obj_load(FILE *fp, int loadprogbits UNUSED_PARAM) | |||
3354 | } | 3351 | } |
3355 | 3352 | ||
3356 | shnum = f->header.e_shnum; | 3353 | shnum = f->header.e_shnum; |
3357 | f->sections = xmalloc(sizeof(struct obj_section *) * shnum); | 3354 | f->sections = xzalloc(sizeof(struct obj_section *) * shnum); |
3358 | memset(f->sections, 0, sizeof(struct obj_section *) * shnum); | ||
3359 | 3355 | ||
3360 | section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); | 3356 | section_headers = alloca(sizeof(ElfW(Shdr)) * shnum); |
3361 | fseek(fp, f->header.e_shoff, SEEK_SET); | 3357 | fseek(fp, f->header.e_shoff, SEEK_SET); |
@@ -3391,14 +3387,13 @@ static struct obj_file *obj_load(FILE *fp, int loadprogbits UNUSED_PARAM) | |||
3391 | case SHT_SYMTAB: | 3387 | case SHT_SYMTAB: |
3392 | case SHT_STRTAB: | 3388 | case SHT_STRTAB: |
3393 | case SHT_RELM: | 3389 | case SHT_RELM: |
3390 | sec->contents = NULL; | ||
3394 | if (sec->header.sh_size > 0) { | 3391 | if (sec->header.sh_size > 0) { |
3395 | sec->contents = xmalloc(sec->header.sh_size); | 3392 | sec->contents = xzalloc(sec->header.sh_size); |
3396 | fseek(fp, sec->header.sh_offset, SEEK_SET); | 3393 | fseek(fp, sec->header.sh_offset, SEEK_SET); |
3397 | if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { | 3394 | if (fread(sec->contents, sec->header.sh_size, 1, fp) != 1) { |
3398 | bb_perror_msg_and_die("error reading ELF section data"); | 3395 | bb_perror_msg_and_die("error reading ELF section data"); |
3399 | } | 3396 | } |
3400 | } else { | ||
3401 | sec->contents = NULL; | ||
3402 | } | 3397 | } |
3403 | break; | 3398 | break; |
3404 | 3399 | ||
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c index 5caa00c83..92ebe3676 100644 --- a/networking/udhcp/dhcpc.c +++ b/networking/udhcp/dhcpc.c | |||
@@ -259,9 +259,10 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv) | |||
259 | if (opt & OPT_o) | 259 | if (opt & OPT_o) |
260 | client_config.no_default_options = 1; | 260 | client_config.no_default_options = 1; |
261 | while (list_O) { | 261 | while (list_O) { |
262 | int n = index_in_strings(dhcp_option_strings, llist_pop(&list_O)); | 262 | char *optstr = llist_pop(&list_O); |
263 | int n = index_in_strings(dhcp_option_strings, optstr); | ||
263 | if (n < 0) | 264 | if (n < 0) |
264 | bb_error_msg_and_die("unknown option '%s'", list_O->data); | 265 | bb_error_msg_and_die("unknown option '%s'", optstr); |
265 | n = dhcp_options[n].code; | 266 | n = dhcp_options[n].code; |
266 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); | 267 | client_config.opt_mask[n >> 3] |= 1 << (n & 7); |
267 | } | 268 | } |