Fix various compiler warnings throughout the code
Mostly signed/unsigned and typecasting issues
Taken from http://sourceforge.net/tracker/index.php?func=detail&aid=1811517&group_id=68956&atid=522957
diff --git a/ggsn/ggsn.c b/ggsn/ggsn.c
index 62a37f2..60a4f80 100644
--- a/ggsn/ggsn.c
+++ b/ggsn/ggsn.c
@@ -124,7 +124,7 @@
int encaps_printf(void *p, void *packet, unsigned len)
{
- int i;
+ unsigned int i;
if (debug) {
printf("The packet looks like this:\n");
for( i=0; i<len; i++) {
@@ -423,7 +423,7 @@
}
apn.l = strlen(args_info.apn_arg) + 1;
apn.v[0] = (char) strlen(args_info.apn_arg);
- strncpy(&apn.v[1], args_info.apn_arg, sizeof(apn.v)-1);
+ strncpy((char *) &apn.v[1], args_info.apn_arg, sizeof(apn.v)-1);
/* foreground */
diff --git a/ggsn/ippool.c b/ggsn/ippool.c
index 35b14a3..fa3d8af 100644
--- a/ggsn/ippool.c
+++ b/ggsn/ippool.c
@@ -23,7 +23,7 @@
int ippool_printaddr(struct ippool_t *this) {
- int n;
+ unsigned int n;
printf("ippool_printaddr\n");
printf("Firstdyn %d\n", this->firstdyn - this->member);
printf("Lastdyn %d\n", this->lastdyn - this->member);
@@ -110,7 +110,7 @@
unsigned int a1, a2, a3, a4;
unsigned int m1, m2, m3, m4;
int c;
- unsigned int m;
+ int m;
int masklog;
c = sscanf(pool, "%u.%u.%u.%u/%u.%u.%u.%u",
@@ -167,8 +167,8 @@
struct in_addr stataddr;
struct in_addr statmask;
unsigned int m;
- unsigned int listsize;
- unsigned int dynsize;
+ int listsize;
+ int dynsize;
unsigned int statsize;
if (!allowdyn) {
diff --git a/ggsn/ippool.h b/ggsn/ippool.h
index fe9f90c..02691a6 100644
--- a/ggsn/ippool.h
+++ b/ggsn/ippool.h
@@ -37,13 +37,13 @@
struct ippoolm_t; /* Forward declaration */
struct ippool_t {
- int listsize; /* Total number of addresses */
+ unsigned int listsize; /* Total number of addresses */
int allowdyn; /* Allow dynamic IP address allocation */
int allowstat; /* Allow static IP address allocation */
struct in_addr stataddr; /* Static address range network address */
struct in_addr statmask; /* Static address range network mask */
struct ippoolm_t *member; /* Listsize array of members */
- int hashsize; /* Size of hash table */
+ unsigned int hashsize; /* Size of hash table */
int hashlog; /* Log2 size of hash table */
int hashmask; /* Bitmask for calculating hash */
struct ippoolm_t **hash; /* Hashsize array of pointer to member */
diff --git a/ggsn/syserr.c b/ggsn/syserr.c
index e0ebc3a..002d8c3 100644
--- a/ggsn/syserr.c
+++ b/ggsn/syserr.c
@@ -41,7 +41,7 @@
va_list args;
char buf[SYSERR_MSGSIZE];
char buf2[SYSERR_MSGSIZE];
- int n;
+ unsigned int n;
int pos;
va_start(args, fmt);
diff --git a/ggsn/tun.c b/ggsn/tun.c
index 365aec0..1cc706b 100644
--- a/ggsn/tun.c
+++ b/ggsn/tun.c
@@ -243,7 +243,7 @@
} req;
struct sockaddr_nl local;
- int addr_len;
+ socklen_t addr_len;
int fd;
int status;