summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGravatar John Kohl <jtkohl@mit.edu>1988-06-23 06:28:56 +0000
committerGravatar John Kohl <jtkohl@mit.edu>1988-06-23 06:28:56 +0000
commit76a56cff9767ccf9d1e579e808247ef3ad1f5282 (patch)
tree15a05e875c5e43bf2a739d1f9b15ed3b71c3bb77 /lib
parent0a9847711808fbd565b2d1db75525de6e606063f (diff)
lint fixes
Diffstat (limited to 'lib')
-rw-r--r--lib/ZCkIfNot.c4
-rw-r--r--lib/ZFmtList.c2
-rw-r--r--lib/ZFmtNotice.c2
-rw-r--r--lib/ZFmtRaw.c2
-rw-r--r--lib/ZFmtRawLst.c2
-rw-r--r--lib/ZGetWGPort.c15
-rw-r--r--lib/ZIfNotice.c4
-rw-r--r--lib/ZInit.c4
-rw-r--r--lib/ZLocateU.c3
-rw-r--r--lib/ZLocations.c6
-rw-r--r--lib/ZMakeAscii.c4
-rw-r--r--lib/ZOpenPort.c4
-rw-r--r--lib/ZParseNot.c18
-rw-r--r--lib/ZPeekIfNot.c4
-rw-r--r--lib/ZPeekPkt.c4
-rw-r--r--lib/ZReadAscii.c9
-rw-r--r--lib/ZRecvNot.c4
-rw-r--r--lib/ZRecvPkt.c2
-rw-r--r--lib/ZRetSubs.c10
-rw-r--r--lib/ZSendPkt.c3
-rw-r--r--lib/ZVariables.c36
-rw-r--r--lib/Zinternal.c51
22 files changed, 104 insertions, 89 deletions
diff --git a/lib/ZCkIfNot.c b/lib/ZCkIfNot.c
index 96eaddd..a7b3e34 100644
--- a/lib/ZCkIfNot.c
+++ b/lib/ZCkIfNot.c
@@ -34,14 +34,14 @@ Code_t ZCheckIfNotice(notice, from, predicate, args)
if ((retval = Z_ReadEnqueue()) != ZERR_NONE)
return (retval);
- qptr = (struct _Z_InputQ *)Z_GetFirstComplete();
+ qptr = Z_GetFirstComplete();
while (qptr) {
if ((retval = ZParseNotice(qptr->packet, qptr->packet_len,
&tmpnotice)) != ZERR_NONE)
return (retval);
if ((predicate)(&tmpnotice, args)) {
- if (!(buffer = malloc(qptr->packet_len)))
+ if (!(buffer = malloc((unsigned) qptr->packet_len)))
return (ENOMEM);
bcopy(qptr->packet, buffer, qptr->packet_len);
if (from)
diff --git a/lib/ZFmtList.c b/lib/ZFmtList.c
index b2a733b..6711f75 100644
--- a/lib/ZFmtList.c
+++ b/lib/ZFmtList.c
@@ -44,7 +44,7 @@ Code_t ZFormatNoticeList(notice, list, nitems, buffer, ret_len,
*ret_len = hdrlen+size;
- if (!(*buffer = malloc(*ret_len)))
+ if (!(*buffer = malloc((unsigned)*ret_len)))
return (ENOMEM);
bcopy(header, *buffer, hdrlen);
diff --git a/lib/ZFmtNotice.c b/lib/ZFmtNotice.c
index 8aaab6a..c6292fe 100644
--- a/lib/ZFmtNotice.c
+++ b/lib/ZFmtNotice.c
@@ -36,7 +36,7 @@ Code_t ZFormatNotice(notice, buffer, ret_len, cert_routine)
*ret_len = hdrlen+notice->z_message_len;
- if (!(*buffer = (char *)malloc(*ret_len)))
+ if (!(*buffer = (char *)malloc((unsigned)*ret_len)))
return (ENOMEM);
bcopy(header, *buffer, hdrlen);
diff --git a/lib/ZFmtRaw.c b/lib/ZFmtRaw.c
index bcd7bf7..cebf7c2 100644
--- a/lib/ZFmtRaw.c
+++ b/lib/ZFmtRaw.c
@@ -35,7 +35,7 @@ Code_t ZFormatRawNotice(notice, buffer, ret_len)
*ret_len = hdrlen+notice->z_message_len;
- if (!(*buffer = malloc(*ret_len)))
+ if (!(*buffer = malloc((unsigned) *ret_len)))
return (ENOMEM);
bcopy(header, *buffer, hdrlen);
diff --git a/lib/ZFmtRawLst.c b/lib/ZFmtRawLst.c
index deafbe3..9f70708 100644
--- a/lib/ZFmtRawLst.c
+++ b/lib/ZFmtRawLst.c
@@ -42,7 +42,7 @@ Code_t ZFormatRawNoticeList(notice, list, nitems, buffer, ret_len)
*ret_len = hdrlen+size;
- if (!(*buffer = malloc(*ret_len)))
+ if (!(*buffer = malloc((unsigned) *ret_len)))
return (ENOMEM);
bcopy(header, *buffer, hdrlen);
diff --git a/lib/ZGetWGPort.c b/lib/ZGetWGPort.c
index 79cb961..c2d28e8 100644
--- a/lib/ZGetWGPort.c
+++ b/lib/ZGetWGPort.c
@@ -20,21 +20,28 @@ static char rcsid_ZGetWGPort_c[] = "$Header$";
#include <zephyr/zephyr_internal.h>
+extern char *getenv();
+extern uid_t getuid();
+
int ZGetWGPort()
{
char *envptr, name[128];
FILE *fp;
int wgport;
- envptr = (char *)getenv("WGFILE");
+ envptr = getenv("WGFILE");
if (!envptr) {
- sprintf(name, "/tmp/wg.%d", getuid());
+ (void) sprintf(name, "/tmp/wg.%d", getuid());
envptr = name;
}
if (!(fp = fopen(envptr, "r")))
return (-1);
- fscanf(fp, "%d", &wgport);
- fclose(fp);
+
+ /* if fscanf fails, return -1 via wgport */
+ if (fscanf(fp, "%d", &wgport) != 1)
+ wgport = -1;
+
+ (void) fclose(fp);
return (wgport);
}
diff --git a/lib/ZIfNotice.c b/lib/ZIfNotice.c
index 7b4af2a..d37eb8e 100644
--- a/lib/ZIfNotice.c
+++ b/lib/ZIfNotice.c
@@ -34,7 +34,7 @@ Code_t ZIfNotice(notice, from, predicate, args)
if ((retval = Z_WaitForComplete()) != ZERR_NONE)
return (retval);
- qptr = (struct _Z_InputQ *) Z_GetFirstComplete();
+ qptr = Z_GetFirstComplete();
for (;;) {
while (qptr) {
@@ -42,7 +42,7 @@ Code_t ZIfNotice(notice, from, predicate, args)
&tmpnotice)) != ZERR_NONE)
return (retval);
if ((predicate)(&tmpnotice, args)) {
- if (!(buffer = malloc(qptr->packet_len)))
+ if (!(buffer = malloc((unsigned) qptr->packet_len)))
return (ENOMEM);
bcopy(qptr->packet, buffer, qptr->packet_len);
if (from)
diff --git a/lib/ZInit.c b/lib/ZInit.c
index f4900eb..d09e18f 100644
--- a/lib/ZInit.c
+++ b/lib/ZInit.c
@@ -66,9 +66,9 @@ Code_t ZInitialize()
if (gethostname(hostname, MAXHOSTNAMELEN))
return (errno);
if (hent = gethostbyname(hostname))
- strcpy(__Zephyr_realm, hent->h_name);
+ (void) strcpy(__Zephyr_realm, hent->h_name);
else
- strcpy(__Zephyr_realm, hostname);
+ (void) strcpy(__Zephyr_realm, hostname);
#endif
/* Get the sender so we can cache it */
diff --git a/lib/ZLocateU.c b/lib/ZLocateU.c
index 2e8b18f..6a2d0c2 100644
--- a/lib/ZLocateU.c
+++ b/lib/ZLocateU.c
@@ -54,7 +54,8 @@ Code_t ZLocateUser(user, nlocs)
nrecv = ack = 0;
while (!nrecv || !ack) {
- if ((retval = ZIfNotice(&retnotice, NULL, ZCompareMultiUIDPred,
+ if ((retval = ZIfNotice(&retnotice, (struct sockaddr_in *) 0,
+ ZCompareMultiUIDPred,
(char *)&notice.z_multiuid)) != ZERR_NONE)
return (retval);
diff --git a/lib/ZLocations.c b/lib/ZLocations.c
index ebb5081..40ebcf9 100644
--- a/lib/ZLocations.c
+++ b/lib/ZLocations.c
@@ -26,7 +26,7 @@ static char rcsid_ZLocations_c[] = "$Header$";
#include <sys/param.h>
#include <netdb.h>
-uid_t getuid();
+extern char *getenv();
Code_t ZSetLocation(exposure)
char *exposure;
@@ -86,8 +86,8 @@ Z_SendLocation(class, opcode, auth, format)
bptr[1] = ctime(&ourtime);
bptr[1][strlen(bptr[1])-1] = '\0';
- if ((display = (char *)getenv("DISPLAY")) && *display) {
- strcpy(mytty, display);
+ if ((display = getenv("DISPLAY")) && *display) {
+ (void) strcpy(mytty, display);
bptr[2] = mytty;
}
else {
diff --git a/lib/ZMakeAscii.c b/lib/ZMakeAscii.c
index 58d6185..b6c4a12 100644
--- a/lib/ZMakeAscii.c
+++ b/lib/ZMakeAscii.c
@@ -42,8 +42,8 @@ Code_t ZMakeAscii(ptr, len, field, num)
}
if (len < 3)
return (ZERR_FIELDLEN);
- *ptr++ = cnvt_itox(field[i] >> 4);
- *ptr++ = cnvt_itox(field[i] & 15);
+ *ptr++ = cnvt_itox((int) (field[i] >> 4));
+ *ptr++ = cnvt_itox((int) (field[i] & 0xf));
len -= 2;
}
diff --git a/lib/ZOpenPort.c b/lib/ZOpenPort.c
index 54e0ae8..5d8056a 100644
--- a/lib/ZOpenPort.c
+++ b/lib/ZOpenPort.c
@@ -43,7 +43,7 @@ Code_t ZOpenPort(port)
bindin.sin_addr.s_addr = INADDR_ANY;
- if (bind(__Zephyr_fd, &bindin, sizeof(bindin)) < 0) {
+ if (bind(__Zephyr_fd, (struct sockaddr *)&bindin, sizeof(bindin)) < 0) {
if (errno == EADDRINUSE && port && *port)
return (ZERR_PORTINUSE);
else
@@ -52,7 +52,7 @@ Code_t ZOpenPort(port)
if (!bindin.sin_port) {
len = sizeof(bindin);
- if (getsockname(__Zephyr_fd, &bindin, &len))
+ if (getsockname(__Zephyr_fd, (struct sockaddr *)&bindin, &len))
return (errno);
}
diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c
index ee23152..4fc9cf1 100644
--- a/lib/ZParseNot.c
+++ b/lib/ZParseNot.c
@@ -29,7 +29,7 @@ Code_t ZParseNotice(buffer, len, notice)
int maj, numfields, i;
unsigned int temp[3];
- bzero(notice, sizeof(ZNotice_t));
+ bzero((char *)notice, sizeof(ZNotice_t));
ptr = buffer;
end = buffer+len;
@@ -48,7 +48,7 @@ Code_t ZParseNotice(buffer, len, notice)
if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
sizeof(int)) == ZERR_BADFIELD)
return (ZERR_BADPKT);
- numfields = ntohl(*temp);
+ numfields = ntohl((u_long) *temp);
ptr += strlen(ptr)+1;
/*XXX 3 */
@@ -60,7 +60,7 @@ Code_t ZParseNotice(buffer, len, notice)
if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
sizeof(int)) == ZERR_BADFIELD)
return (ZERR_BADPKT);
- notice->z_kind = (ZNotice_Kind_t)ntohl(*temp);
+ notice->z_kind = (ZNotice_Kind_t)ntohl((u_long) *temp);
numfields--;
ptr += strlen(ptr)+1;
}
@@ -72,8 +72,8 @@ Code_t ZParseNotice(buffer, len, notice)
sizeof(ZUnique_Id_t)) == ZERR_BADFIELD)
return (ZERR_BADPKT);
bcopy((char *)temp, (char *)&notice->z_uid, sizeof(ZUnique_Id_t));
- notice->z_time.tv_sec = ntohl(notice->z_uid.tv.tv_sec);
- notice->z_time.tv_usec = ntohl(notice->z_uid.tv.tv_usec);
+ notice->z_time.tv_sec = ntohl((u_long) notice->z_uid.tv.tv_sec);
+ notice->z_time.tv_usec = ntohl((u_long) notice->z_uid.tv.tv_usec);
numfields--;
ptr += strlen(ptr)+1;
}
@@ -107,7 +107,7 @@ Code_t ZParseNotice(buffer, len, notice)
if (ZReadAscii(ptr, end-ptr, (unsigned char *)temp,
sizeof(int)) == ZERR_BADFIELD)
return (ZERR_BADPKT);
- notice->z_authent_len = ntohl(*temp);
+ notice->z_authent_len = ntohl((u_long) *temp);
numfields--;
ptr += strlen(ptr)+1;
}
@@ -175,7 +175,7 @@ Code_t ZParseNotice(buffer, len, notice)
sizeof(ZChecksum_t))
== ZERR_BADFIELD)
return (ZERR_BADPKT);
- notice->z_checksum = ntohl(*temp);
+ notice->z_checksum = ntohl((u_long) *temp);
numfields--;
ptr += strlen(ptr)+1;
@@ -192,8 +192,8 @@ Code_t ZParseNotice(buffer, len, notice)
sizeof(ZUnique_Id_t)) == ZERR_BADFIELD)
return (ZERR_BADPKT);
bcopy((char *)temp, (char *)&notice->z_multiuid, sizeof(ZUnique_Id_t));
- notice->z_time.tv_sec = ntohl(notice->z_multiuid.tv.tv_sec);
- notice->z_time.tv_usec = ntohl(notice->z_multiuid.tv.tv_usec);
+ notice->z_time.tv_sec = ntohl((u_long) notice->z_multiuid.tv.tv_sec);
+ notice->z_time.tv_usec = ntohl((u_long) notice->z_multiuid.tv.tv_usec);
numfields--;
ptr += strlen(ptr)+1;
}
diff --git a/lib/ZPeekIfNot.c b/lib/ZPeekIfNot.c
index b26f8c5..253639a 100644
--- a/lib/ZPeekIfNot.c
+++ b/lib/ZPeekIfNot.c
@@ -34,7 +34,7 @@ Code_t ZPeekIfNotice(notice, from, predicate, args)
if ((retval = Z_WaitForComplete()) != ZERR_NONE)
return (retval);
- qptr = (struct _Z_InputQ *) Z_GetFirstComplete();
+ qptr = Z_GetFirstComplete();
for (;;) {
while (qptr) {
@@ -42,7 +42,7 @@ Code_t ZPeekIfNotice(notice, from, predicate, args)
&tmpnotice)) != ZERR_NONE)
return (retval);
if ((predicate)(&tmpnotice, args)) {
- if (!(buffer = malloc(qptr->packet_len)))
+ if (!(buffer = malloc((unsigned) qptr->packet_len)))
return (ENOMEM);
bcopy(qptr->packet, buffer, qptr->packet_len);
if (from)
diff --git a/lib/ZPeekPkt.c b/lib/ZPeekPkt.c
index 2919298..7a806cb 100644
--- a/lib/ZPeekPkt.c
+++ b/lib/ZPeekPkt.c
@@ -31,11 +31,11 @@ Code_t ZPeekPacket(buffer, ret_len, from)
if ((retval = Z_WaitForComplete()) != ZERR_NONE)
return (retval);
- nextq = (struct _Z_InputQ *)Z_GetFirstComplete();
+ nextq =Z_GetFirstComplete();
*ret_len = nextq->packet_len;
- if (!(*buffer = malloc(*ret_len)))
+ if (!(*buffer = malloc((unsigned) *ret_len)))
return (ENOMEM);
bcopy(nextq->packet, *buffer, *ret_len);
diff --git a/lib/ZReadAscii.c b/lib/ZReadAscii.c
index 79dc3f5..b5ead0e 100644
--- a/lib/ZReadAscii.c
+++ b/lib/ZReadAscii.c
@@ -28,6 +28,7 @@ int ZReadAscii(ptr, len, field, num)
{
int i;
unsigned int hexbyte;
+ register char c1, c2;
for (i=0;i<num;i++) {
if (*ptr == ' ') {
@@ -41,9 +42,11 @@ int ZReadAscii(ptr, len, field, num)
if (len < 0)
return (ZERR_BADFIELD);
}
- hexbyte = (cnvt_xtoi(ptr[0]) << 4) | cnvt_xtoi(ptr[1]);
- if (hexbyte < 0)
- return (ZERR_BADFIELD);
+ c1 = cnvt_xtoi(ptr[0]);
+ c2 = cnvt_xtoi(ptr[1]);
+ if (c1 < 0 || c2 < 0)
+ return(ZERR_BADFIELD);
+ hexbyte = (c1 << 4) | c2;
field[i] = hexbyte;
ptr += 2;
len -= 2;
diff --git a/lib/ZRecvNot.c b/lib/ZRecvNot.c
index a08f886..857fc77 100644
--- a/lib/ZRecvNot.c
+++ b/lib/ZRecvNot.c
@@ -32,11 +32,11 @@ Code_t ZReceiveNotice(notice, from)
if ((retval = Z_WaitForComplete()) != ZERR_NONE)
return (retval);
- nextq = (struct _Z_InputQ *) Z_GetFirstComplete();
+ nextq = Z_GetFirstComplete();
len = nextq->packet_len;
- if (!(buffer = malloc(len)))
+ if (!(buffer = malloc((unsigned) len)))
return (ENOMEM);
if (from)
diff --git a/lib/ZRecvPkt.c b/lib/ZRecvPkt.c
index 03bf070..964854d 100644
--- a/lib/ZRecvPkt.c
+++ b/lib/ZRecvPkt.c
@@ -31,7 +31,7 @@ Code_t ZReceivePacket(buffer, ret_len, from)
if ((retval = Z_WaitForComplete()) != ZERR_NONE)
return (retval);
- nextq = (struct _Z_InputQ *) Z_GetFirstComplete();
+ nextq = Z_GetFirstComplete();
*ret_len = nextq->packet_len;
if (*ret_len > Z_MAXPKTLEN)
diff --git a/lib/ZRetSubs.c b/lib/ZRetSubs.c
index 8858dbd..7ba0553 100644
--- a/lib/ZRetSubs.c
+++ b/lib/ZRetSubs.c
@@ -59,10 +59,8 @@ static Code_t Z_RetSubs(notice, nsubs)
int *nsubs;
{
int i,retval,nrecv,gimmeack;
- ZNotice_t notice,retnotice;
- ZPacket_t buffer;
+ ZNotice_t retnotice;
char *ptr,*end,*ptr2;
- char asciiport[50];
retval = ZFlushSubscriptions();
@@ -82,7 +80,7 @@ static Code_t Z_RetSubs(notice, nsubs)
notice->z_default_format = "";
notice->z_num_other_fields = 0;
- if ((retval = ZSendNotice(&notice,ZAUTH)) != ZERR_NONE)
+ if ((retval = ZSendNotice(notice,ZAUTH)) != ZERR_NONE)
return (retval);
nrecv = 0;
@@ -90,7 +88,7 @@ static Code_t Z_RetSubs(notice, nsubs)
__subscriptions_list = (ZSubscription_t *) 0;
while (!nrecv || !gimmeack) {
- if ((retval = ZIfNotice(&retnotice,NULL,
+ if ((retval = ZIfNotice(&retnotice, (struct sockaddr_in *) 0,
ZCompareMultiUIDPred,
(char *)&notice->z_multiuid))
!= ZERR_NONE)
@@ -102,7 +100,7 @@ static Code_t Z_RetSubs(notice, nsubs)
}
if (retnotice.z_kind == SERVACK &&
- !strcmp(retnotice.z_opcode,notice->z_opcode))) {
+ !strcmp(retnotice.z_opcode,notice->z_opcode)) {
gimmeack = 1;
continue;
}
diff --git a/lib/ZSendPkt.c b/lib/ZSendPkt.c
index c2b4bde..c7449b2 100644
--- a/lib/ZSendPkt.c
+++ b/lib/ZSendPkt.c
@@ -46,7 +46,8 @@ Code_t ZSendPacket(packet, len, waitforack)
dest = ZGetDestAddr();
- if (sendto(ZGetFD(), packet, len, 0, &dest, sizeof(dest)) < 0)
+ if (sendto(ZGetFD(), packet, len, 0, (struct sockaddr *)&dest,
+ sizeof(dest)) < 0)
return (errno);
if (!waitforack)
diff --git a/lib/ZVariables.c b/lib/ZVariables.c
index 77e8b21..67869c2 100644
--- a/lib/ZVariables.c
+++ b/lib/ZVariables.c
@@ -25,6 +25,8 @@ static char rcsid_ZVariables_c[] = "$Header$";
#include <pwd.h>
#define _toupper(c) (islower(c)?toupper(c):c)
+extern char *getenv();
+extern uid_t getuid();
char *ZGetVariable(var)
char *var;
@@ -54,8 +56,8 @@ Code_t ZSetVariable(var, value)
if (get_localvarfile(varfile))
return (ZERR_INTERNAL);
- strcpy(varfilebackup, varfile);
- strcat(varfilebackup, ".backup");
+ (void) strcpy(varfilebackup, varfile);
+ (void) strcat(varfilebackup, ".backup");
if (!(fpout = fopen(varfilebackup, "w")))
return (errno);
@@ -70,11 +72,12 @@ Code_t ZSetVariable(var, value)
else
fprintf(fpout, "%s\n", varbfr);
}
- fclose(fpin);
+ (void) fclose(fpin); /* don't care about errs on input */
}
if (!written)
fprintf(fpout, "%s = %s\n", var, value);
- fclose(fpout);
+ if (fclose(fpout) == EOF)
+ return(EIO); /* can't rely on errno */
if (rename(varfilebackup, varfile))
return (errno);
return (ZERR_NONE);
@@ -89,8 +92,8 @@ Code_t ZUnsetVariable(var)
if (get_localvarfile(varfile))
return (ZERR_INTERNAL);
- strcpy(varfilebackup, varfile);
- strcat(varfilebackup, ".backup");
+ (void) strcpy(varfilebackup, varfile);
+ (void) strcat(varfilebackup, ".backup");
if (!(fpout = fopen(varfilebackup, "w")))
return (errno);
@@ -101,9 +104,10 @@ Code_t ZUnsetVariable(var)
if (!varline(varbfr, var))
fprintf(fpout, "%s\n", varbfr);
}
- fclose(fpin);
+ (void) fclose(fpin); /* don't care about read close errs */
}
- fclose(fpout);
+ if (fclose(fpout) == EOF)
+ return(EIO); /* errno isn't reliable */
if (rename(varfilebackup, varfile))
return (errno);
return (ZERR_NONE);
@@ -115,19 +119,19 @@ static get_localvarfile(bfr)
char *envptr;
struct passwd *pwd;
- envptr = (char *)getenv("HOME");
+ envptr = getenv("HOME");
if (envptr)
- strcpy(bfr, envptr);
+ (void) strcpy(bfr, envptr);
else {
- if (!(pwd = getpwuid(getuid()))) {
+ if (!(pwd = getpwuid((int) getuid()))) {
fprintf(stderr, "Zephyr internal failure: Can't find your entry in /etc/passwd\n");
return (1);
}
- strcpy(bfr, pwd->pw_dir);
+ (void) strcpy(bfr, pwd->pw_dir);
}
- strcat(bfr, "/");
- strcat(bfr, ".zephyr.vars");
+ (void) strcat(bfr, "/");
+ (void) strcat(bfr, ".zephyr.vars");
return (0);
}
@@ -148,10 +152,10 @@ static char *get_varval(fn, var)
varbfr[strlen(varbfr)-1] = '\0';
if (!(i = varline(varbfr, var)))
continue;
- fclose(fp);
+ (void) fclose(fp); /* open read-only, don't care */
return (varbfr+i);
}
- fclose(fp);
+ (void) fclose(fp); /* open read-only, don't care */
return ((char *)0);
}
diff --git a/lib/Zinternal.c b/lib/Zinternal.c
index 86e98b9..d2d8c78 100644
--- a/lib/Zinternal.c
+++ b/lib/Zinternal.c
@@ -180,7 +180,7 @@ Code_t Z_ReadWait()
from_len = sizeof(struct sockaddr_in);
packet_len = recvfrom(ZGetFD(), packet, sizeof(packet), 0,
- &from, &from_len);
+ (struct sockaddr *)&from, &from_len);
if (packet_len < 0)
return (errno);
@@ -261,11 +261,11 @@ Code_t Z_ReadWait()
*/
if (part == 0 && !qptr->header) {
qptr->header_len = packet_len-notice.z_message_len;
- if (!(qptr->header = malloc(qptr->header_len)))
+ if (!(qptr->header = malloc((unsigned) qptr->header_len)))
return (ENOMEM);
bcopy(packet, qptr->header, qptr->header_len);
}
- return (Z_AddNoticeToEntry(qptr, &notice, part, partof));
+ return (Z_AddNoticeToEntry(qptr, &notice, part));
}
/*
@@ -282,7 +282,7 @@ Code_t Z_ReadWait()
qptr = (struct _Z_InputQ *)malloc(sizeof(struct _Z_InputQ));
if (!qptr)
return (ENOMEM);
- bzero(qptr, sizeof(struct _Z_InputQ));
+ bzero((char *)qptr, sizeof(struct _Z_InputQ));
/* Insert the entry at the end of the queue */
qptr->next = NULL;
@@ -311,7 +311,7 @@ Code_t Z_ReadWait()
*/
if (__Zephyr_server || part == 0) {
qptr->header_len = packet_len-notice.z_message_len;
- qptr->header = malloc(packet_len-notice.z_message_len);
+ qptr->header = malloc((unsigned) (packet_len-notice.z_message_len));
bcopy(packet, qptr->header, qptr->header_len);
}
@@ -325,13 +325,13 @@ Code_t Z_ReadWait()
qptr->holelist = NULL;
qptr->complete = 1;
/* allocate a msg buf for this piece */
- if (!(qptr->msg = malloc(notice.z_message_len)))
+ if (!(qptr->msg = malloc((unsigned) notice.z_message_len)))
return(ENOMEM);
qptr->msg_len = notice.z_message_len;
__Q_Size += notice.z_message_len;
bcopy(notice.z_message, qptr->msg, notice.z_message_len);
qptr->packet_len = qptr->header_len+qptr->msg_len;
- if (!(qptr->packet = malloc(qptr->packet_len)))
+ if (!(qptr->packet = malloc((unsigned) qptr->packet_len)))
return (ENOMEM);
bcopy(qptr->header, qptr->packet, qptr->header_len);
bcopy(qptr->msg, qptr->packet+qptr->header_len, qptr->msg_len);
@@ -342,7 +342,7 @@ Code_t Z_ReadWait()
* We know how long the message is going to be (this is better
* than IP fragmentation...), so go ahead and allocate it all.
*/
- if (!(qptr->msg = malloc(partof)))
+ if (!(qptr->msg = malloc((unsigned) partof)))
return (ENOMEM);
qptr->msg_len = partof;
__Q_Size += partof;
@@ -358,17 +358,16 @@ Code_t Z_ReadWait()
qptr->holelist->next = NULL;
qptr->holelist->first = 0;
qptr->holelist->last = partof-1;
- return (Z_AddNoticeToEntry(qptr, &notice, part, partof));
+ return (Z_AddNoticeToEntry(qptr, &notice, part));
}
/* Fragment management routines - compliments, more or less, of RFC815 */
-Code_t Z_AddNoticeToEntry(qptr, notice, part, partof)
+Code_t Z_AddNoticeToEntry(qptr, notice, part)
struct _Z_InputQ *qptr;
ZNotice_t *notice;
int part;
- int partof;
{
int last, oldfirst, oldlast;
struct _Z_Hole *hole, *lasthole;
@@ -401,7 +400,7 @@ Code_t Z_AddNoticeToEntry(qptr, notice, part, partof)
lasthole->next = hole->next;
else
qptr->holelist = hole->next;
- free(hole);
+ free((char *)hole);
/*
* Now create a new hole that is the original hole without the
* current fragment.
@@ -462,7 +461,7 @@ Code_t Z_AddNoticeToEntry(qptr, notice, part, partof)
qptr->complete = 1;
qptr->timep = 0; /* don't time out anymore */
qptr->packet_len = qptr->header_len+qptr->msg_len;
- if (!(qptr->packet = malloc(qptr->packet_len)))
+ if (!(qptr->packet = malloc((unsigned) qptr->packet_len)))
return (ENOMEM);
bcopy(qptr->header, qptr->packet, qptr->header_len);
bcopy(qptr->msg, qptr->packet+qptr->header_len, qptr->msg_len);
@@ -487,17 +486,19 @@ Code_t Z_FormatHeader(notice, buffer, buffer_len, len, cert_routine)
notice->z_multinotice = "";
(void) gettimeofday(&notice->z_uid.tv, (struct timezone *)0);
- notice->z_uid.tv.tv_sec = htonl(notice->z_uid.tv.tv_sec);
- notice->z_uid.tv.tv_usec = htonl(notice->z_uid.tv.tv_usec);
+ notice->z_uid.tv.tv_sec = htonl((u_long) notice->z_uid.tv.tv_sec);
+ notice->z_uid.tv.tv_usec = htonl((u_long) notice->z_uid.tv.tv_usec);
if ((retval = Z_GetMyAddr()) != ZERR_NONE)
return (retval);
bcopy(__My_addr, (char *)&notice->z_uid.zuid_addr, __My_length);
- bcopy(&notice->z_uid, &notice->z_multiuid, sizeof(ZUnique_Id_t));
+ bcopy((char *)&notice->z_uid,
+ (char *)&notice->z_multiuid, sizeof(ZUnique_Id_t));
- sprintf(version, "%s%d.%d", ZVERSIONHDR, ZVERSIONMAJOR, ZVERSIONMINOR);
+ (void) sprintf(version, "%s%d.%d", ZVERSIONHDR, ZVERSIONMAJOR,
+ ZVERSIONMINOR);
notice->z_version = (char *)malloc((unsigned)strlen(version)+1);
if (!notice->z_version)
return(ENOMEM);
@@ -535,16 +536,16 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, sumend_ptr)
if (buffer_len < strlen(notice->z_version)+1)
return (ZERR_HEADERLEN);
- strcpy(ptr, notice->z_version);
+ (void) strcpy(ptr, notice->z_version);
ptr += strlen(ptr)+1;
- temp = htonl(ZNUMFIELDS+notice->z_num_other_fields);
+ temp = htonl((u_long) (ZNUMFIELDS+notice->z_num_other_fields));
if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&temp,
sizeof(int)) == ZERR_FIELDLEN)
return (ZERR_HEADERLEN);
ptr += strlen(ptr)+1;
- temp = htonl((int)notice->z_kind);
+ temp = htonl((u_long) notice->z_kind);
if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&temp,
sizeof(int)) == ZERR_FIELDLEN)
return (ZERR_HEADERLEN);
@@ -565,7 +566,7 @@ Code_t Z_FormatRawHeader(notice, buffer, buffer_len, len, sumend_ptr)
return (ZERR_HEADERLEN);
ptr += strlen(ptr)+1;
- temp = htonl(notice->z_authent_len);
+ temp = htonl((u_long) notice->z_authent_len);
if (ZMakeAscii(ptr, end-ptr, (unsigned char *)&temp,
sizeof(int)) == ZERR_FIELDLEN)
return (ZERR_HEADERLEN);
@@ -692,7 +693,7 @@ Z_RemQueue(qptr)
hole = qptr->holelist;
while (hole) {
nexthole = hole->next;
- free(hole);
+ free((char *)hole);
hole = nexthole;
}
@@ -743,15 +744,15 @@ Code_t Z_SendFragmentedNotice(notice, len, func)
partnotice = *notice;
while (offset < notice->z_message_len || !notice->z_message_len) {
- sprintf(multi, "%d/%d", offset, notice->z_message_len);
+ (void) sprintf(multi, "%d/%d", offset, notice->z_message_len);
partnotice.z_multinotice = multi;
if (offset > 0) {
(void) gettimeofday(&partnotice.z_uid.tv,
(struct timezone *)0);
partnotice.z_uid.tv.tv_sec =
- htonl(partnotice.z_uid.tv.tv_sec);
+ htonl((u_long) partnotice.z_uid.tv.tv_sec);
partnotice.z_uid.tv.tv_usec =
- htonl(partnotice.z_uid.tv.tv_usec);
+ htonl((u_long) partnotice.z_uid.tv.tv_usec);
if ((retval = Z_GetMyAddr()) != ZERR_NONE)
return (retval);
bcopy(__My_addr, (char *)&partnotice.z_uid.zuid_addr,