Unix-Network-Programming icon indicating copy to clipboard operation
Unix-Network-Programming copied to clipboard

inet_ntop() -- error: argument 'size' doesn't match prototype

Open rahulrajaram opened this issue 6 years ago • 1 comments

Hi,

Thanks for hosting this project. I have found a problem in the following step.

cd libfree
make

It looks like this definition of inet_ntop conflicts with the prototype here. Specifically, the fourth parameter, size, which is of type size_t in libfree/inet_ntop.c, should actually be socklen_t.

I have verified that libfree/ complies after making the change.

Thanks, Rahul.

rahulrajaram avatar Dec 16 '18 19:12 rahulrajaram

Hi, Also have i found that problem, but how to solve them? What's more, after i've changed the type of parameter size to socklen_t, there are other problems, uninitialized variable before used.

gcc -I../lib -g -O2 -D_REENTRANT -Wall   -c -o inet_ntop.o inet_ntop.c
/usr/include/arpa/inet.h: In function ‘inet_ntop’:
inet_ntop.c:153:23: warning: ‘best.len’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (best.base == -1 || cur.len > best.len)
       ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
inet_ntop.c:124:28: note: ‘best.len’ was declared here
  struct { int base, len; } best, cur;
                            ^~~~
gcc -I../lib -g -O2 -D_REENTRANT -Wall   -c -o inet_pton.o inet_pton.c
ar rv ../libunp.a in_cksum.o inet_ntop.o inet_pton.o
a - in_cksum.o
a - inet_ntop.o
a - inet_pton.o
ranlib ../libunp.a

MagicZer0 avatar May 06 '19 03:05 MagicZer0