Revisión | f89fdc91346995e642534a9c5db4e8cd8289a7da (tree) |
---|---|
Tiempo | 2014-02-18 17:49:26 |
Autor | Yoshinori Sato <ysato@sa76...> |
Commiter | Yoshinori Sato |
cosmetic update
@@ -39,11 +39,13 @@ const static struct option long_options[] = { | ||
39 | 39 | |
40 | 40 | static void usage(void) |
41 | 41 | { |
42 | - puts(PROGNAME " [-p port][-f input clock frequency][-b][--userboot][-l][-V] filename"); | |
42 | + puts(PROGNAME "-f input clock frequency [-p port]]" | |
43 | + "[-b][--userboot][-l][-V] filename"); | |
43 | 44 | } |
44 | 45 | |
45 | 46 | /* read raw binary */ |
46 | -static int write_binary(FILE *fp, struct writeinfo_t *writeinfo, struct port_t *p) | |
47 | +static int write_binary(FILE *fp, struct writeinfo_t *writeinfo, | |
48 | + struct port_t *p) | |
47 | 49 | { |
48 | 50 | int fno; |
49 | 51 | struct stat bin_st; |
@@ -55,7 +57,8 @@ static int write_binary(FILE *fp, struct writeinfo_t *writeinfo, struct port_t * | ||
55 | 57 | fstat(fno, &bin_st); |
56 | 58 | bin_len = bin_st.st_size; |
57 | 59 | |
58 | - if ((bin_buf = (unsigned char *)mmap(NULL, bin_len, PROT_READ, MAP_SHARED, fno, 0)) == MAP_FAILED) | |
60 | + if ((bin_buf = (unsigned char *)mmap(NULL, bin_len, PROT_READ, | |
61 | + MAP_SHARED, fno, 0)) == MAP_FAILED) | |
59 | 62 | goto error_perror; |
60 | 63 | writeinfo->area.end = bin_len - 1; |
61 | 64 | if (!write_rom(p, bin_buf, writeinfo)) |
@@ -88,13 +91,15 @@ static int write_srec(FILE *fp, struct writeinfo_t *writeinfo, struct port_t *p) | ||
88 | 91 | const static int address_len[]={0,4,6,8,0,0,0,8,6,4}; |
89 | 92 | int r = 0; |
90 | 93 | int l; |
94 | + unsigned int romsize; | |
91 | 95 | |
92 | - romimage = (unsigned char *)malloc(writeinfo->area.end - writeinfo->area.start + 1); | |
96 | + romsize = writeinfo->area.end - writeinfo->area.start + 1; | |
97 | + romimage = (unsigned char *)malloc(romsize); | |
93 | 98 | if (!romimage) { |
94 | 99 | perror(PROGNAME); |
95 | 100 | goto error; |
96 | 101 | } |
97 | - memset(romimage, 0xff, writeinfo->area.end - writeinfo->area.start + 1); | |
102 | + memset(romimage, 0xff, romsize); | |
98 | 103 | |
99 | 104 | while (fgets(linebuf, sizeof(linebuf), fp)) { |
100 | 105 | /* check valid Srecord */ |
@@ -126,7 +131,8 @@ static int write_srec(FILE *fp, struct writeinfo_t *writeinfo, struct port_t *p) | ||
126 | 131 | /* area check */ |
127 | 132 | if (addr < writeinfo->area.start || |
128 | 133 | (addr + len - 1) > writeinfo->area.end) { |
129 | - fprintf(stderr, "srec address %08x is out of romarea\n", addr); | |
134 | + fprintf(stderr, | |
135 | + "srec address %08x is out of rom\n", addr); | |
130 | 136 | goto error; |
131 | 137 | } |
132 | 138 | bufp = romimage + addr - writeinfo->area.start; |