firmware-tools/ptgen: fix minor coding style issues
Signed-off-by: Michael Heimpold <mhei@heimpold.de>
This commit is contained in:
parent
4b275baf91
commit
83f729dfb2
1 changed files with 34 additions and 26 deletions
|
@ -70,7 +70,8 @@ char *filename = NULL;
|
||||||
*
|
*
|
||||||
* returns the size in KByte
|
* returns the size in KByte
|
||||||
*/
|
*/
|
||||||
static long to_kbytes(const char *string) {
|
static long to_kbytes(const char *string)
|
||||||
|
{
|
||||||
int exp = 0;
|
int exp = 0;
|
||||||
long result;
|
long result;
|
||||||
char *end;
|
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 */
|
/* 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;
|
int c,h,s;
|
||||||
|
|
||||||
s = (sect % sectors) + 1;
|
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 */
|
/* 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;
|
int cyl_size = heads * sectors;
|
||||||
|
|
||||||
return sect + cyl_size - (sect % cyl_size);
|
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);
|
fprintf(stderr, "Invalid size in partition %d!\n", i);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pte[i].active = ((i + 1) == active) ? 0x80 : 0;
|
pte[i].active = ((i + 1) == active) ? 0x80 : 0;
|
||||||
pte[i].type = parts[i].type;
|
pte[i].type = parts[i].type;
|
||||||
|
|
||||||
start = sect + sectors;
|
start = sect + sectors;
|
||||||
if (kb_align != 0)
|
if (kb_align != 0)
|
||||||
start = round_to_kb(start);
|
start = round_to_kb(start);
|
||||||
pte[i].start = cpu_to_le32(start);
|
pte[i].start = cpu_to_le32(start);
|
||||||
|
|
||||||
sect = start + parts[i].size * 2;
|
sect = start + parts[i].size * 2;
|
||||||
if (kb_align == 0)
|
if (kb_align == 0)
|
||||||
sect = round_to_cyl(sect);
|
sect = round_to_cyl(sect);
|
||||||
pte[i].length = cpu_to_le32(len = sect - start);
|
pte[i].length = cpu_to_le32(len = sect - start);
|
||||||
|
|
||||||
to_chs(start, pte[i].chs_start);
|
to_chs(start, pte[i].chs_start);
|
||||||
to_chs(start + len - 1, pte[i].chs_end);
|
to_chs(start + len - 1, pte[i].chs_end);
|
||||||
|
|
||||||
if (verbose)
|
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);
|
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)start * 512);
|
||||||
printf("%ld\n", ((long) len * 512));
|
printf("%ld\n", (long)len * 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) {
|
if ((fd = open(filename, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0) {
|
||||||
|
|
Loading…
Reference in a new issue