aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 20:32:02 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-12-19 20:32:02 +0000
commit28703015ab71784f40bc97f720ed900e26bd03ca (patch)
treeff0f9a21d1822c9a2f35819db4156d9555f56116
parentf58906b6463436f6a19f72d43c3ab4ba69d79104 (diff)
downloadbusybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.tar.gz
busybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.tar.bz2
busybox-w32-28703015ab71784f40bc97f720ed900e26bd03ca.zip
u_short, ulong exterminated
fdiskXXX: add a bit of sanity (not enough by far)
-rw-r--r--console-tools/loadfont.c4
-rw-r--r--console-tools/loadkmap.c4
-rw-r--r--networking/inetd.c6
-rw-r--r--networking/traceroute.c32
-rw-r--r--networking/udhcp/arpping.c6
-rw-r--r--networking/udhcp/dhcprelay.c2
-rw-r--r--util-linux/fdisk.c68
-rw-r--r--util-linux/fdisk_osf.c53
-rw-r--r--util-linux/fdisk_sgi.c4
-rw-r--r--util-linux/fdisk_sun.c4
-rw-r--r--util-linux/mount.c2
11 files changed, 90 insertions, 95 deletions
diff --git a/console-tools/loadfont.c b/console-tools/loadfont.c
index 5a05876c2..36f0e6da9 100644
--- a/console-tools/loadfont.c
+++ b/console-tools/loadfont.c
@@ -81,14 +81,14 @@ do_loadtable(int fd, unsigned char *inbuf, int tailsz, int fontsize)
81 struct unipair *up; 81 struct unipair *up;
82 int ct = 0, maxct; 82 int ct = 0, maxct;
83 int glyph; 83 int glyph;
84 u_short unicode; 84 uint16_t unicode;
85 85
86 maxct = tailsz; /* more than enough */ 86 maxct = tailsz; /* more than enough */
87 up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair)); 87 up = (struct unipair *) xmalloc(maxct * sizeof(struct unipair));
88 88
89 for (glyph = 0; glyph < fontsize; glyph++) { 89 for (glyph = 0; glyph < fontsize; glyph++) {
90 while (tailsz >= 2) { 90 while (tailsz >= 2) {
91 unicode = (((u_short) inbuf[1]) << 8) + inbuf[0]; 91 unicode = (((uint16_t) inbuf[1]) << 8) + inbuf[0];
92 tailsz -= 2; 92 tailsz -= 2;
93 inbuf += 2; 93 inbuf += 2;
94 if (unicode == PSF_SEPARATOR) 94 if (unicode == PSF_SEPARATOR)
diff --git a/console-tools/loadkmap.c b/console-tools/loadkmap.c
index ce9b6817c..74a2378b4 100644
--- a/console-tools/loadkmap.c
+++ b/console-tools/loadkmap.c
@@ -29,7 +29,7 @@ int loadkmap_main(int argc, char **argv)
29{ 29{
30 struct kbentry ke; 30 struct kbentry ke;
31 int i, j, fd; 31 int i, j, fd;
32 u_short ibuff[NR_KEYS]; 32 uint16_t ibuff[NR_KEYS];
33 char flags[MAX_NR_KEYMAPS]; 33 char flags[MAX_NR_KEYMAPS];
34 char buff[7]; 34 char buff[7];
35 35
@@ -46,7 +46,7 @@ int loadkmap_main(int argc, char **argv)
46 46
47 for (i = 0; i < MAX_NR_KEYMAPS; i++) { 47 for (i = 0; i < MAX_NR_KEYMAPS; i++) {
48 if (flags[i] == 1) { 48 if (flags[i] == 1) {
49 xread(0, ibuff, NR_KEYS * sizeof(u_short)); 49 xread(0, ibuff, NR_KEYS * sizeof(uint16_t));
50 for (j = 0; j < NR_KEYS; j++) { 50 for (j = 0; j < NR_KEYS; j++) {
51 ke.kb_index = j; 51 ke.kb_index = j;
52 ke.kb_table = i; 52 ke.kb_table = i;
diff --git a/networking/inetd.c b/networking/inetd.c
index ec7b2e8f7..4856b11ae 100644
--- a/networking/inetd.c
+++ b/networking/inetd.c
@@ -985,7 +985,7 @@ static void config(int sig ATTRIBUTE_UNUSED)
985 } else 985 } else
986#endif 986#endif
987 { 987 {
988 u_short port = htons(atoi(sep->se_service)); 988 uint16_t port = htons(atoi(sep->se_service));
989 // FIXME: atoi_or_else(str, 0) would be handy here 989 // FIXME: atoi_or_else(str, 0) would be handy here
990 if (!port) { 990 if (!port) {
991 /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname)); 991 /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname));
@@ -1037,8 +1037,8 @@ static void config(int sig ATTRIBUTE_UNUSED)
1037 register_rpc(sep); 1037 register_rpc(sep);
1038 } else 1038 } else
1039#endif 1039#endif
1040 { 1040 {
1041 u_short port = htons(atoi(sep->se_service)); 1041 uint16_t port = htons(atoi(sep->se_service));
1042 1042
1043 if (!port) { 1043 if (!port) {
1044 /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname)); 1044 /*XXX*/ strncpy(protoname, sep->se_proto, sizeof(protoname));
diff --git a/networking/traceroute.c b/networking/traceroute.c
index 490076543..1462543f1 100644
--- a/networking/traceroute.c
+++ b/networking/traceroute.c
@@ -316,8 +316,8 @@ static int pmtu; /* Path MTU Discovery (RFC1191) */
316 316
317static char *hostname; 317static char *hostname;
318 318
319static u_short ident; 319static uint16_t ident;
320static u_short port = 32768 + 666; /* start udp dest port # for probe packets */ 320static uint16_t port = 32768 + 666; /* start udp dest port # for probe packets */
321 321
322static int waittime = 5; /* time to wait for response (in seconds) */ 322static int waittime = 5; /* time to wait for response (in seconds) */
323static int nflag; /* print addresses numerically */ 323static int nflag; /* print addresses numerically */
@@ -539,12 +539,12 @@ wait_for_reply(int sock, struct sockaddr_in *fromp, const struct timeval *tp)
539/* 539/*
540 * Checksum routine for Internet Protocol family headers (C Version) 540 * Checksum routine for Internet Protocol family headers (C Version)
541 */ 541 */
542static u_short 542static uint16_t
543in_cksum(u_short *addr, int len) 543in_cksum(uint16_t *addr, int len)
544{ 544{
545 int nleft = len; 545 int nleft = len;
546 u_short *w = addr; 546 uint16_t *w = addr;
547 u_short answer; 547 uint16_t answer;
548 int sum = 0; 548 int sum = 0;
549 549
550 /* 550 /*
@@ -589,7 +589,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
589 */ 589 */
590 if (doipcksum) { 590 if (doipcksum) {
591 outip->ip_sum = 591 outip->ip_sum =
592 in_cksum((u_short *)outip, sizeof(*outip) + optlen); 592 in_cksum((uint16_t *)outip, sizeof(*outip) + optlen);
593 if (outip->ip_sum == 0) 593 if (outip->ip_sum == 0)
594 outip->ip_sum = 0xffff; 594 outip->ip_sum = 0xffff;
595 } 595 }
@@ -610,7 +610,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
610 if (useicmp) { 610 if (useicmp) {
611 /* Always calculate checksum for icmp packets */ 611 /* Always calculate checksum for icmp packets */
612 outicmp->icmp_cksum = 0; 612 outicmp->icmp_cksum = 0;
613 outicmp->icmp_cksum = in_cksum((u_short *)outicmp, 613 outicmp->icmp_cksum = in_cksum((uint16_t *)outicmp,
614 packlen - (sizeof(*outip) + optlen)); 614 packlen - (sizeof(*outip) + optlen));
615 if (outicmp->icmp_cksum == 0) 615 if (outicmp->icmp_cksum == 0)
616 outicmp->icmp_cksum = 0xffff; 616 outicmp->icmp_cksum = 0xffff;
@@ -628,7 +628,7 @@ send_probe(int seq, int ttl, struct timeval *tp)
628 ui->ui_pr = oui->ui_pr; 628 ui->ui_pr = oui->ui_pr;
629 ui->ui_len = outudp->len; 629 ui->ui_len = outudp->len;
630 outudp->check = 0; 630 outudp->check = 0;
631 outudp->check = in_cksum((u_short *)ui, packlen); 631 outudp->check = in_cksum((uint16_t *)ui, packlen);
632 if (outudp->check == 0) 632 if (outudp->check == 0)
633 outudp->check = 0xffff; 633 outudp->check = 0xffff;
634 *outip = tip; 634 *outip = tip;
@@ -637,11 +637,11 @@ send_probe(int seq, int ttl, struct timeval *tp)
637#if ENABLE_FEATURE_TRACEROUTE_VERBOSE 637#if ENABLE_FEATURE_TRACEROUTE_VERBOSE
638 /* XXX undocumented debugging hack */ 638 /* XXX undocumented debugging hack */
639 if (verbose > 1) { 639 if (verbose > 1) {
640 const u_short *sp; 640 const uint16_t *sp;
641 int nshorts, i; 641 int nshorts, i;
642 642
643 sp = (u_short *)outip; 643 sp = (uint16_t *)outip;
644 nshorts = (u_int)packlen / sizeof(u_short); 644 nshorts = (u_int)packlen / sizeof(uint16_t);
645 i = 0; 645 i = 0;
646 printf("[ %d bytes", packlen); 646 printf("[ %d bytes", packlen);
647 while (--nshorts >= 0) { 647 while (--nshorts >= 0) {
@@ -906,7 +906,7 @@ traceroute_main(int argc, char *argv[])
906#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE 906#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
907 int lsrr = 0; 907 int lsrr = 0;
908#endif 908#endif
909 u_short off = 0; 909 uint16_t off = 0;
910 struct IFADDRLIST *al; 910 struct IFADDRLIST *al;
911 char *device = NULL; 911 char *device = NULL;
912 int max_ttl = 30; 912 int max_ttl = 30;
@@ -1137,17 +1137,15 @@ traceroute_main(int argc, char *argv[])
1137 outicmp = (struct icmp *)outp; 1137 outicmp = (struct icmp *)outp;
1138 outicmp->icmp_type = ICMP_ECHO; 1138 outicmp->icmp_type = ICMP_ECHO;
1139 outicmp->icmp_id = htons(ident); 1139 outicmp->icmp_id = htons(ident);
1140
1141 outdata = (struct outdata *)(outp + 8); /* XXX magic number */ 1140 outdata = (struct outdata *)(outp + 8); /* XXX magic number */
1142 } else 1141 } else
1143#endif 1142#endif
1144 { 1143 {
1145 outip->ip_p = IPPROTO_UDP; 1144 outip->ip_p = IPPROTO_UDP;
1146 1145
1147 outudp = (struct udphdr *)outp; 1146 outudp = (struct udphdr *)outp;
1148 outudp->source = htons(ident); 1147 outudp->source = htons(ident);
1149 outudp->len = 1148 outudp->len = htons((uint16_t)(packlen - (sizeof(*outip) + optlen)));
1150 htons((u_short)(packlen - (sizeof(*outip) + optlen)));
1151 outdata = (struct outdata *)(outudp + 1); 1149 outdata = (struct outdata *)(outudp + 1);
1152 } 1150 }
1153 1151
diff --git a/networking/udhcp/arpping.c b/networking/udhcp/arpping.c
index 9c8b9c562..f78fd3fd8 100644
--- a/networking/udhcp/arpping.c
+++ b/networking/udhcp/arpping.c
@@ -15,9 +15,9 @@
15 15
16struct arpMsg { 16struct arpMsg {
17 /* Ethernet header */ 17 /* Ethernet header */
18 u_char h_dest[6]; /* destination ether addr */ 18 uint8_t h_dest[6]; /* destination ether addr */
19 u_char h_source[6]; /* source ether addr */ 19 uint8_t h_source[6]; /* source ether addr */
20 u_short h_proto; /* packet type ID field */ 20 uint16_t h_proto; /* packet type ID field */
21 21
22 /* ARP packet */ 22 /* ARP packet */
23 uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */ 23 uint16_t htype; /* hardware type (must be ARPHRD_ETHER) */
diff --git a/networking/udhcp/dhcprelay.c b/networking/udhcp/dhcprelay.c
index 052739400..a3ea327c3 100644
--- a/networking/udhcp/dhcprelay.c
+++ b/networking/udhcp/dhcprelay.c
@@ -103,7 +103,7 @@ static void xid_del(u_int32_t xid)
103 */ 103 */
104static int get_dhcp_packet_type(struct dhcpMessage *p) 104static int get_dhcp_packet_type(struct dhcpMessage *p)
105{ 105{
106 u_char *op; 106 uint8_t *op;
107 107
108 /* it must be either a BOOTREQUEST or a BOOTREPLY */ 108 /* it must be either a BOOTREQUEST or a BOOTREPLY */
109 if (p->op != BOOTREQUEST && p->op != BOOTREPLY) 109 if (p->op != BOOTREQUEST && p->op != BOOTREPLY)
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 2af5a41b9..e4f7e5455 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -220,8 +220,8 @@ static int get_boot(enum action what);
220 } 220 }
221 221
222 222
223static int32_t get_start_sect(const struct partition *p); 223static unsigned get_start_sect(const struct partition *p);
224static int32_t get_nr_sects(const struct partition *p); 224static unsigned get_nr_sects(const struct partition *p);
225 225
226/* 226/*
227 * per partition table entry data 227 * per partition table entry data
@@ -338,7 +338,9 @@ read_hex(const struct systypes *sys)
338 continue; 338 continue;
339 } 339 }
340 v = bb_strtoul(line_ptr, NULL, 16); 340 v = bb_strtoul(line_ptr, NULL, 16);
341 if (errno || v > 0xff) continue; 341 if (v > 0xff)
342 /* Bad input also triggers this */
343 continue;
342 return v; 344 return v;
343 } 345 }
344} 346}
@@ -393,15 +395,15 @@ STATIC_OSF void xbsd_print_disklabel(int);
393#define SGI_XLV 0x0c 395#define SGI_XLV 0x0c
394#define SGI_XVM 0x0d 396#define SGI_XVM 0x0d
395#define SGI_ENTIRE_DISK SGI_VOLUME 397#define SGI_ENTIRE_DISK SGI_VOLUME
396#if defined(CONFIG_FEATURE_SGI_LABEL) || defined(CONFIG_FEATURE_SUN_LABEL) 398#if ENABLE_FEATURE_SGI_LABEL || ENABLE_FEATURE_SUN_LABEL
397static uint16_t 399static uint16_t
398__swap16(uint16_t x) 400fdisk_swap16(uint16_t x)
399{ 401{
400 return (x << 8) | (x >> 8); 402 return (x << 8) | (x >> 8);
401} 403}
402 404
403static uint32_t 405static uint32_t
404__swap32(uint32_t x) 406fdisk_swap32(uint32_t x)
405{ 407{
406 return (x << 24) | 408 return (x << 24) |
407 ((x & 0xFF00) << 8) | 409 ((x & 0xFF00) << 8) |
@@ -578,7 +580,7 @@ set_start_sect(struct partition *p, unsigned start_sect)
578} 580}
579#endif 581#endif
580 582
581static int32_t 583static unsigned
582get_start_sect(const struct partition *p) 584get_start_sect(const struct partition *p)
583{ 585{
584 return read4_little_endian(p->start4); 586 return read4_little_endian(p->start4);
@@ -586,13 +588,13 @@ get_start_sect(const struct partition *p)
586 588
587#if ENABLE_FEATURE_FDISK_WRITABLE 589#if ENABLE_FEATURE_FDISK_WRITABLE
588static void 590static void
589set_nr_sects(struct partition *p, int32_t nr_sects) 591set_nr_sects(struct partition *p, unsigned nr_sects)
590{ 592{
591 store4_little_endian(p->size4, nr_sects); 593 store4_little_endian(p->size4, nr_sects);
592} 594}
593#endif 595#endif
594 596
595static int32_t 597static unsigned
596get_nr_sects(const struct partition *p) 598get_nr_sects(const struct partition *p)
597{ 599{
598 return read4_little_endian(p->size4); 600 return read4_little_endian(p->size4);
@@ -1770,13 +1772,13 @@ change_sysid(void)
1770#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 1772#endif /* CONFIG_FEATURE_FDISK_WRITABLE */
1771 1773
1772 1774
1773/* check_consistency() and long2chs() added Sat Mar 6 12:28:16 1993, 1775/* check_consistency() and linear2chs() added Sat Mar 6 12:28:16 1993,
1774 * faith@cs.unc.edu, based on code fragments from pfdisk by Gordon W. Ross, 1776 * faith@cs.unc.edu, based on code fragments from pfdisk by Gordon W. Ross,
1775 * Jan. 1990 (version 1.2.1 by Gordon W. Ross Aug. 1990; Modified by S. 1777 * Jan. 1990 (version 1.2.1 by Gordon W. Ross Aug. 1990; Modified by S.
1776 * Lubkin Oct. 1991). */ 1778 * Lubkin Oct. 1991). */
1777 1779
1778static void 1780static void
1779long2chs(ulong ls, unsigned *c, unsigned *h, unsigned *s) 1781linear2chs(unsigned ls, unsigned *c, unsigned *h, unsigned *s)
1780{ 1782{
1781 int spc = heads * sectors; 1783 int spc = heads * sectors;
1782 1784
@@ -1808,10 +1810,10 @@ check_consistency(const struct partition *p, int partition)
1808 pes = p->end_sector & 0x3f; 1810 pes = p->end_sector & 0x3f;
1809 1811
1810/* compute logical beginning (c, h, s) */ 1812/* compute logical beginning (c, h, s) */
1811 long2chs(get_start_sect(p), &lbc, &lbh, &lbs); 1813 linear2chs(get_start_sect(p), &lbc, &lbh, &lbs);
1812 1814
1813/* compute logical ending (c, h, s) */ 1815/* compute logical ending (c, h, s) */
1814 long2chs(get_start_sect(p) + get_nr_sects(p) - 1, &lec, &leh, &les); 1816 linear2chs(get_start_sect(p) + get_nr_sects(p) - 1, &lec, &leh, &les);
1815 1817
1816/* Same physical / logical beginning? */ 1818/* Same physical / logical beginning? */
1817 if (cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) { 1819 if (cylinders <= 1024 && (pbc != lbc || pbh != lbh || pbs != lbs)) {
@@ -2479,46 +2481,40 @@ write_table(void)
2479static void 2481static void
2480reread_partition_table(int leave) 2482reread_partition_table(int leave)
2481{ 2483{
2482 int error = 0;
2483 int i; 2484 int i;
2484 2485
2485 printf(_("Calling ioctl() to re-read partition table.\n")); 2486 printf(_("Calling ioctl() to re-read partition table\n"));
2486 sync(); 2487 sync();
2487 sleep(2); 2488 sleep(2); /* Huh? */
2488 if ((i = ioctl(fd, BLKRRPART)) != 0) { 2489 i = ioctl(fd, BLKRRPART);
2489 error = errno; 2490#if 0
2490 } else { 2491 else {
2491 /* some kernel versions (1.2.x) seem to have trouble 2492 /* some kernel versions (1.2.x) seem to have trouble
2492 rereading the partition table, but if asked to do it 2493 rereading the partition table, but if asked to do it
2493 twice, the second time works. - biro@yggdrasil.com */ 2494 twice, the second time works. - biro@yggdrasil.com */
2494 sync(); 2495 sync();
2495 sleep(2); 2496 sleep(2);
2496 if ((i = ioctl(fd, BLKRRPART)) != 0) 2497 i = ioctl(fd, BLKRRPART);
2497 error = errno;
2498 } 2498 }
2499#endif
2499 2500
2500 if (i) { 2501 if (i) {
2501 printf(_("\nWARNING: Re-reading the partition table " 2502 bb_perror_msg("WARNING: rereading partition table "
2502 "failed with error %d: %s.\n" 2503 "failed, kernel still uses old table");
2503 "The kernel still uses the old table.\n"
2504 "The new table will be used "
2505 "at the next reboot.\n"),
2506 error, strerror(error));
2507 } 2504 }
2508 2505
2506#if 0
2509 if (dos_changed) 2507 if (dos_changed)
2510 printf( 2508 printf(
2511 _("\nWARNING: If you have created or modified any DOS 6.x\n" 2509 _("\nWARNING: If you have created or modified any DOS 6.x\n"
2512 "partitions, please see the fdisk manual page for additional\n" 2510 "partitions, please see the fdisk manual page for additional\n"
2513 "information.\n")); 2511 "information.\n"));
2512#endif
2514 2513
2515 if (leave) { 2514 if (leave) {
2516 close(fd); 2515 if (ENABLE_FEATURE_CLEAN_UP)
2517 2516 close(fd);
2518 printf(_("Syncing disks.\n")); 2517 exit(i != 0);
2519 sync();
2520 sleep(4); /* for sync() */
2521 exit(!!i);
2522 } 2518 }
2523} 2519}
2524#endif /* CONFIG_FEATURE_FDISK_WRITABLE */ 2520#endif /* CONFIG_FEATURE_FDISK_WRITABLE */
@@ -2544,7 +2540,6 @@ print_buffer(char *pbuffer)
2544 puts(""); 2540 puts("");
2545} 2541}
2546 2542
2547
2548static void 2543static void
2549print_raw(void) 2544print_raw(void)
2550{ 2545{
@@ -2728,7 +2723,8 @@ try(const char *device, int user_specified)
2728 if (!user_specified) 2723 if (!user_specified)
2729 if (is_ide_cdrom_or_tape(device)) 2724 if (is_ide_cdrom_or_tape(device))
2730 return; 2725 return;
2731 if ((fd = open(disk_device, type_open)) >= 0) { 2726 fd = open(disk_device, type_open);
2727 if (fd >= 0) {
2732 gb = get_boot(try_only); 2728 gb = get_boot(try_only);
2733 if (gb > 0) { /* I/O error */ 2729 if (gb > 0) { /* I/O error */
2734 close(fd); 2730 close(fd);
@@ -2861,7 +2857,7 @@ int fdisk_main(int argc, char **argv)
2861 type_open = O_RDONLY; 2857 type_open = O_RDONLY;
2862 if (argc > 0) { 2858 if (argc > 0) {
2863 int k; 2859 int k;
2864#if __GNUC__ 2860#if defined(__GNUC__)
2865 /* avoid gcc warning: 2861 /* avoid gcc warning:
2866 variable `k' might be clobbered by `longjmp' */ 2862 variable `k' might be clobbered by `longjmp' */
2867 (void)&k; 2863 (void)&k;
diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
index bff2371e4..3d654d392 100644
--- a/util-linux/fdisk_osf.c
+++ b/util-linux/fdisk_osf.c
@@ -253,7 +253,7 @@ static void xbsd_change_fstype(void);
253static int xbsd_get_part_index(int max); 253static int xbsd_get_part_index(int max);
254static int xbsd_check_new_partition(int *i); 254static int xbsd_check_new_partition(int *i);
255static void xbsd_list_types(void); 255static void xbsd_list_types(void);
256static u_short xbsd_dkcksum(struct xbsd_disklabel *lp); 256static uint16_t xbsd_dkcksum(struct xbsd_disklabel *lp);
257static int xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d); 257static int xbsd_initlabel(struct partition *p, struct xbsd_disklabel *d);
258static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d); 258static int xbsd_readlabel(struct partition *p, struct xbsd_disklabel *d);
259static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d); 259static int xbsd_writelabel(struct partition *p, struct xbsd_disklabel *d);
@@ -650,37 +650,38 @@ xbsd_edit_disklabel(void)
650 d = &xbsd_dlabel; 650 d = &xbsd_dlabel;
651 651
652#if defined (__alpha__) || defined (__ia64__) 652#if defined (__alpha__) || defined (__ia64__)
653 d->d_secsize = (u_long) edit_int((u_long) d->d_secsize ,_("bytes/sector")); 653 d->d_secsize = edit_int(d->d_secsize ,_("bytes/sector"));
654 d->d_nsectors = (u_long) edit_int((u_long) d->d_nsectors ,_("sectors/track")); 654 d->d_nsectors = edit_int(d->d_nsectors ,_("sectors/track"));
655 d->d_ntracks = (u_long) edit_int((u_long) d->d_ntracks ,_("tracks/cylinder")); 655 d->d_ntracks = edit_int(d->d_ntracks ,_("tracks/cylinder"));
656 d->d_ncylinders = (u_long) edit_int((u_long) d->d_ncylinders ,_("cylinders")); 656 d->d_ncylinders = edit_int(d->d_ncylinders ,_("cylinders"));
657#endif 657#endif
658 658
659 /* d->d_secpercyl can be != d->d_nsectors * d->d_ntracks */ 659 /* d->d_secpercyl can be != d->d_nsectors * d->d_ntracks */
660 while (1) { 660 while (1) {
661 d->d_secpercyl = (u_long) edit_int((u_long) d->d_nsectors * d->d_ntracks, 661 d->d_secpercyl = edit_int(d->d_nsectors * d->d_ntracks,
662 _("sectors/cylinder")); 662 _("sectors/cylinder"));
663 if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks) 663 if (d->d_secpercyl <= d->d_nsectors * d->d_ntracks)
664 break; 664 break;
665 665
666 printf(_("Must be <= sectors/track * tracks/cylinder (default).\n")); 666 printf(_("Must be <= sectors/track * tracks/cylinder (default).\n"));
667 } 667 }
668 d->d_rpm = (u_short) edit_int((u_short) d->d_rpm ,_("rpm")); 668 d->d_rpm = edit_int(d->d_rpm ,_("rpm"));
669 d->d_interleave = (u_short) edit_int((u_short) d->d_interleave,_("interleave")); 669 d->d_interleave = edit_int(d->d_interleave,_("interleave"));
670 d->d_trackskew = (u_short) edit_int((u_short) d->d_trackskew ,_("trackskew")); 670 d->d_trackskew = edit_int(d->d_trackskew ,_("trackskew"));
671 d->d_cylskew = (u_short) edit_int((u_short) d->d_cylskew ,_("cylinderskew")); 671 d->d_cylskew = edit_int(d->d_cylskew ,_("cylinderskew"));
672 d->d_headswitch = (u_long) edit_int((u_long) d->d_headswitch ,_("headswitch")); 672 d->d_headswitch = edit_int(d->d_headswitch,_("headswitch"));
673 d->d_trkseek = (u_long) edit_int((u_long) d->d_trkseek ,_("track-to-track seek")); 673 d->d_trkseek = edit_int(d->d_trkseek ,_("track-to-track seek"));
674 674
675 d->d_secperunit = d->d_secpercyl * d->d_ncylinders; 675 d->d_secperunit = d->d_secpercyl * d->d_ncylinders;
676} 676}
677 677
678static int 678static int
679xbsd_get_bootstrap (char *path, void *ptr, int size) 679xbsd_get_bootstrap(char *path, void *ptr, int size)
680{ 680{
681 int fdb; 681 int fdb;
682 682
683 if ((fdb = open (path, O_RDONLY)) < 0) { 683 fdb = open(path, O_RDONLY);
684 if (fdb < 0) {
684 perror(path); 685 perror(path);
685 return 0; 686 return 0;
686 } 687 }
@@ -736,7 +737,7 @@ xbsd_write_bootstrap(void)
736 737
737 snprintf(path, sizeof(path), "%s/boot%s", bootdir, dkbasename); 738 snprintf(path, sizeof(path), "%s/boot%s", bootdir, dkbasename);
738 if (!xbsd_get_bootstrap(path, &disklabelbuffer[xbsd_dlabel.d_secsize], 739 if (!xbsd_get_bootstrap(path, &disklabelbuffer[xbsd_dlabel.d_secsize],
739 (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize)) 740 (int) xbsd_dlabel.d_bbsize - xbsd_dlabel.d_secsize))
740 return; 741 return;
741 742
742 e = d + sizeof(struct xbsd_disklabel); 743 e = d + sizeof(struct xbsd_disklabel);
@@ -748,9 +749,9 @@ xbsd_write_bootstrap(void)
748 749
749 memmove(d, &dl, sizeof(struct xbsd_disklabel)); 750 memmove(d, &dl, sizeof(struct xbsd_disklabel));
750 751
751#if defined (__powerpc__) || defined (__hppa__) 752#if defined(__powerpc__) || defined(__hppa__)
752 sector = 0; 753 sector = 0;
753#elif defined (__alpha__) 754#elif defined(__alpha__)
754 sector = 0; 755 sector = 0;
755 alpha_bootblock_checksum(disklabelbuffer); 756 alpha_bootblock_checksum(disklabelbuffer);
756#else 757#else
@@ -762,11 +763,11 @@ xbsd_write_bootstrap(void)
762 if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE)) 763 if (BSD_BBSIZE != write(fd, disklabelbuffer, BSD_BBSIZE))
763 fdisk_fatal(unable_to_write); 764 fdisk_fatal(unable_to_write);
764 765
765#if defined (__alpha__) 766#if defined(__alpha__)
766 printf(_("Bootstrap installed on %s.\n"), disk_device); 767 printf(_("Bootstrap installed on %s.\n"), disk_device);
767#else 768#else
768 printf(_("Bootstrap installed on %s.\n"), 769 printf(_("Bootstrap installed on %s.\n"),
769 partname (disk_device, xbsd_part_index+1, 0)); 770 partname(disk_device, xbsd_part_index+1, 0));
770#endif 771#endif
771 772
772 sync_disks(); 773 sync_disks();
@@ -812,7 +813,7 @@ xbsd_check_new_partition(int *i)
812 } 813 }
813 } 814 }
814 815
815 *i = xbsd_get_part_index (BSD_MAXPARTITIONS); 816 *i = xbsd_get_part_index(BSD_MAXPARTITIONS);
816 817
817 if (*i >= xbsd_dlabel.d_npartitions) 818 if (*i >= xbsd_dlabel.d_npartitions)
818 xbsd_dlabel.d_npartitions = (*i) + 1; 819 xbsd_dlabel.d_npartitions = (*i) + 1;
@@ -831,14 +832,14 @@ xbsd_list_types(void)
831 list_types(xbsd_fstypes); 832 list_types(xbsd_fstypes);
832} 833}
833 834
834static u_short 835static uint16_t
835xbsd_dkcksum(struct xbsd_disklabel *lp) 836xbsd_dkcksum(struct xbsd_disklabel *lp)
836{ 837{
837 u_short *start, *end; 838 uint16_t *start, *end;
838 u_short sum = 0; 839 uint16_t sum = 0;
839 840
840 start = (u_short *) lp; 841 start = (uint16_t *) lp;
841 end = (u_short *) &lp->d_partitions[lp->d_npartitions]; 842 end = (uint16_t *) &lp->d_partitions[lp->d_npartitions];
842 while (start < end) 843 while (start < end)
843 sum ^= *start++; 844 sum ^= *start++;
844 return sum; 845 return sum;
diff --git a/util-linux/fdisk_sgi.c b/util-linux/fdisk_sgi.c
index 548a70bdc..7687103c9 100644
--- a/util-linux/fdisk_sgi.c
+++ b/util-linux/fdisk_sgi.c
@@ -84,8 +84,8 @@ typedef struct {
84#define SGI_INFO_MAGIC 0x00072959 84#define SGI_INFO_MAGIC 0x00072959
85#define SGI_INFO_MAGIC_SWAPPED 0x59290700 85#define SGI_INFO_MAGIC_SWAPPED 0x59290700
86 86
87#define SGI_SSWAP16(x) (sgi_other_endian ? __swap16(x) : (uint16_t)(x)) 87#define SGI_SSWAP16(x) (sgi_other_endian ? fdisk_swap16(x) : (uint16_t)(x))
88#define SGI_SSWAP32(x) (sgi_other_endian ? __swap32(x) : (uint32_t)(x)) 88#define SGI_SSWAP32(x) (sgi_other_endian ? fdisk_swap32(x) : (uint32_t)(x))
89 89
90#define sgilabel ((sgi_partition *)MBRbuffer) 90#define sgilabel ((sgi_partition *)MBRbuffer)
91#define sgiparam (sgilabel->devparam) 91#define sgiparam (sgilabel->devparam)
diff --git a/util-linux/fdisk_sun.c b/util-linux/fdisk_sun.c
index 1e8f2e525..af85fb2c4 100644
--- a/util-linux/fdisk_sun.c
+++ b/util-linux/fdisk_sun.c
@@ -2,8 +2,8 @@
2 2
3#define SUN_LABEL_MAGIC 0xDABE 3#define SUN_LABEL_MAGIC 0xDABE
4#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA 4#define SUN_LABEL_MAGIC_SWAPPED 0xBEDA
5#define SUN_SSWAP16(x) (sun_other_endian ? __swap16(x) : (uint16_t)(x)) 5#define SUN_SSWAP16(x) (sun_other_endian ? fdisk_swap16(x) : (uint16_t)(x))
6#define SUN_SSWAP32(x) (sun_other_endian ? __swap32(x) : (uint32_t)(x)) 6#define SUN_SSWAP32(x) (sun_other_endian ? fdisk_swap32(x) : (uint32_t)(x))
7 7
8/* Copied from linux/major.h */ 8/* Copied from linux/major.h */
9#define FLOPPY_MAJOR 2 9#define FLOPPY_MAJOR 2
diff --git a/util-linux/mount.c b/util-linux/mount.c
index 35665a2b5..661e26f19 100644
--- a/util-linux/mount.c
+++ b/util-linux/mount.c
@@ -439,7 +439,7 @@ struct ppathcnf {
439 short pc_name_max; 439 short pc_name_max;
440 short pc_path_max; 440 short pc_path_max;
441 short pc_pipe_buf; 441 short pc_pipe_buf;
442 u_char pc_vdisable; 442 uint8_t pc_vdisable;
443 char pc_xxx; 443 char pc_xxx;
444 short pc_mask[2]; 444 short pc_mask[2];
445}; 445};