Skip to contentSkip to conversation

NBD dead code elimination

PATCH In review Carlo Marcelo Arenas Belon 2 participants 2 messages Jun 18, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NBD dead code elimination

The following patch, removes tcp_socket_outgoing which is not being used by the current implementation, neither the proposed unix socket patches.

This avoids the following compile time warning :

nbd.c:99: warning: 'tcp_socket_outgoing' defined but not used

Carlo
---

nbd.c +0 -39
Index: nbd.c
===================================================================
@@ -95,45 +95,6 @@
     return offset;
 }
 
-static int tcp_socket_outgoing(const char *address, uint16_t port)
-{
-    int s;
-    struct in_addr in;
-    struct sockaddr_in addr;
-    int serrno;
-
-    s = socket(PF_INET, SOCK_STREAM, 0);
-    if (s == -1) {
-        return -1;
-    }
-
-    if (inet_aton(address, &in) == 0) {
-        struct hostent *ent;
-
-        ent = gethostbyname(address);
-        if (ent == NULL) {
-            goto error;
-        }
-
-        memcpy(&in, ent->h_addr, sizeof(in));
-    }
-
-    addr.sin_family = AF_INET;
-    addr.sin_port = htons(port);
-    memcpy(&addr.sin_addr.s_addr, &in, sizeof(in));
-
-    if (connect(s, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
-        goto error;
-    }
-
-    return s;
-error:
-    serrno = errno;
-    close(s);
-    errno = serrno;
-    return -1;
-}
-
 int tcp_socket_incoming(const char *address, uint16_t port)
 {
     int s;
#1 lore raw

Hi,

I don't know if it is a good idea to remove this code, perhaps it can be useful one day if we want to add the nbd-client functionality in qemu-nbd (my patch, using unix socket, already does).

Regards,
Laurent

Le mercredi 18 juin 2008 à 02:15 -0500, Carlo Marcelo Arenas Belon a écrit :

Quoted 9 lines

The following patch, removes tcp_socket_outgoing which is not being used by the current implementation, neither the proposed unix socket patches.

This avoids the following compile time warning :

nbd.c:99: warning: 'tcp_socket_outgoing' defined but not used

Carlo
---

Signature · 3 lines
------------- [email protected] ---------------
"The best way to predict the future is to invent it."
- Alan Kay