From 033aecd1e883e84ca5d38037e7fcefa11b6e6c61 Mon Sep 17 00:00:00 2001 From: Nathan Neulinger Date: Mon, 4 Jun 2001 22:08:19 +0000 Subject: [PATCH] viced-dotted-quad-logging-without-malloc-20010601 based on suggestion from rees@umich.edu ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== update for solaris cc joy --- src/util/afsutil.h | 2 +- src/util/hostparse.c | 6 +---- src/viced/host.c | 52 ++++++++++++++++++++++---------------------- src/viced/viced.c | 13 +++++------ 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/src/util/afsutil.h b/src/util/afsutil.h index 35fb5c4c3..2363ecf8f 100644 --- a/src/util/afsutil.h +++ b/src/util/afsutil.h @@ -58,7 +58,7 @@ extern char *vctime(const time_t *atime); /* Convert a 4 byte integer to a text string. */ extern char* afs_inet_ntoa(afs_uint32 addr); -extern char* afs_inet_ntoa_r(afs_uint32 addr); +extern char* afs_inet_ntoa_r(afs_uint32 addr, char *buf); /* copy strings, converting case along the way. */ extern char *lcstring(char *d, char *s, int n); diff --git a/src/util/hostparse.c b/src/util/hostparse.c index a49f9b199..b9b8e2fc4 100644 --- a/src/util/hostparse.c +++ b/src/util/hostparse.c @@ -232,15 +232,11 @@ char* afs_inet_ntoa(afs_uint32 addr) } /* same as above, but to a non-static buffer, must be freed by called */ -char* afs_inet_ntoa_r(afs_uint32 addr) +char* afs_inet_ntoa_r(afs_uint32 addr, char *buf) { - char *buf; int temp; temp = ntohl(addr); - buf = (char *) malloc(16); /* length of xxx.xxx.xxx.xxx\0 */ - buf[15] = 0; - sprintf(buf, "%d.%d.%d.%d", (temp >> 24 ) & 0xff, (temp >> 16 ) & 0xff, diff --git a/src/viced/host.c b/src/viced/host.c index bba7bbc33..2d2233b3e 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -986,11 +986,11 @@ retry: goto retry; } } else { - char *hoststr = afs_inet_ntoa_r(host->host); - ViceLog(0,("CB: WhoAreYou failed for %s:%d, error %d\n", - hoststr, ntohs(host->port), code)); - host->hostFlags |= VENUSDOWN; - free(hoststr); + char hoststr[16]; + afs_inet_ntoa_r(host->host, hoststr); + ViceLog(0,("CB: WhoAreYou failed for %s:%d, error %d\n", + hoststr, ntohs(host->port), code)); + host->hostFlags |= VENUSDOWN; } host->hostFlags |= ALTADDR; h_Unlock_r(host); @@ -1087,11 +1087,11 @@ retry: } } if (code) { - char *hoststr = afs_inet_ntoa_r(host->host); - ViceLog(0,("CB: RCallBackConnectBack failed for %s:%d\n", - hoststr, ntohs(host->port))); - host->hostFlags |= VENUSDOWN; - free(hoststr); + char hoststr[16]; + afs_inet_ntoa_r(host->host, hoststr); + ViceLog(0,("CB: RCallBackConnectBack failed for %s:%d\n", + hoststr, ntohs(host->port))); + host->hostFlags |= VENUSDOWN; } else host->hostFlags |= RESETDONE; @@ -1909,13 +1909,13 @@ int CheckHost(host, held) host->hostFlags |= ALTADDR; /* alternate addresses valid */ if ( code ) { - char *hoststr = afs_inet_ntoa_r(host->host); - ViceLog(0, - ("CB: RCallBackConnectBack (host.c) failed for host %s:%d\n", - hoststr, ntohs(host->port))); - host->hostFlags |= VENUSDOWN; - free(hoststr); - } + char hoststr[16]; + afs_inet_ntoa_r(host->host, hoststr); + ViceLog(0, + ("CB: RCallBackConnectBack (host.c) failed for host %s:%d\n", + hoststr, ntohs(host->port))); + host->hostFlags |= VENUSDOWN; + } /* Note: it's safe to delete hosts even if they have call * back state, because break delayed callbacks (called when a * message is received from the workstation) will always send a @@ -1933,12 +1933,12 @@ int CheckHost(host, held) H_LOCK if(code) { if ( MultiProbeAlternateAddress_r(host) ) { - char *hoststr = afs_inet_ntoa_r(host->host); - ViceLog(0, + char hoststr[16]; + afs_inet_ntoa_r(host->host, hoststr); + ViceLog(0, ("ProbeUuid failed for host %s:%d\n", hoststr, ntohs(host->port))); - host->hostFlags |= VENUSDOWN; - free(hoststr); + host->hostFlags |= VENUSDOWN; } } } else { @@ -1946,11 +1946,11 @@ int CheckHost(host, held) code = RXAFSCB_Probe(host->callback_rxcon); H_LOCK if (code) { - char *hoststr = afs_inet_ntoa_r(host->host); - ViceLog(0, ("ProbeUuid failed for host %s:%d\n", - hoststr, ntohs(host->port))); - host->hostFlags |= VENUSDOWN; - free(hoststr); + char hoststr[16]; + afs_inet_ntoa_r(host->host, hoststr); + ViceLog(0, ("ProbeUuid failed for host %s:%d\n", + hoststr, ntohs(host->port))); + host->hostFlags |= VENUSDOWN; } } } diff --git a/src/viced/viced.c b/src/viced/viced.c index 221f51676..b24d1a871 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -599,13 +599,12 @@ main(argc, argv) ViceLog(0, ("Can't find address for FileServer '%s'\n", FS_HostName)); } else { - char *hoststr; - bcopy(he->h_addr, &FS_HostAddr_NBO, 4); - hoststr = afs_inet_ntoa_r(FS_HostAddr_NBO); - FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO); - ViceLog(0,("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n", - FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO)); - free(hoststr); + char hoststr[16]; + bcopy(he->h_addr, &FS_HostAddr_NBO, 4); + afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr); + FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO); + ViceLog(0,("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n", + FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO)); } /* Install handler to catch the shutdown signal */ -- 2.39.5