aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2004-03-30 09:21:54 +0000
committerEric Andersen <andersen@codepoet.org>2004-03-30 09:21:54 +0000
commit0a92f3570224f3529b2f46431f44b69dd0ab64bd (patch)
tree25bea023fee99bc6d0e7636e9bcf2f253d9f2897
parent259cf97803dd6e3e9f7d11a84e5313f1ee93b7b5 (diff)
downloadbusybox-w32-0a92f3570224f3529b2f46431f44b69dd0ab64bd.tar.gz
busybox-w32-0a92f3570224f3529b2f46431f44b69dd0ab64bd.tar.bz2
busybox-w32-0a92f3570224f3529b2f46431f44b69dd0ab64bd.zip
As waldi noticed, checks for the size of an off_t and casting
etc was also redundant and possibly buggy...
-rw-r--r--util-linux/fdisk.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index e9ef5cee3..96517da96 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -93,13 +93,6 @@
93#endif 93#endif
94 94
95 95
96#if defined(CONFIG_LFS) || defined(__alpha__) || defined(__ia64__) || defined(__s390x__)
97typedef long long fdisk_loff_t;
98#else
99typedef long fdisk_loff_t;
100#endif
101
102
103/* including <linux/hdreg.h> also fails */ 96/* including <linux/hdreg.h> also fails */
104struct hd_geometry { 97struct hd_geometry {
105 unsigned char heads; 98 unsigned char heads;
@@ -1372,7 +1365,7 @@ xbsd_write_bootstrap (void)
1372 sector = get_start_sect(xbsd_part); 1365 sector = get_start_sect(xbsd_part);
1373#endif 1366#endif
1374 1367
1375 if (lseek (fd, (fdisk_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1) 1368 if (lseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
1376 fdisk_fatal (unable_to_seek); 1369 fdisk_fatal (unable_to_seek);
1377 if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) 1370 if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
1378 fdisk_fatal (unable_to_write); 1371 fdisk_fatal (unable_to_write);
@@ -1540,7 +1533,7 @@ xbsd_readlabel (struct partition *p, struct xbsd_disklabel *d)
1540 sector = 0; 1533 sector = 0;
1541#endif 1534#endif
1542 1535
1543 if (lseek (fd, (fdisk_loff_t) sector * SECTOR_SIZE, SEEK_SET) == -1) 1536 if (lseek (fd, sector * SECTOR_SIZE, SEEK_SET) == -1)
1544 fdisk_fatal (unable_to_seek); 1537 fdisk_fatal (unable_to_seek);
1545 if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE)) 1538 if (BSD_BBSIZE != read (fd, disklabelbuffer, BSD_BBSIZE))
1546 fdisk_fatal (unable_to_read); 1539 fdisk_fatal (unable_to_read);
@@ -1586,12 +1579,12 @@ xbsd_writelabel (struct partition *p, struct xbsd_disklabel *d)
1586 1579
1587#if defined (__alpha__) && BSD_LABELSECTOR == 0 1580#if defined (__alpha__) && BSD_LABELSECTOR == 0
1588 alpha_bootblock_checksum (disklabelbuffer); 1581 alpha_bootblock_checksum (disklabelbuffer);
1589 if (lseek (fd, (fdisk_loff_t) 0, SEEK_SET) == -1) 1582 if (lseek (fd, 0, SEEK_SET) == -1)
1590 fdisk_fatal (unable_to_seek); 1583 fdisk_fatal (unable_to_seek);
1591 if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE)) 1584 if (BSD_BBSIZE != write (fd, disklabelbuffer, BSD_BBSIZE))
1592 fdisk_fatal (unable_to_write); 1585 fdisk_fatal (unable_to_write);
1593#else 1586#else
1594 if (lseek (fd, (fdisk_loff_t) sector * SECTOR_SIZE + BSD_LABELOFFSET, 1587 if (lseek (fd, sector * SECTOR_SIZE + BSD_LABELOFFSET,
1595 SEEK_SET) == -1) 1588 SEEK_SET) == -1)
1596 fdisk_fatal (unable_to_seek); 1589 fdisk_fatal (unable_to_seek);
1597 if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel))) 1590 if (sizeof (struct xbsd_disklabel) != write (fd, d, sizeof (struct xbsd_disklabel)))
@@ -3401,8 +3394,8 @@ static void fdisk_fatal(enum failure why) {
3401 3394
3402static void 3395static void
3403seek_sector(uint secno) { 3396seek_sector(uint secno) {
3404 fdisk_loff_t offset = (fdisk_loff_t) secno * sector_size; 3397 off_t offset = secno * sector_size;
3405 if (lseek(fd, offset, SEEK_SET) == (fdisk_loff_t) -1) 3398 if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
3406 fdisk_fatal(unable_to_seek); 3399 fdisk_fatal(unable_to_seek);
3407} 3400}
3408 3401