Bug#62990: problems with socket.h and -pedantic
Package: libc6-dev
Version: 2.1.3-8
Receive this error when compiling socket code with -Wall and -pedantic.
Machine is frozen potato updated to unstable woody.
socket.h:226: warning: ANSI C forbids zero-size array `__cmsg_data'
System:
ii libc6 2.1.3-8 GNU C Library: Shared libraries and Timezone
ii libc6-dev 2.1.3-8 GNU C Library: Development Libraries and Hea
ii libg++272 2.7.2.8-0.1 The GNU C++ libraries (libc6 version).
ii gcc 2.95.2-9 The GNU C compiler.
ii libstdc++2.8 2.90.29-2 The GNU stdc++ library (old egcs version)
ii libstdc++2.9 2.91.66-0slink The GNU stdc++ library (egcs version)
Code and Makefile(shar):
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2000-04-24 23:18 EDT by <natedog@ci209036-a>.
# Source directory was `/home/natedog/UK/cs570/hw6'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 600 -rw-r--r-- src/dbgtools.h
# 317 -rw-r--r-- src/Makefile
# 463 -rw-r--r-- src/server.c
# 3921 -rw-r--r-- src/client.c
# 396 -rw-r--r-- src/shareddefs.h
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
if test "$gettext_dir" = FAILED && test -f $dir/gettext \
&& ($dir/gettext --version >/dev/null 2>&1)
then
set `$dir/gettext --version 2>&1`
if test "$3" = GNU
then
gettext_dir=$dir
fi
fi
if test "$locale_dir" = FAILED && test -f $dir/shar \
&& ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
then
locale_dir=`$dir/shar --print-text-domain-dir`
fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
echo=echo
else
TEXTDOMAINDIR=$locale_dir
export TEXTDOMAINDIR
TEXTDOMAIN=sharutils
export TEXTDOMAIN
echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then
shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then
shar_touch='touch -am $3$4$5$6$2 "$8"'
else
shar_touch=:
echo
$echo 'WARNING: not restoring timestamps. Consider getting and'
$echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh14194; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
exit 1
fi
# ============= src/dbgtools.h ==============
if test ! -d 'src'; then
$echo 'x -' 'creating directory' 'src'
mkdir 'src'
fi
if test -f 'src/dbgtools.h' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'src/dbgtools.h' '(file already exists)'
else
$echo 'x -' extracting 'src/dbgtools.h' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'src/dbgtools.h' &&
X
/*************************************************************
X **
X ** dbgtools.h
X **
X ** Nathan Valentine - nrvale0@pop.uky.edu
X ** CS570 Spring 1999
X ** Dr. Manivannan
X **
X *************************************************************/
#ifndef _DBGTOOLS_H_
#define _DBGTOOLS_H_
X
#include <unistd.h>
#include <stdio.h>
X
#ifndef FUNC_UNDEFINED
X
#ifdef _DEBUG_
#define FUNC_UNDEFINED fprintf(stderr, "\n%s has not been implemented!\tFile:\t%s Line:\t%d \n", __FUNCTION__, __FILE__, __LINE__)
#else
#define FUNC_UNDEFINED
#endif /* _DEBUG_ */
X
#endif /* FUNC_UNDEFINED */
X
#endif /* _DBGTOOLS_H_ */
X
SHAR_EOF
(set 20 00 04 24 23 16 10 'src/dbgtools.h'; eval "$shar_touch") &&
chmod 0644 'src/dbgtools.h' ||
$echo 'restore of' 'src/dbgtools.h' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'src/dbgtools.h:' 'MD5 check failed'
c45af6d69e4dc42080675dcfcfc47007 src/dbgtools.h
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'src/dbgtools.h'`"
test 600 -eq "$shar_count" ||
$echo 'src/dbgtools.h:' 'original size' '600,' 'current size' "$shar_count!"
fi
fi
# ============= src/Makefile ==============
if test -f 'src/Makefile' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'src/Makefile' '(file already exists)'
else
$echo 'x -' extracting 'src/Makefile' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'src/Makefile' &&
INCLUDES=
CC=gcc -g -Wall -pedantic -D_DEBUG_
#CC=gcc -g -Wall -D_DEBUG_
LINKS=
X
all: client server
X
client: client.c
X $(CC) $(INCLUDES) $(CFLAGS) $^ -o client $(LINKS)
X
server: server.c
X $(CC) $(INCLUDES) $(CFLAGS) $^ -o server $(LINKS)
X
clean:
X rm -vf a.out
X rm -vf core
X rm -vf *.o
X rm -vf client
X rm -vf server
SHAR_EOF
(set 20 00 04 24 23 16 11 'src/Makefile'; eval "$shar_touch") &&
chmod 0644 'src/Makefile' ||
$echo 'restore of' 'src/Makefile' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'src/Makefile:' 'MD5 check failed'
a6fc8431f5f30833da71bd5604541e10 src/Makefile
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'src/Makefile'`"
test 317 -eq "$shar_count" ||
$echo 'src/Makefile:' 'original size' '317,' 'current size' "$shar_count!"
fi
fi
# ============= src/server.c ==============
if test -f 'src/server.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'src/server.c' '(file already exists)'
else
$echo 'x -' extracting 'src/server.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'src/server.c' &&
/*************************************************************
X **
X ** server.c -
X **
X ** Nathan Valentine - nrvale0@pop.uky.edu
X ** CS570 Spring 1999
X ** Dr. Manivannan
X **
X *************************************************************/
X
#ifdef _DEBUG_
#include "dbgtools.h"
#endif /* _DEBUG_ */
X
#include <stdlib.h>
#include <stdio.h>
X
#include "shareddefs.h"
X
/* static int init(); */
X
int
main(const int argc, const char** argv)
{
X
X return(EXIT_SUCCESS);
}
SHAR_EOF
(set 20 00 04 24 23 16 11 'src/server.c'; eval "$shar_touch") &&
chmod 0644 'src/server.c' ||
$echo 'restore of' 'src/server.c' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'src/server.c:' 'MD5 check failed'
97da3fbfb48d09f1ff0a0acb0d730bf9 src/server.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'src/server.c'`"
test 463 -eq "$shar_count" ||
$echo 'src/server.c:' 'original size' '463,' 'current size' "$shar_count!"
fi
fi
# ============= src/client.c ==============
if test -f 'src/client.c' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'src/client.c' '(file already exists)'
else
$echo 'x -' extracting 'src/client.c' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'src/client.c' &&
/*************************************************************
X **
X ** client.c
X **
X ** Nathan Valentine - nrvale0@pop.uky.edu
X ** CS570 Spring 1999
X ** Dr. Manivannan
X **
X *************************************************************/
X
#ifdef _DEBUG_
#include "dbgtools.h"
#endif /* _DEBUG_ */
X
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
X
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
X
#include "shareddefs.h"
X
/* functions */
static int init(const int, const char**);
static int cleanup();
static void usage();
X
static int server_connect(char*, int);
X
/* globals..so shoot me! ;) */
static int Connxs[MAX_HOSTS];
static char* Hosts[MAX_HOSTS];
static int NumHosts, NumConnxs = 0;
X
/************************************************************
X ** main() -
X *************************************************************/
int
main(const int argc, const char** argv)
{
X
X memset((void *)Connxs, 0, sizeof(int)*MAX_HOSTS);
X memset((void *)Hosts, 0, sizeof(char*)*MAX_HOSTS);
X
X if( 1 >= argc )
X { usage(); goto ERR; };
X
X if( MAX_HOSTS < argc -1 )
X { fprintf(stderr, "Sorry too many hosts specified. Max is %d.\n", MAX_HOSTS); usage(); goto ERR; };
X
X if( -1 == init(argc, argv) )
X { fprintf(stderr, "\nError during intialization! Exiting!\n"); goto ERR; };
X
X cleanup();
X return(EXIT_SUCCESS);
X ERR:
X cleanup();
X return(EXIT_FAILURE);
}
X
/************************************************************
X ** init() - do same basic setup
X *************************************************************/
static int
init( const int argc, const char** argv)
{
X int i= 0;
X
X /* get the list of hosts */
X NumHosts = argc -1;
X for( i = 0; i < NumHosts; i++ )
X {
X if( NULL == ( Hosts[i] = (char *)malloc(strlen(argv[i+1])+1) ) )
X { fprintf(stderr, "Allocating memory for hostname:\t%s\n", argv[i+1]); goto ERR; };
X (void *)strncpy(Hosts[i], argv[i+1], strlen(argv[i+1]));
X printf("Adding server:\t%s\n", Hosts[i]);
X };
X
X /* make a connection to each host and stort the fdes in the Connxs array */
X for( i = 0; i < NumHosts; i++ )
X {
X if( -1 == (Connxs[i] = server_connect(Hosts[i], PORT)) )
X { fprintf(stderr, "Error connecting to %s\n", Hosts[i]); goto ERR; };
X NumConnxs++;
X };
X
X return(1);
X ERR:
X return(-1);
}
X
/************************************************************
X ** server_connect() - connect to server
X *************************************************************/
static int
server_connect(char* hostname, int port)
{
X int sock = -1;
X struct sockaddr_in server;
X struct hostent *host_info = NULL;
X
X if( -1 == (sock = socket(AF_INET, SOCK_STREAM,0)) )
X { perror("Creating socket"); goto ERR; };
X if( NULL == (host_info = gethostbyname(hostname)) )
X { perror("Looking up hostname"); goto ERR; };
X
X server.sin_family = AF_INET;
X server.sin_port = htons(port);
X memcpy(&server.sin_addr,host_info->h_addr,host_info->h_length);
X
X if( -1 == connect(sock, (struct sockaddr *)&server, sizeof (struct sockaddr_in)) )
X { perror("Connecting"); goto ERR; };
X
X return(sock);
X ERR:
X return(-1);
}
X
/************************************************************
X ** cleanup() - cleanup before exit
X *************************************************************/
static int
cleanup()
{
X
X int i = 0;
X
X /* free the mem for all of the host names and close open fdes */
X for( i = 0; i < NumHosts; i++ )
X {
X if( NULL != Hosts[i] )
X free(Hosts[i]);
X if( -1 == close(Connxs[i]) )
X fprintf(stderr, "Error closing socket to Connx[%d]. Continuing...\n", i);
X };
X
X return(1);
/* ERR: */
/* return(-1); */
}
X
/************************************************************
X ** cleanup() - cleanup before exit
X *************************************************************/
static void
usage()
{
X fprintf(stderr,"\n");
X fprintf(stderr, "client usage:\n\n");
X fprintf(stderr, "\tclient <server hostname>+\n");
X fprintf(stderr,"\n\n");
}
SHAR_EOF
(set 20 00 04 24 23 16 11 'src/client.c'; eval "$shar_touch") &&
chmod 0644 'src/client.c' ||
$echo 'restore of' 'src/client.c' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'src/client.c:' 'MD5 check failed'
eb82111bdc645ed2903924182a7fe1b8 src/client.c
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'src/client.c'`"
test 3921 -eq "$shar_count" ||
$echo 'src/client.c:' 'original size' '3921,' 'current size' "$shar_count!"
fi
fi
# ============= src/shareddefs.h ==============
if test -f 'src/shareddefs.h' && test "$first_param" != -c; then
$echo 'x -' SKIPPING 'src/shareddefs.h' '(file already exists)'
else
$echo 'x -' extracting 'src/shareddefs.h' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'src/shareddefs.h' &&
/*************************************************************
X **
X ** shareddefs.h - stuff that both the client and server need.
X **
X ** Nathan Valentine - nrvale0@pop.uky.edu
X ** CS570 Spring 1999
X ** Dr. Manivannan
X **
X *************************************************************/
X
#ifndef _SHAREDDEFS_
#define _SHAREDDEFS_
X
#define MAX_HOSTS 10
#define PORT 3434
X
#endif /* _SHAREDDEFS_ */
SHAR_EOF
(set 20 00 04 24 23 16 11 'src/shareddefs.h'; eval "$shar_touch") &&
chmod 0644 'src/shareddefs.h' ||
$echo 'restore of' 'src/shareddefs.h' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'src/shareddefs.h:' 'MD5 check failed'
545696c7f0aa6bb361406a37c5189216 src/shareddefs.h
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'src/shareddefs.h'`"
test 396 -eq "$shar_count" ||
$echo 'src/shareddefs.h:' 'original size' '396,' 'current size' "$shar_count!"
fi
fi
rm -fr _sh14194
exit 0
:
--
Nathan Valentine - nrvale0@pop.uky.edu AIM: NRVesKY ICQ: 39023424
U. of Ky Linux Users Group - http://www.uky.edu/StudentOrgs/UKLUG
Punning is the worst vice, and there's no vice versa. - Unknown
Reply to: