dtlogin: start to resolve static analysis warnings

Also convert some K&R function declarations to ansi
This commit is contained in:
Peter Howkins
2014-12-23 17:49:11 +00:00
parent 29294e0373
commit e54c164fe1
13 changed files with 215 additions and 317 deletions

View File

@@ -160,6 +160,8 @@ static struct _app_resources {
int connectionType;
} app_resources;
static int FromHex (char *s, char *d, int len);
#define offset(field) XtOffsetOf(struct _app_resources, field)
#define XtRARRAY8 "ARRAY8"
@@ -213,9 +215,7 @@ static XdmcpBuffer buffer;
/* ARGSUSED */
static void
PingHosts (closure, id)
XtPointer closure;
XtIntervalId *id;
PingHosts (XtPointer closure, XtIntervalId *id)
{
HostAddr *hosts;
@@ -233,19 +233,19 @@ PingHosts (closure, id)
char **NameTable;
int NameTableSize;
static int
HostnameCompare (a, b)
#if defined(__STDC__)
const void *a, *b;
static int
HostnameCompare (const void *a, const void *b)
#else
char *a, *b;
static int
HostnameCompare (char *a, char *b)
#endif
{
return strcmp (*(char **)a, *(char **)b);
}
static void
RebuildTable (size)
RebuildTable (int size)
{
char **newTable = 0;
HostName *names;
@@ -296,8 +296,7 @@ RebuildTable (size)
}
static void
RebuildTableAdd (size)
int size;
RebuildTableAdd (int size)
{
char **newTable = 0;
HostName *names;
@@ -336,10 +335,7 @@ RebuildTableAdd (size)
static int
AddHostname (hostname, status, addr, willing)
ARRAY8Ptr hostname, status;
struct sockaddr *addr;
int willing;
AddHostname (ARRAY8Ptr hostname, ARRAY8Ptr status, struct sockaddr *addr, int willing)
{
HostName *new, **names, *name;
ARRAY8 hostAddr;
@@ -445,9 +441,8 @@ AddHostname (hostname, status, addr, willing)
return 1;
}
static
DisposeHostname (host)
HostName *host;
static void
DisposeHostname (HostName *host)
{
XdmcpDisposeARRAY8 (&host->hostname);
XdmcpDisposeARRAY8 (&host->hostaddr);
@@ -456,9 +451,8 @@ DisposeHostname (host)
free ((char *) host);
}
static
RemoveHostname (host)
HostName *host;
static int
RemoveHostname (HostName *host)
{
HostName **prev, *hosts;
@@ -475,10 +469,12 @@ RemoveHostname (host)
DisposeHostname (host);
NameTableSize--;
RebuildTable (NameTableSize);
return 1;
}
static
EmptyHostnames ()
static void
EmptyHostnames (void)
{
HostName *hosts, *next;
@@ -494,10 +490,7 @@ EmptyHostnames ()
/* ARGSUSED */
static void
ReceivePacket (closure, source, id)
XtPointer closure;
int *source;
XtInputId *id;
ReceivePacket (XtPointer closure, int *source, XtInputId *id)
{
XdmcpHeader header;
ARRAY8 authenticationName;
@@ -554,10 +547,8 @@ ReceivePacket (closure, source, id)
}
}
RegisterHostaddr (addr, len, type)
struct sockaddr *addr;
int len;
xdmOpCode type;
int
RegisterHostaddr (struct sockaddr *addr, int len, xdmOpCode type)
{
HostAddr *host, **prev;
@@ -577,6 +568,7 @@ RegisterHostaddr (addr, len, type)
;
*prev = host;
host->next = NULL;
return 1;
}
/*
@@ -585,9 +577,8 @@ RegisterHostaddr (addr, len, type)
* The special name "BROADCAST" looks up all the broadcast
* addresses on the local host.
*/
RegisterHostname (name)
char *name;
int
RegisterHostname (char *name)
{
struct hostent *hostent;
struct sockaddr_in in_addr;
@@ -678,13 +669,13 @@ RegisterHostname (name)
RegisterHostaddr ((struct sockaddr *)&in_addr, sizeof (in_addr),
QUERY);
}
return 1;
}
static ARRAYofARRAY8 AuthenticationNames;
RegisterAuthenticationName (name, namelen)
char *name;
int namelen;
static int
RegisterAuthenticationName (char *name, int namelen)
{
ARRAY8Ptr authName;
if (!XdmcpReallocARRAYofARRAY8 (&AuthenticationNames,
@@ -694,10 +685,12 @@ RegisterAuthenticationName (name, namelen)
if (!XdmcpAllocARRAY8 (authName, namelen))
return 0;
memmove( authName->data, name, namelen);
return 1;
}
InitXDMCP (argv)
char **argv;
int
InitXDMCP (char **argv)
{
int soopts = 1;
XdmcpHeader header;
@@ -740,8 +733,7 @@ InitXDMCP (argv)
}
void
Choose (h)
HostName *h;
Choose (HostName *h)
{
if (app_resources.xdmAddress)
{
@@ -801,11 +793,7 @@ Choose (h)
/* ARGSUSED */
void
DoAccept (w, event, params, num_params)
Widget w;
XEvent *event;
String *params;
Cardinal *num_params;
DoAccept (Widget w, XEvent *event, String *params, Cardinal *num_params)
{
HostName *h;
XmStringTable selectedItem;
@@ -846,11 +834,7 @@ DoAccept (w, event, params, num_params)
/* ARGSUSED */
static void
DoCheckWilling (w, event, params, num_params)
Widget w;
XEvent *event;
String *params;
Cardinal *num_params;
DoCheckWilling (Widget w, XEvent *event, String *params, Cardinal *num_params)
{
HostName *h;
XmStringTable selectedItem;
@@ -889,22 +873,14 @@ DoCheckWilling (w, event, params, num_params)
/* ARGSUSED */
void
DoCancel (w, event, params, num_params)
Widget w;
XEvent *event;
String *params;
Cardinal *num_params;
DoCancel (Widget w, XEvent *event, String *params, Cardinal *num_params)
{
exit (OBEYSESS_DISPLAY);
}
/* ARGSUSED */
void
DoPing (w, event, params, num_params)
Widget w;
XEvent *event;
String *params;
Cardinal *num_params;
DoPing (Widget w, XEvent *event, String *params, Cardinal *num_params)
{
EmptyHostnames ();
pingTry = 0;
@@ -918,8 +894,8 @@ static XtActionsRec app_actions[] = {
"Ping", DoPing,
};
main (argc, argv)
char **argv;
int
main (int argc, char **argv)
{
Arg position[3];
Dimension width, height;
@@ -1018,17 +994,15 @@ XtPopup(login_shell, XtGrabNone);
#endif
InitXDMCP (argv + 1);
XtMainLoop ();
exit(0);
/*NOTREACHED*/
return 0;
}
/* Converts the hex string s of length len into the byte array d.
Returns 0 if s was a legal hex string, 1 otherwise.
*/
int
FromHex (s, d, len)
char *s, *d;
int len;
static int
FromHex (char *s, char *d, int len)
{
int t;
int ret = len&1; /* odd-length hex strings are illegal */
@@ -1052,11 +1026,7 @@ FromHex (s, d, len)
/*ARGSUSED*/
static void
CvtStringToARRAY8 (args, num_args, fromVal, toVal)
XrmValuePtr args;
Cardinal *num_args;
XrmValuePtr fromVal;
XrmValuePtr toVal;
CvtStringToARRAY8 (XrmValuePtr args, Cardinal *num_args, XrmValuePtr fromVal, XrmValuePtr toVal)
{
static ARRAY8Ptr dest;
char *s;