From: danw Date: Wed, 29 Jan 1997 23:24:06 +0000 (+0000) Subject: POSIX, ANSI, sanity fixes X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/a43ce477fadf60ad125052349e4996e12c448e65 POSIX, ANSI, sanity fixes s/#endif lint/#endif/ for irix cc #include in idno.c for OSes that don't have crypt in stdlib 64-bit OS fixes in mr_param.c fill in missing return values in sq.c --- diff --git a/lib/Imakefile b/lib/Imakefile index f87cd370..a14df558 100644 --- a/lib/Imakefile +++ b/lib/Imakefile @@ -36,7 +36,7 @@ comp_et_depend(gdss_et) depend:: ${CODE} library_obj_rule() -install_library_target(moira,$(OBJECTS),$(SRCS),${MR_LINTLIB}) +install_library_target(moira,$(OBJECTS),$(SRCS)) install:: -mkdir ${DESTDIR}${INCLDIR} diff --git a/lib/critical.c b/lib/critical.c index 7d5df7f1..27913d2e 100644 --- a/lib/critical.c +++ b/lib/critical.c @@ -19,7 +19,8 @@ #include #endif #include - +#include +#include /* mode to create the file with */ #define LOGFILEMODE 0644 @@ -33,7 +34,7 @@ extern char *whoami; * whoami to be defined and contain the name of the calling program. * It's a kludge that it takes a max of 8 arguments in a way that * isn't necessarily portable, but varargs doesn't work here and we - * don't have vsprintf(). + * don't necessarily have vsprintf(). */ void critical_alert(instance, msg, arg1, arg2, arg3, arg4, @@ -53,7 +54,7 @@ void critical_alert(instance, msg, arg1, arg2, arg3, arg4, /* Log message to critical file */ if ((crit = fopen(CRITERRLOG, "a")) != (FILE *)NULL) { - long t, time(); + time_t t; char *time_s; time(&t); diff --git a/lib/fixhost.c b/lib/fixhost.c index 54bc7205..d712d6eb 100644 --- a/lib/fixhost.c +++ b/lib/fixhost.c @@ -10,7 +10,7 @@ #ifndef lint static char *rcsid_fixhost_c = "$Header$"; -#endif lint +#endif #include #include @@ -18,6 +18,7 @@ static char *rcsid_fixhost_c = "$Header$"; #include #include #include +#include #ifdef POSIX #include #endif @@ -25,9 +26,6 @@ static char *rcsid_fixhost_c = "$Header$"; #include #include -extern char *malloc(); -extern char *realloc(); - /* * Canonicalize hostname: * if it is in double-quotes, then strip the quotes and return the name. diff --git a/lib/fixname.c b/lib/fixname.c index ae133a41..dd300bf7 100644 --- a/lib/fixname.c +++ b/lib/fixname.c @@ -10,7 +10,7 @@ #ifndef lint static char *rcsid_fixname_c = "$Header$"; -#endif lint +#endif #include #include @@ -48,7 +48,7 @@ void FixName(ilnm, ifnm, last, first, middle) #ifdef notdef /* okay, finish up first name */ AppendJrOrIII(ifnm, &ends_jr, &ends_ii, &ends_iii, &ends_iv, &ends_v); -#endif notdef +#endif strncpy(first, ifnm, FIRST_LEN); } diff --git a/lib/hash.c b/lib/hash.c index e34e289f..665925d4 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -11,10 +11,11 @@ #include #include #include +#include -extern char *malloc(); - +#ifndef NULL #define NULL 0 +#endif #define hash_func(h, key) (key >= 0 ? (key % h->size) : (-key % h->size)) /* Create a hash table. The size is just a hint, not a maximum. */ diff --git a/lib/idno.c b/lib/idno.c index be166df2..e98222a6 100644 --- a/lib/idno.c +++ b/lib/idno.c @@ -10,7 +10,12 @@ #include #include #include - +#ifdef POSIX +#include +#endif +#ifdef USE_CRYPT_H +#include +#endif /* Function Name: RemoveHyphens * Description: Removes all hyphens from the string passed to it. @@ -42,7 +47,6 @@ EncryptID(sbuf, idnumber, first, last) char *sbuf, *idnumber, *first, *last; { char salt[3]; - extern char *crypt(); RemoveHyphens(idnumber); salt[0] = tolower(last[0]); diff --git a/lib/mr_access.c b/lib/mr_access.c index f386d806..c8633f1d 100644 --- a/lib/mr_access.c +++ b/lib/mr_access.c @@ -10,12 +10,12 @@ #ifndef lint static char *rcsid_sms_access_c = "$Header$"; -#endif lint +#endif #include #include "mr_private.h" #include - +#include /* * Check access to a named query. diff --git a/lib/mr_auth.c b/lib/mr_auth.c index d6db8ca0..25277cee 100644 --- a/lib/mr_auth.c +++ b/lib/mr_auth.c @@ -13,7 +13,7 @@ #ifndef lint static char *rcsid_sms_auth_c = "$Header$"; -#endif lint +#endif #include #include "mr_private.h" diff --git a/lib/mr_call.c b/lib/mr_call.c index 86ca32c9..9048dc8a 100644 --- a/lib/mr_call.c +++ b/lib/mr_call.c @@ -10,7 +10,7 @@ #ifndef lint static char *rcsid_sms_call_c = "$Header$"; -#endif lint +#endif #include #include "mr_private.h" diff --git a/lib/mr_connect.c b/lib/mr_connect.c index 39ebcd45..b619e2d7 100644 --- a/lib/mr_connect.c +++ b/lib/mr_connect.c @@ -13,12 +13,14 @@ #ifndef lint static char *rcsid_sms_connect_c = "$Header$"; -#endif lint +#endif #include #include "mr_private.h" #include #include +#include +#include static char *mr_server_host = 0; @@ -33,7 +35,6 @@ char *server; { extern int errno; char *p, **pp, sbuf[256]; - extern char *getenv(), **hes_resolve(); if (!mr_inited) mr_init(); if (_mr_conn) return MR_ALREADY_CONNECTED; @@ -47,7 +48,7 @@ char *server; pp = hes_resolve("moira", "sloc"); if (pp) server = *pp; } -#endif HESIOD +#endif if (!server || (strlen(server) == 0)) { server = MOIRA_SERVER; diff --git a/lib/mr_data.c b/lib/mr_data.c index 8e7f4ffa..d9864fb9 100644 --- a/lib/mr_data.c +++ b/lib/mr_data.c @@ -11,7 +11,7 @@ #ifndef lint static char *rcsid_sms_data_c = "$Header$"; -#endif lint +#endif #include #include "mr_private.h" diff --git a/lib/mr_init.c b/lib/mr_init.c index 880e88c1..7a8055a0 100644 --- a/lib/mr_init.c +++ b/lib/mr_init.c @@ -10,7 +10,7 @@ #ifndef lint static char *rcsid_sms_init_c = "$Header$"; -#endif lint +#endif #include #include "mr_private.h" diff --git a/lib/mr_ops.c b/lib/mr_ops.c index 25ea8597..7e91f131 100644 --- a/lib/mr_ops.c +++ b/lib/mr_ops.c @@ -15,7 +15,7 @@ #ifndef lint static char *rcsid_sms_do_update_c = "$Header$"; -#endif lint +#endif #include #include diff --git a/lib/mr_param.c b/lib/mr_param.c index 0db231f7..c3f074d7 100644 --- a/lib/mr_param.c +++ b/lib/mr_param.c @@ -11,13 +11,14 @@ #ifndef lint static char *rcsid_sms_param_c = "$Header$"; -#endif lint +#endif #include #include #include #include "mr_private.h" #include +#include /* * GDB operations to send and recieve RPC requests and replies. @@ -69,10 +70,10 @@ mr_start_send(op, hcon, arg) * At least for now, each argument is a string, which is * sent as a count of bytes followed by the bytes * (including the trailing '\0'), padded - * to a longword boundary. + * to a 32-bit boundary. */ - mr_size = 4 * sizeof(long); + mr_size = 4 * sizeof(int32); argl = (int *)malloc((unsigned)(sizeof(int) * arg->mr_argc)); @@ -85,9 +86,9 @@ mr_start_send(op, hcon, arg) argl[i] = len = arg->mr_argl[i]; else argl[i] = len = strlen(arg->mr_argv[i]) + 1; - mr_size += sizeof(long) + len; - /* Round up to next longword boundary.. */ - mr_size = sizeof(long) * howmany(mr_size, sizeof(long)); + mr_size += sizeof(int32) + len; + /* Round up to next 32-bit boundary.. */ + mr_size = sizeof(int32) * howmany(mr_size, sizeof(int32)); } arg->mr_flattened = buf = malloc(mr_size); @@ -96,30 +97,24 @@ mr_start_send(op, hcon, arg) arg->mr_size = mr_size; - /* - * This is gross. Any better suggestions, anyone? - * It should work on the RT's, since malloc is guaranteed to - * return a pointer which is aligned correctly for any data. - */ - - ((long *)buf)[0] = htonl(mr_size); - ((long *)buf)[1] = htonl(arg->mr_version_no); - ((long *)buf)[2] = htonl(arg->mr_procno); - ((long *)buf)[3] = htonl(arg->mr_argc); + ((int32 *)buf)[0] = htonl(mr_size); + ((int32 *)buf)[1] = htonl(arg->mr_version_no); + ((int32 *)buf)[2] = htonl(arg->mr_procno); + ((int32 *)buf)[3] = htonl(arg->mr_argc); /* * bp is a pointer into the point in the buffer to put * the next argument. */ - bp = (char *)(((long *)buf) + 4); + bp = (char *)(((int32 *)buf) + 4); for (i = 0; imr_argc; ++i) { len = argl[i]; - *((long *)bp) = htonl(len); - bp += sizeof(long); + *((int32 *)bp) = htonl(len); + bp += sizeof(int32); memcpy(bp, arg->mr_argv[i], len); - bp += sizeof(long) * howmany(len, sizeof(long)); + bp += sizeof(int32) * howmany(len, sizeof(int32)); } op->fcn.cont = mr_cont_send; arg->mr_size = mr_size; @@ -148,7 +143,7 @@ mr_cont_recv(op, hcon, argp) case S_RECV_START: arg->mr_state = S_RECV_DATA; if (gdb_receive_data(hcon, (caddr_t)&arg->mr_size, - sizeof(long)) == OP_COMPLETE) + sizeof(int32)) == OP_COMPLETE) continue; done = TRUE; break; @@ -161,11 +156,11 @@ mr_cont_recv(op, hcon, argp) } arg->mr_flattened = malloc(arg->mr_size); arg->mr_state = S_DECODE_DATA; - memcpy(arg->mr_flattened, (caddr_t)&arg->mr_size, sizeof(long)); + memcpy(arg->mr_flattened, (caddr_t)&arg->mr_size, sizeof(int32)); if (gdb_receive_data(hcon, - arg->mr_flattened + sizeof(long), - arg->mr_size - sizeof(long)) + arg->mr_flattened + sizeof(int32), + arg->mr_size - sizeof(int32)) == OP_COMPLETE) continue; done = TRUE; @@ -187,7 +182,7 @@ mr_cont_recv(op, hcon, argp) for (i = 0; imr_argc; ++i) { u_short nlen = ntohl(* (int *) cp); - cp += sizeof (long); + cp += sizeof (int32); if (cp + nlen > arg->mr_flattened + arg->mr_size) { free(arg->mr_flattened); arg->mr_flattened = NULL; @@ -196,7 +191,7 @@ mr_cont_recv(op, hcon, argp) arg->mr_argv[i] = (char *)malloc(nlen); memcpy(arg->mr_argv[i], cp, nlen); arg->mr_argl[i]=nlen; - cp += sizeof(long) * howmany(nlen, sizeof(long)); + cp += sizeof(int32) * howmany(nlen, sizeof(int32)); } free(arg->mr_flattened); arg->mr_flattened = NULL; diff --git a/lib/mr_private.h b/lib/mr_private.h index 720c3cdc..d769f397 100644 --- a/lib/mr_private.h +++ b/lib/mr_private.h @@ -27,16 +27,3 @@ extern int sending_version_no; #define EVER (;;) #define CHECK_CONNECTED {if (!_mr_conn) return MR_NOT_CONNECTED;} - -/* - * There should be an include file for these.. - */ - -extern char *malloc(); -#ifndef htonl -extern u_long htonl(), ntohl(); -extern u_short htons(), ntohs(); -#endif /* htonl */ - - - diff --git a/lib/mr_query.c b/lib/mr_query.c index 0058754b..16eca18e 100644 --- a/lib/mr_query.c +++ b/lib/mr_query.c @@ -11,11 +11,12 @@ #ifndef lint static char *rcsid_sms_query_c = "$Header$"; -#endif lint +#endif #include #include "mr_private.h" #include +#include /* * This routine is the primary external interface to the mr library. @@ -23,7 +24,7 @@ static char *rcsid_sms_query_c = "$Header$"; * It builds a new argument vector with the query handle prepended, * and calls mr_query_internal. */ -int level = 0; +static int level = 0; int mr_query(name, argc, argv, callproc, callarg) char *name; /* Query name */ diff --git a/lib/nfsparttype.c b/lib/nfsparttype.c index c7e47cf5..e00a72ac 100644 --- a/lib/nfsparttype.c +++ b/lib/nfsparttype.c @@ -11,13 +11,14 @@ #ifndef lint static char *rcsid_nfsparttype_c = "$Header$"; -#endif lint +#endif #include #include #include #include #include +#include extern char *strsave(); extern char *strtrim(); diff --git a/lib/sq.c b/lib/sq.c index a9e98856..eac91562 100644 --- a/lib/sq.c +++ b/lib/sq.c @@ -10,8 +10,7 @@ #include #include #include - -extern char *malloc(); +#include struct save_queue * sq_create() @@ -77,7 +76,7 @@ sq_save_unique_data(sq, data) register struct save_queue *q; for (q = sq->q_next; q != sq; q = q->q_next) - if (q->q_data == data) return; + if (q->q_data == data) return 1; return sq_save_data(sq, data); } @@ -90,7 +89,7 @@ sq_save_unique_string(sq, data) register struct save_queue *q; for (q = sq->q_next; q != sq; q = q->q_next) - if (!strcmp(q->q_data, data)) return; + if (!strcmp(q->q_data, data)) return 1; return sq_save_data(sq, data); } diff --git a/lib/strs.c b/lib/strs.c index 62385dd1..055e19a5 100644 --- a/lib/strs.c +++ b/lib/strs.c @@ -12,15 +12,14 @@ #ifndef lint static char *rcsid_strs_c = "$Header$"; -#endif lint +#endif #include #include +#include #include #include -extern char *malloc(), *realloc(); - /* * Random string functions which should be in the C library.. */ @@ -36,7 +35,6 @@ strsave(s) register char *p; /* Kludge for sloppy string semantics */ if (!s) { - printf("NULL != \"\" !!!!\r\n"); p = malloc(1); *p = '\0'; return p;