mirror of https://github.com/hak5/openwrt.git
firmware-tools/ptgen: fix minor coding style issues
Signed-off-by: Michael Heimpold <mhei@heimpold.de>openwrt-18.06
parent
4b275baf91
commit
83f729dfb2
|
@ -70,7 +70,8 @@ char *filename = NULL;
|
|||
*
|
||||
* returns the size in KByte
|
||||
*/
|
||||
static long to_kbytes(const char *string) {
|
||||
static long to_kbytes(const char *string)
|
||||
{
|
||||
int exp = 0;
|
||||
long result;
|
||||
char *end;
|
||||
|
@ -99,7 +100,8 @@ static long to_kbytes(const char *string) {
|
|||
}
|
||||
|
||||
/* convert the sector number into a CHS value for the partition table */
|
||||
static void to_chs(long sect, unsigned char chs[3]) {
|
||||
static void to_chs(long sect, unsigned char chs[3])
|
||||
{
|
||||
int c,h,s;
|
||||
|
||||
s = (sect % sectors) + 1;
|
||||
|
@ -116,7 +118,8 @@ static void to_chs(long sect, unsigned char chs[3]) {
|
|||
}
|
||||
|
||||
/* round the sector number up to the next cylinder */
|
||||
static inline unsigned long round_to_cyl(long sect) {
|
||||
static inline unsigned long round_to_cyl(long sect)
|
||||
{
|
||||
int cyl_size = heads * sectors;
|
||||
|
||||
return sect + cyl_size - (sect % cyl_size);
|
||||
|
@ -140,22 +143,27 @@ static int gen_ptable(uint32_t signature, int nr)
|
|||
fprintf(stderr, "Invalid size in partition %d!\n", i);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pte[i].active = ((i + 1) == active) ? 0x80 : 0;
|
||||
pte[i].type = parts[i].type;
|
||||
|
||||
start = sect + sectors;
|
||||
if (kb_align != 0)
|
||||
start = round_to_kb(start);
|
||||
pte[i].start = cpu_to_le32(start);
|
||||
|
||||
sect = start + parts[i].size * 2;
|
||||
if (kb_align == 0)
|
||||
sect = round_to_cyl(sect);
|
||||
pte[i].length = cpu_to_le32(len = sect - start);
|
||||
|
||||
to_chs(start, pte[i].chs_start);
|
||||
to_chs(start + len - 1, pte[i].chs_end);
|
||||
|
||||
if (verbose)
|
||||
fprintf(stderr, "Partition %d: start=%ld, end=%ld, size=%ld\n", i, (long)start * 512, ((long)start + (long)len) * 512, (long)len * 512);
|
||||
printf("%ld\n", ((long) start * 512));
|
||||
printf("%ld\n", ((long) len * 512));
|
||||
printf("%ld\n", (long)start * 512);
|
||||
printf("%ld\n", (long)len * 512);
|
||||
}
|
||||
|
||||
if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) {
|
||||
|
|
Loading…
Reference in New Issue