[Mesa-dev] [PATCH] xdemos/corender: remove obsolete function gethostbyname

david.heidelberger david.heidelberger at ixit.cz
Sat Sep 14 06:12:30 PDT 2013


 From 911cdbcf90440d748c185ac53fa6dded7f3da17c Mon Sep 17 00:00:00 2001
 From: David Heidelberger <david.heidelberger at ixit.cz>
Date: Mon, 9 Sep 2013 21:48:36 +0200
Subject: [PATCH] xdemos/corender: remove obsolete function gethostbyname

Patch remove unused and obsolete funtion gethostbyname(). This also
fixes runtime assert and error.

corender: ipc.c:85: CreatePort: Assertion `hp' failed.
---
  src/xdemos/ipc.c | 12 ------------
  1 file changed, 12 deletions(-)

diff --git a/src/xdemos/ipc.c b/src/xdemos/ipc.c
index c872d16..d6920b5 100644
--- a/src/xdemos/ipc.c
+++ b/src/xdemos/ipc.c
@@ -67,7 +67,6 @@ CreatePort(int *port)
  {
      char hostname[1000];
      struct sockaddr_in servaddr;
-    struct hostent *hp;
      int so_reuseaddr = 1;
      int tcp_nodelay = 1;
      int sock, k;
@@ -80,16 +79,10 @@ CreatePort(int *port)
      k = gethostname(hostname, 1000);
      assert(k == 0);

-    /* get hostent info */
-    hp = gethostbyname(hostname);
-    assert(hp);
-
      /* initialize the servaddr struct */
      memset(&servaddr, 0, sizeof(servaddr) );
      servaddr.sin_family = AF_INET;
      servaddr.sin_port = htons((unsigned short) (*port));
-    memcpy((char *) &servaddr.sin_addr, hp->h_addr,
-	   sizeof(servaddr.sin_addr));

      /* deallocate when we exit */
      k = setsockopt(sock, SOL_SOCKET, SO_REUSEADDR,
@@ -155,7 +148,6 @@ int
  Connect(const char *hostname, int port)
  {
      struct sockaddr_in servaddr;
-    struct hostent *hp;
      int sock, k;
      int tcp_nodelay = 1;

@@ -164,13 +156,9 @@ Connect(const char *hostname, int port)
      sock = socket(AF_INET, SOCK_STREAM, 0);
      assert(sock >= 0);

-    hp = gethostbyname(hostname);
-    assert(hp);
-
      memset(&servaddr, 0, sizeof(servaddr));
      servaddr.sin_family = AF_INET;
      servaddr.sin_port = htons((unsigned short) port);
-    memcpy((char *) &servaddr.sin_addr, hp->h_addr, 
sizeof(servaddr.sin_addr));

      k = connect(sock, (struct sockaddr *) &servaddr, sizeof(servaddr));
      if (k != 0) {
-- 
1.8.2.1



More information about the mesa-dev mailing list