X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=scripts%2Fbmptologo.c;h=443cdda4da243e2ce79e5595aa752d99bf21073b;hb=87fb89c353234910f500934b5f83577d3df88810;hp=fdac7cfc8498f944ba2a330cf9a7fffb42adbf7d;hpb=333cf5284c70ab75389875bb5169926d748d4cc4;p=firefly-linux-kernel-4.4.55.git diff --git a/scripts/bmptologo.c b/scripts/bmptologo.c index fdac7cfc8498..443cdda4da24 100644 --- a/scripts/bmptologo.c +++ b/scripts/bmptologo.c @@ -104,69 +104,25 @@ static unsigned long logo_height; static unsigned long data_long; static unsigned long data_start; static unsigned char *logo_data; -static struct color logo_clut[MAX_LINUX_LOGO_COLORS]; -static unsigned int logo_clutsize; static void die(const char *fmt, ...) __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2))); static void usage(void) __attribute ((noreturn)); -static unsigned int get_number(FILE *fp) -{ - int c, val; - - /* Skip leading whitespace */ - do { - c = fgetc(fp); - if (c == EOF) - die("%s: end of file\n", filename); - if (c == '#') { - /* Ignore comments 'till end of line */ - do { - c = fgetc(fp); - if (c == EOF) - die("%s: end of file\n", filename); - } while (c != '\n'); - } - } while (isspace(c)); - - /* Parse decimal number */ - val = 0; - while (isdigit(c)) { - val = 10*val+c-'0'; - c = fgetc(fp); - if (c == EOF) - die("%s: end of file\n", filename); - } - return val; -} - -static unsigned int get_number255(FILE *fp, unsigned int maxval) -{ - unsigned int val = get_number(fp); - return (255*val+maxval/2)/maxval; -} - static void read_image(void) { - FILE *fp; - unsigned long i; + int fd; struct stat s; - char j = 0; - int magic; - unsigned int maxval; - char read_buf[0x28]; - long ret = 0; unsigned char *data; /* open image file */ - fp = open(filename, O_RDONLY); - if (!fp) + fd = open(filename, O_RDONLY); + if (fd < 0) die("Cannot open file isll.. %s: %s\n", filename, strerror(errno)); - if (fstat(fp, &s) < 0) { - die("Cannot stat file isll.. %s: %s\n", filename, strerror(errno)); - } + if (fstat(fd, &s) < 0) + die("Cannot stat file isll.. %s: %s\n", filename, strerror(errno)); + #if 0 ret = fread(read_buf,1,0x26,fp); if (ret != 0x26) @@ -195,9 +151,9 @@ static void read_image(void) if (ret != data_long) die("read file %s: error logo_data=%ld\n", filename,ret); #else - data = mmap(0, s.st_size, PROT_READ, MAP_SHARED, fp, 0); - if (data == MAP_FAILED) - die("read file %s: error logo_data\n", filename); + data = mmap(0, s.st_size, PROT_READ, MAP_SHARED, fd, 0); + if (data == MAP_FAILED) + die("read file %s: error logo_data\n", filename); logo_data = data + 54; logo_height = (data[0x19]<<24) + (data[0x18]<<16) +(data[0x17]<<8) +(data[0x16]); logo_width = (data[0x15]<<24) + (data[0x14]<<16) +(data[0x13]<<8) +(data[0x12]); @@ -218,7 +174,7 @@ static void read_image(void) logo_data[9],logo_data[10],logo_data[11]); #endif /* close file */ - close(fp); + close(fd); }