Fix various warnings that pop up by default with gcc 4.9
authorWouter Verhelst <w@uter.be>
Wed, 1 Oct 2014 20:42:18 +0000 (22:42 +0200)
committerWouter Verhelst <w@uter.be>
Wed, 1 Oct 2014 20:42:18 +0000 (22:42 +0200)
cliserv.c
cliserv.h
nbd-server.c
nbdsrv.c

index 5abbe64..c240f53 100644 (file)
--- a/cliserv.c
+++ b/cliserv.c
@@ -3,6 +3,10 @@
 #include <stdio.h>
 #include <syslog.h>
 
+const u64 cliserv_magic = 0x00420281861253LL;
+const u64 opts_magic = 0x49484156454F5054LL;
+const u64 rep_magic = 0x3e889045565a9LL;
+
 void setmysockopt(int sock) {
        int size = 1;
 #if 0
index 702c847..9a0025e 100644 (file)
--- a/cliserv.h
+++ b/cliserv.h
@@ -64,9 +64,10 @@ typedef unsigned long long u64;
 #endif
 #endif
 
-static u64 cliserv_magic = 0x00420281861253LL;
-static u64 opts_magic = 0x49484156454F5054LL;
-static u64 rep_magic = 0x3e889045565a9LL;
+extern const u64 cliserv_magic;
+extern const u64 opts_magic;
+extern const u64 rep_magic;
+
 #define INIT_PASSWD "NBDMAGIC"
 
 #define INFO(a) do { } while(0)
index b98ba72..4611489 100644 (file)
@@ -1820,8 +1820,6 @@ void serveconnection(CLIENT *client) {
  **/
 int set_peername(int net, CLIENT *client) {
        struct sockaddr_storage netaddr;
-       struct sockaddr_in  *netaddr4 = NULL;
-       struct sockaddr_in6 *netaddr6 = NULL;
        socklen_t addrinlen = sizeof( struct sockaddr_storage );
        struct addrinfo hints;
        struct addrinfo *ai = NULL;
@@ -1830,7 +1828,6 @@ int set_peername(int net, CLIENT *client) {
        char *tmp = NULL;
        int i;
        int e;
-       int shift;
 
        if (getpeername(net, (struct sockaddr *) &(client->clientaddr), &addrinlen) < 0) {
                msg(LOG_INFO, "getpeername failed: %m");
@@ -1879,7 +1876,7 @@ int set_peername(int net, CLIENT *client) {
                        } else if(ai->ai_family == AF_INET6) {
                                addrbits = 128;
                        }
-                       uint8_t* addrptr = ((struct sockaddr*)&netaddr)->sa_data;
+                       uint8_t* addrptr = (uint8_t*)(((struct sockaddr*)&netaddr)->sa_data);
                        for(int i = 0; i < addrbits; i+=8) {
                                int masklen = client->server->cidrlen - i;
                                masklen = masklen > 0 ? masklen : 0;
@@ -2486,7 +2483,6 @@ int open_modern(const gchar *const addr, const gchar *const port,
        struct sock_flags;
        int e;
         int retval = -1;
-       int i=0;
        int sock = -1;
 
        memset(&hints, '\0', sizeof(hints));
index 3689004..506579a 100644 (file)
--- a/nbdsrv.c
+++ b/nbdsrv.c
@@ -104,11 +104,6 @@ uint8_t getmaskbyte(int masklen) {
 int authorized_client(CLIENT *opts) {
        FILE *f ;
        char line[LINELEN]; 
-       char *tmp;
-       struct in_addr addr;
-       struct in_addr client;
-       struct in_addr cltemp;
-       int len;
 
        if (opts->server->authname == NULL) {
                msg(LOG_INFO, "No authorization file, granting access.");