diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2009-02-14 12:36:16 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2009-02-14 12:36:16 +0000 |
commit | 4efcec937881b2c0f05f7923a0acc254091680e3 (patch) | |
tree | 286163c7c949cad89f712c548db63f4807eb730e | |
parent | 52b56b7585e959af10d663665fa3099c3c3862d7 (diff) | |
download | busybox-w32-4efcec937881b2c0f05f7923a0acc254091680e3.tar.gz busybox-w32-4efcec937881b2c0f05f7923a0acc254091680e3.tar.bz2 busybox-w32-4efcec937881b2c0f05f7923a0acc254091680e3.zip |
- misc untested shrinkage:
$ ./scripts/bloat-o-meter _bb_un.oorig busybox_unstripped
function old new delta
fbsplash_main 595 985 +390
fb_drawimage 493 - -493
------------------------------------------------------------------------------
(add/remove: 0/1 grow/shrink: 1/0 up/down: 390/-493) Total: -103 bytes
$ size miscutils/fbsplash.o*
text data bss dec hex filename
2019 0 0 2019 7e3 miscutils/fbsplash.o.oorig
1857 0 0 1857 741 miscutils/fbsplash.o.new
-rw-r--r-- | miscutils/fbsplash.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/miscutils/fbsplash.c b/miscutils/fbsplash.c index c6509555c..330dd4d1d 100644 --- a/miscutils/fbsplash.c +++ b/miscutils/fbsplash.c | |||
@@ -87,7 +87,7 @@ static void fb_open(const char *strfb_device) | |||
87 | * BYTES_PER_PIXEL /*(G.scr_var.bits_per_pixel / 8)*/ , | 87 | * BYTES_PER_PIXEL /*(G.scr_var.bits_per_pixel / 8)*/ , |
88 | PROT_WRITE, MAP_SHARED, fbfd, 0); | 88 | PROT_WRITE, MAP_SHARED, fbfd, 0); |
89 | if (G.addr == MAP_FAILED) | 89 | if (G.addr == MAP_FAILED) |
90 | bb_perror_msg_and_die("can't mmap %s", strfb_device); | 90 | bb_perror_msg_and_die("mmap"); |
91 | close(fbfd); | 91 | close(fbfd); |
92 | } | 92 | } |
93 | 93 | ||
@@ -121,7 +121,7 @@ static void fb_drawrectangle(void) | |||
121 | // vertical lines | 121 | // vertical lines |
122 | ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL); | 122 | ptr1 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx) * BYTES_PER_PIXEL); |
123 | ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * BYTES_PER_PIXEL); | 123 | ptr2 = (DATA*)(G.addr + (G.nbar_posy * G.scr_var.xres + G.nbar_posx + G.nbar_width - 1) * BYTES_PER_PIXEL); |
124 | cnt = G.nbar_posy + G.nbar_height - 1 - G.nbar_posy; | 124 | cnt = G.nbar_height - 1 /* HUH?! G.nbar_posy + G.nbar_height - 1 - G.nbar_posy*/; |
125 | do { | 125 | do { |
126 | *ptr1 = thispix; ptr1 += G.scr_var.xres; | 126 | *ptr1 = thispix; ptr1 += G.scr_var.xres; |
127 | *ptr2 = thispix; ptr2 += G.scr_var.xres; | 127 | *ptr2 = thispix; ptr2 += G.scr_var.xres; |
@@ -216,18 +216,18 @@ static void fb_drawprogressbar(unsigned percent) | |||
216 | */ | 216 | */ |
217 | static void fb_drawimage(void) | 217 | static void fb_drawimage(void) |
218 | { | 218 | { |
219 | char head[256]; | 219 | RESERVE_CONFIG_BUFFER(head, 256); |
220 | char s[80]; | 220 | RESERVE_CONFIG_BUFFER(s, 80); |
221 | FILE *theme_file; | 221 | int theme_file; |
222 | unsigned char *pixline; | 222 | unsigned char *pixline; |
223 | unsigned i, j, width, height, line_size; | 223 | unsigned i, j, width, height, line_size; |
224 | 224 | ||
225 | memset(head, 0, sizeof(head)); | 225 | memset(head, 0, sizeof(head)); |
226 | theme_file = xfopen_stdin(G.image_filename); | 226 | theme_file = open_or_warn_stdin(G.image_filename); |
227 | 227 | ||
228 | // parse ppm header | 228 | // parse ppm header |
229 | while (1) { | 229 | while (1) { |
230 | if (fgets(s, sizeof(s), theme_file) == NULL) | 230 | if (safe_read(theme_file, s, sizeof(s)) <= 0) |
231 | bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); | 231 | bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); |
232 | 232 | ||
233 | if (s[0] == '#') | 233 | if (s[0] == '#') |
@@ -257,7 +257,7 @@ static void fb_drawimage(void) | |||
257 | unsigned char *pixel = pixline; | 257 | unsigned char *pixel = pixline; |
258 | DATA *src = (DATA *)(G.addr + j * G.scr_fix.line_length); | 258 | DATA *src = (DATA *)(G.addr + j * G.scr_fix.line_length); |
259 | 259 | ||
260 | if (fread(pixline, 1, line_size, theme_file) != line_size) | 260 | if (safe_read(theme_file, pixline, line_size) != line_size) |
261 | bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); | 261 | bb_error_msg_and_die("bad PPM file '%s'", G.image_filename); |
262 | for (i = 0; i < width; i++) { | 262 | for (i = 0; i < width; i++) { |
263 | unsigned thispix; | 263 | unsigned thispix; |
@@ -268,8 +268,12 @@ static void fb_drawimage(void) | |||
268 | pixel += 3; | 268 | pixel += 3; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | free(pixline); | 271 | if (ENABLE_FEATURE_CLEAN_UP) { |
272 | fclose(theme_file); | 272 | free(pixline); |
273 | RELEASE_CONFIG_BUFFER(s); | ||
274 | RELEASE_CONFIG_BUFFER(head); | ||
275 | } | ||
276 | close(theme_file); | ||
273 | } | 277 | } |
274 | 278 | ||
275 | 279 | ||
@@ -294,7 +298,7 @@ static void init(const char *cfg_filename) | |||
294 | unsigned val = xatoi_u(token[1]); | 298 | unsigned val = xatoi_u(token[1]); |
295 | int i = index_in_strings(param_names, token[0]); | 299 | int i = index_in_strings(param_names, token[0]); |
296 | if (i < 0) | 300 | if (i < 0) |
297 | bb_error_msg_and_die("syntax error: '%s'", token[0]); | 301 | bb_error_msg_and_die("syntax error: %s", token[0]); |
298 | if (i >= 0 && i < 7) | 302 | if (i >= 0 && i < 7) |
299 | G.ns[i] = val; | 303 | G.ns[i] = val; |
300 | #if DEBUG | 304 | #if DEBUG |