25 Sep, 2013, JohnnyStarr wrote in the 1st comment:
Votes: 0
I'm getting the following warnings in init_descriptor() in comm.c

I have had quite a few complaints from GCC but I've been able to clean everything up until now.
Here is the output I'm getting:

comm.c: In function init_descriptor:
comm.c:933:35: warning: passing argument 3 of getsockname from incompatible pointer type [enabled by default]
/usr/include/x86_64-linux-gnu/sys/socket.h:119:12: note: expected socklen_t * __restrict__ but argument is of type size_t *
comm.c:934:42: warning: passing argument 3 of accept from incompatible pointer type [enabled by default]
/usr/include/x86_64-linux-gnu/sys/socket.h:214:12: note: expected socklen_t * __restrict__ but argument is of type size_t *
comm.c:970:36: warning: passing argument 3 of getpeername from incompatible pointer type [enabled by default]
/usr/include/x86_64-linux-gnu/sys/socket.h:133:12: note: expected socklen_t * __restrict__ but argument is of type size_t *


For convenience, here is the init_descriptor() function in full. I have also commented the line numbers that are throwing the warnings.

Any help here would be appreciated. Thanks.

#if defined(unix)

void init_descriptor (int control)
{
char buf[MAX_STRING_LENGTH];
DESCRIPTOR_DATA *dnew;
struct sockaddr_in sock;
struct hostent *from;
size_t desc, size;

size = sizeof (sock);
getsockname (control, (struct sockaddr *) &sock, &size); // ========== LN: 933
if ((desc = accept (control, (struct sockaddr *) &sock, &size)) < 0) // ========== LN: 934
{
perror ("New_descriptor: accept");
return;
}

#if !defined(FNDELAY)
#define FNDELAY O_NDELAY
#endif

if (fcntl (desc, F_SETFL, FNDELAY) == -1)
{
perror ("New_descriptor: fcntl: FNDELAY");
return;
}

/*
* Cons a new descriptor.
*/
dnew = new_descriptor ();

dnew->descriptor = desc;
if (!mud_ansiprompt)
dnew->connected = CON_GET_NAME;
else
dnew->connected = CON_ANSI;
dnew->ansi = mud_ansicolor;
dnew->showstr_head = NULL;
dnew->showstr_point = NULL;
dnew->outsize = 2000;
dnew->pEdit = NULL; /* OLC */
dnew->pString = NULL; /* OLC */
dnew->editor = 0; /* OLC */
dnew->outbuf = alloc_mem (dnew->outsize);

size = sizeof (sock);
if (getpeername (desc, (struct sockaddr *) &sock, &size) < 0) // ========== LN: 970
{
perror ("New_descriptor: getpeername");
dnew->host = str_dup ("(unknown)");
}
else
{
/*
* Would be nice to use inet_ntoa here but it takes a struct arg,
* which ain't very compatible between gcc and system libraries.
*/
int addr;

addr = ntohl (sock.sin_addr.s_addr);
sprintf (buf, "%d.%d.%d.%d",
(addr >> 24) & 0xFF, (addr >> 16) & 0xFF,
(addr >> 8) & 0xFF, (addr) & 0xFF);
sprintf (log_buf, "Sock.sinaddr: %s", buf);
log_string (log_buf);
from = gethostbyaddr ((char *) &sock.sin_addr,
sizeof (sock.sin_addr), AF_INET);
dnew->host = str_dup (from ? from->h_name : buf);
}

/*
* Swiftest: I added the following to ban sites. I don't
* endorse banning of sites, but Copper has few descriptors now
* and some people from certain sites keep abusing access by
* using automated 'autodialers' and leaving connections hanging.
*
* Furey: added suffix check by request of Nickel of HiddenWorlds.
*/
if (check_ban (dnew->host, BAN_ALL))
{
write_to_descriptor (desc,
"Your site has been banned from this mud.\n\r",
0);
close (desc);
free_descriptor (dnew);
return;
}
/*
* Init descriptor data.
*/
dnew->next = descriptor_list;
descriptor_list = dnew;

/*
* First Contact!
*/
if (!mud_ansiprompt)
{
extern char * help_greeting;
if ( help_greeting[0] == '.' )
send_to_desc ( help_greeting+1, dnew );
else
send_to_desc ( help_greeting , dnew );
}
else
send_to_desc ("Do you want ANSI? (Y/n) ", dnew);

return;
}
#endif
25 Sep, 2013, Zeno wrote in the 2nd comment:
Votes: 0
http://www.mudbytes.net/index.php?a=topi...

See below and page 2, I think.
25 Sep, 2013, JohnnyStarr wrote in the 3rd comment:
Votes: 0
Cool, thanks!
0.0/3