Commit 7b53320f authored by Mike Hibler's avatar Mike Hibler

Fix the size of the struct passed over the wire and clean up some lint.

We were using "short" and "int" in the data struct passed between client
and server. Note that we still need to address the big/little endian thing.
parent e19a1c30
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2011 University of Utah and the Flux Group.
# Copyright (c) 2000-2012 University of Utah and the Flux Group.
# All rights reserved.
#
SRCDIR = @srcdir@
......@@ -48,5 +48,5 @@ client-install: client
$(INSTALL_DATA) $(SRCDIR)/emulab-sync.1 $(DESTDIR)$(CLIENT_MANDIR)/man1/emulab-sync.1
clean:
rm -f *.o emulab-syncd emulab-sync version.c
rm -f *.o emulab-syncd emulab-sync *.debug version.c
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2002-2006 University of Utah and the Flux Group.
* Copyright (c) 2002-2012 University of Utah and the Flux Group.
* All rights reserved.
*/
#include <inttypes.h>
#define SERVER_SERVNAME "emulab_syncd"
#define SERVER_PORTNUM 16534
#define SOCKBUFSIZE (1024 * 128)
......@@ -15,10 +17,10 @@
*/
typedef struct {
char name[64]; /* An arbitrary string */
short request; /* Either init or wait */
short flags; /* See below */
int count; /* Number of waiters */
int error; /* Error code (0 == no error) */
int16_t request; /* Either init or wait */
int16_t flags; /* See below */
int32_t count; /* Number of waiters */
int32_t error; /* Error code (0 == no error) */
} barrier_req_t;
/* Request */
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2004, 2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2012 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -217,13 +217,13 @@ main(int argc, char **argv)
if (fgets(buf, sizeof(buf), fp)) {
if ((bp = strchr(buf, '\n')))
*bp = (char) NULL;
*bp = 0;
/*
* Look for port spec
*/
if ((bp = strchr(buf, ':'))) {
*bp++ = (char) NULL;
*bp++ = 0;
portnum = atoi(bp);
}
server = strdup(buf);
......@@ -446,8 +446,8 @@ dotcp(barrier_req_t *barrier_reqp, struct in_addr serverip, int portnum)
}
close(sock);
if (n == 4) {
return *((int *)buf);
if (n == sizeof(int32_t)) {
return *((int32_t *)buf);
}
else {
return -1;
......@@ -463,7 +463,8 @@ dotcp(barrier_req_t *barrier_reqp, struct in_addr serverip, int portnum)
static int
doudp(barrier_req_t *barrier_reqp, struct in_addr serverip, int portnum)
{
int sock, length, n, cc;
int sock, n, cc;
socklen_t length;
struct sockaddr_in name, client;
char buf[BUFSIZ];
......@@ -503,8 +504,8 @@ doudp(barrier_req_t *barrier_reqp, struct in_addr serverip, int portnum)
}
close(sock);
if (cc == 4) {
return *((int *)buf);
if (cc == sizeof(int32_t)) {
return *((int32_t *)buf);
}
else {
return -1;
......
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2006 University of Utah and the Flux Group.
* Copyright (c) 2000-2012 University of Utah and the Flux Group.
* All rights reserved.
*/
......@@ -342,7 +342,8 @@ main(int argc, char **argv)
while (1) {
struct sockaddr_in client;
int length, cc, newsock, j;
int cc, newsock, j;
socklen_t length;
barrier_req_t barrier_req;
if (gotsiginfo) {
......@@ -594,7 +595,8 @@ static int
makesockets(int *portnum, int *udpsockp, int *tcpsockp)
{
struct sockaddr_in name;
int length, i, udpsock, tcpsock;
socklen_t length;
int i, udpsock, tcpsock;
/*
* Setup TCP socket for incoming connections.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment