Fixed world breakage on systems where ntohl() doesn't return u_long

(e.g., on alphas, or even on i386's with a POSIX-200x-conformant
ntohl() (ntohl() returns uint32_t which is u_int on i386's)).

Fixed related bugs and bogons while I'm here:
- ntohl() was "fixed" for printing in 1 place by casting to
  "(unsigned int )".  This breaks the value on systems where u_int
  is smaller than uint32_t, and has 2 style bugs.
- spell u_int consistently (never use "unsigned").
- break K&R support some more (don't cast malloc()'s arg to a wrong
  type...).
This commit is contained in:
Bruce Evans 2001-06-13 11:56:00 +00:00
parent 5333a1958c
commit 87c5c2d426
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=78163

View File

@ -108,10 +108,6 @@ static const char rcsid[] =
#define arp_tpa arp_xtpa
#endif
#ifndef __GNUC__
#define inline
#endif
/*
* The structure for each interface.
*/
@ -134,15 +130,6 @@ int verbose; /* verbose messages */
int s; /* inet datagram socket */
const char *tftp_dir = TFTP_DIR; /* tftp directory */
#ifndef __P
#define __P(protos) ()
#endif
#if BSD < 199200
extern char *malloc();
extern void exit();
#endif
int sflag; /* ignore /tftpboot */
static u_char zero[6];
@ -338,7 +325,7 @@ init_one(struct ifreq *ifrp, char *target)
void
init(char *target)
{
unsigned n;
u_int n;
struct ifreq *ifrp, *ifend;
struct if_info *ii, *nii, *lii;
struct ifconf ifc;
@ -393,7 +380,7 @@ init(char *target)
for (ii = iflist; ii != NULL; ii = ii->ii_next)
syslog(LOG_DEBUG, "%s %s 0x%08lx %s",
ii->ii_ifname, intoa(ntohl(ii->ii_ipaddr)),
ntohl(ii->ii_netmask), eatoa(ii->ii_eaddr));
(u_long)ntohl(ii->ii_netmask), eatoa(ii->ii_eaddr));
}
void
@ -551,7 +538,7 @@ rarp_loop(void)
syslog(LOG_ERR, "BIOCGBLEN: %m");
exit(1);
}
buf = (u_char *)malloc((unsigned)bufsize);
buf = malloc(bufsize);
if (buf == NULL) {
syslog(LOG_ERR, "malloc: %m");
exit(1);
@ -637,7 +624,7 @@ rarp_bootable(u_long addr)
char ipname[9];
static DIR *dd = NULL;
(void)sprintf(ipname, "%08X", (unsigned int )ntohl(addr));
(void)sprintf(ipname, "%08lX", (u_long)ntohl(addr));
/*
* If directory is already open, rewind it. Otherwise, open it.