Bug 33506

Summary: inet.h incomplete type
Product: Ports & Packages Reporter: George Genovezos <ggenovez>
Component: Individual Port(s)Assignee: Ade Lovett <ade>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description George Genovezos 2002-01-03 06:50:00 UTC
Constatly getting errors with gcc 2.8 2.9 & 30 errors are listed below

/usr/include/arpa/inet.h:89: warning: parameter has incomplete type
/usr/include/arpa/inet.h:92: warning: parameter has incomplete type
/usr/include/arpa/inet.h:96: warning: parameter has incomplete type

These errors do not occure with my lynux box (bleah). Source was take out of a Unix programming book.

How-To-Repeat:       #include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <arpa/inet.h>
#include "safecalls.h"

#define PROTOCOL "tcp"
#define REQUEST "GET / HTTP/1.0\n\n"

int write_buffer(int fd, const void *buf, int count);

int main(int argc, char *argv[]) {
  int sockid;
  struct servent *serviceaddr;
  struct hostent *hostaddr;
  struct protoent *protocol;
  struct sockaddr_in *sockaddr;
  char buffer[1024];
  int count;

  /******** Step 1: resolve names and generate the socket structure. */

  /* First, initialize the socketaddr. */
  bzero((char *) &sockaddr, sizeof(sockaddr));
  sockaddr.sin_family = AF_INET;

  /* Resolve the service name. */

  serviceaddr = getservbyname(argv[2], PROTOCOL);
  if (!serviceaddr) {
    HandleError(0, "getservbyname", "service resolution failed");
  }
  sockaddr.sin_port = serviceaddr->s_port;

  /* Resolve the host name. */

  hostaddr = gethostbyname(argv[1]);
  if (!hostaddr) {
    HandleError(0, "gethostbyname", "host resolution failed");
  }

  memcpy(&sockaddr.sin_addr, hostaddr->h_addr, hostaddr->h_length);

  /* Resolve the protocol name. */

  protocol = getprotobyname(PROTOCOL);
  if (!protocol) {
    HandleError(0, "getprotobyname", "protocol resolution failed");
  }
  /* Note: using SOCK_STREAM below since this is only TCP. */

  /********* Step 2: Create the socket for this end. */

  sockid = socket(PF_INET, SOCK_STREAM, protocol->p_proto);
  if (sockid < 0) {
    HandleError(errno, "socket", "couldn't create socket");
  }

  /********* Step 3: Connect the socket to the server.  (Almost done!) */

  if (connect(sockid, &sockaddr, sizeof(sockaddr)) < 0) {
    HandleError(errno, "connect", "connect call failed");
  }

  /********************************************************************/

  /* The channel for communication to the server has now been established.
     Now, request the document at the server root. */

  write_buffer(sockid, REQUEST, strlen(REQUEST));
 
  /* Request has been sent.  Read the result. */
 
  while ((count = saferead(sockid, buffer, sizeof(buffer) - 1))) {
    write_buffer(1, buffer, count);
  }
 
  return 0;
}
 
int write_buffer(int fd, const void *buf, int count) {
  const void *pts = buf;
  int  status = 0, n;
 
  if (count < 0) return (-1);
 
  while (status != count) {
    n = safewrite(fd, pts+status, count-status);
    if (n < 0) return (n);
    status += n;
  }
  return (status);
}
Comment 1 Alan Eldridge 2002-01-03 06:55:53 UTC
On Wed, Jan 02, 2002 at 10:44:29PM -0800, George Genovezos wrote:
>
>>Description:
>Constatly getting errors with gcc 2.8 2.9 & 30 errors are listed below
>
>/usr/include/arpa/inet.h:89: warning: parameter has incomplete type
>/usr/include/arpa/inet.h:92: warning: parameter has incomplete type
>/usr/include/arpa/inet.h:96: warning: parameter has incomplete type
>
>These errors do not occure with my lynux box (bleah). Source was take out of a Unix programming book.

George, I've run into this problem as well; guess I should track it down.
I'll follow up in a day or two.

-- 
Alan Eldridge
Pmmfmffmmfmp mmmpppppffmpmfpmpppff $PffMmmPppMpmPpfPpm mfpmmmmmfpmpmpppff.
Comment 2 Joe Marcus Clarke 2002-01-03 07:38:35 UTC
You need to add:

#include <netinet/in.h>

to the list of includes in the right order:

#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <netinet/in.h> /* LOOK HERE! */
#include <arpa/inet.h>
#include "safecalls.h"

Then that error will go away, but you'll have to fix the other problems 
before it will compile.

Joe
Comment 3 Ade Lovett freebsd_committer freebsd_triage 2002-03-12 03:09:34 UTC
State Changed
From-To: open->closed

Nothing to do with the ports/ system. 


Comment 4 Ade Lovett freebsd_committer freebsd_triage 2002-03-12 03:09:34 UTC
Responsible Changed
From-To: freebsd-ports->ade