[AP-UTILS] patch to fix compile-time errors in ap-utils-0.9.5-2002050602

Erik Rossen rossen@freesurf.ch
Fri, 10 May 2002 21:51:41 +0200


--uQr8t48UFsdbeI+V
Content-Type: multipart/mixed; boundary="ZPt4rx8FFjLCG7dd"
Content-Disposition: inline


--ZPt4rx8FFjLCG7dd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Here are my first patches.

When I tried compiling ap-utils-0.9.5-2002050602 on my Debian woody systems
(both i386 and sparc), I got the following errors and warnings.

#1 and #2 were fatal, #3 is just pickiness from a missing type cast.  What I
don't understand is why errors #1 and #2 occurred.  They seem to come from
local variable declarations that occur in the middle of functions.  I thoug=
ht
that was perfectly legal C, but my version of gcc does not like it.  Has an=
yone
else had similar problems?  Anyway, the code compiled cleanly after I moved=
 the
declarations to the beginning of the code block of the functions.

I have attached the patches I made that let the system compile cleanly.

Roman:  How often will you be posting updated tarballs?  What is your work
schedule like?  Should we be sending small patches that fix one problem at a
time or big patches that include every improvement that we have made?  I ha=
ve a
temporary fix for the ncurses redisplay problem that is worth adding as soo=
n as
possible, but I have not included it in this patch.

Error report #1:
----------------

rossen@grape:~/ap-utils-0.9.5-2002050602$ make
make -C common
make[1]: Entering directory `/home/rossen/ap-utils-0.9.5-2002050602/common'
gcc -O1 -I../common -Wall   -c -o snmp.o snmp.c
gcc -O1 -I../common -Wall   -c -o common.o common.c
common.c: In function `auth':
common.c:138: parse error before `int'
common.c:141: `home_dir' undeclared (first use in this function)
common.c:141: (Each undeclared identifier is reported only once
common.c:141: for each function it appears in.)
common.c:142: `ap_type' undeclared (first use in this function)
common.c:143: `fd' undeclared (first use in this function)
make[1]: *** [common.o] Error 1
make[1]: Leaving directory `/home/rossen/ap-utils-0.9.5-2002050602/common'
make: *** [all] Error 2


Error report #2:
----------------

gcc -O2 -I../common -Wall   -c -o ap-search.o ap-search.c
ap-search.c: In function `main':
ap-search.c:66: parse error before `struct'
ap-search.c:48: warning: unused variable `i'
ap-search.c:47: warning: unused variable `varbinds'
ap-search.c:42: warning: unused variable `reply'
ap-search.c:38: warning: unused variable `Wireless'
ap-search.c:68: warning: control reaches end of non-void function
ap-search.c: At top level:
ap-search.c:68: warning: type defaults to `int' in declaration of `opts'
ap-search.c:68: warning: data definition has no type or storage class
ap-search.c:69: parse error before `if'
ap-search.c:72: parse error before `.'
ap-search.c:73: parse error before `.'
ap-search.c:74: parse error before `.'
ap-search.c:75: parse error before `.'
ap-search.c:76: parse error before `.'
ap-search.c:82: warning: type defaults to `int' in declaration of `close'
ap-search.c:82: warning: parameter names (without types) in function declar=
ation
ap-search.c:82: warning: data definition has no type or storage class
ap-search.c:83: parse error before `for'
make[1]: *** [ap-search.o] Error 1
make[1]: Leaving directory `/home/rossen/ap-utils-0.9.5-2002050602/mrtg'
make: *** [all] Error 2

Error report #3:
----------------

gcc -O2 -I../common -Wall ap-trapd.c -o ap-trapd
ap-trapd.c: In function `main':
ap-trapd.c:87: warning: passing arg 5 of `recvfrom' from incompatible point=
er type
make[1]: Leaving directory `/home/rossen/ap-utils-0.9.5-2002050602/trapd'

--=20
Erik Rossen                         ^    OpenPGP key: 2935D0B9
rossen@freesurf.ch                 /e\   "Use GnuPG, see the
http://www.multimania.com/rossen   ---    black helicopters."

--ZPt4rx8FFjLCG7dd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="patch.ER1.txt"
Content-Transfer-Encoding: quoted-printable

diff -ur ap-utils-0.9.5-2002050602/common/common.c ap-utils-0.9.5-ER1/commo=
n/common.c
--- ap-utils-0.9.5-2002050602/common/common.c	Mon May  6 00:11:58 2002
+++ ap-utils-0.9.5-ER1/common/common.c	Fri May 10 21:22:07 2002
@@ -86,6 +86,9 @@
     int i;
     struct sockaddr_in client =3D { AF_INET, INADDR_ANY, {INADDR_ANY} };
     unsigned char message[32];
+    int fd;
+    extern char *ap_type;
+    char *home_dir;
=20
     noecho();
     curs_set(0);
@@ -135,9 +138,6 @@
 	goto exit;
     }
    =20
-   int fd;
-    extern char *ap_type;
-    char *home_dir;
     if ((home_dir =3D getenv("HOME"))) {
             sprintf(message, "%s/.ap-%s", home_dir, ap_type);
             if ((fd =3D open(message, O_CREAT|O_TRUNC|O_WRONLY, 0600)) !=
=3D -1 ) {
diff -ur ap-utils-0.9.5-2002050602/mrtg/ap-search.c ap-utils-0.9.5-ER1/mrtg=
/ap-search.c
--- ap-utils-0.9.5-2002050602/mrtg/ap-search.c	Mon May  6 15:04:26 2002
+++ ap-utils-0.9.5-ER1/mrtg/ap-search.c	Fri May 10 21:23:31 2002
@@ -49,6 +49,10 @@
=20
     struct sockaddr_in client =3D { AF_INET, INADDR_ANY, {INADDR_ANY} };
=20
+    struct sopts {
+	int broad;
+    } opts =3D { 1 };
+
     community =3D comm;
     if (inet_aton("255.255.255.255", &ap_ip) =3D=3D 0) {
 	printf("Invalid IP-address\n");
@@ -63,9 +67,6 @@
 	perror("Bind socket error");
 	return 1;
     }
-    struct sopts {
-	int broad;
-    } opts =3D { 1 };
     if (setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &opts, sizeof(struct =
sopts)) =3D=3D -1)
 	perror("");
=20
diff -ur ap-utils-0.9.5-2002050602/trapd/ap-trapd.c ap-utils-0.9.5-ER1/trap=
d/ap-trapd.c
--- ap-utils-0.9.5-2002050602/trapd/ap-trapd.c	Sat May  4 21:55:34 2002
+++ ap-utils-0.9.5-ER1/trapd/ap-trapd.c	Fri May 10 21:26:49 2002
@@ -84,7 +84,7 @@
     }
=20
     while (1) {
-	if ((len =3D recvfrom(sockfd, buf, 512, 0, &client, &client_len)) =3D=3D
+	if ((len =3D recvfrom(sockfd, buf, 512, 0, (struct sockaddr *) &client, &=
client_len)) =3D=3D
 	    -1) continue;
 	if (buf[0] !=3D ASN_HEADER) {
 	    continue;

--ZPt4rx8FFjLCG7dd--

--uQr8t48UFsdbeI+V
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE83CTNY88aPik10LkRAnzNAKCTPCtSXSAQujy9ejG/0WfDHmP65ACeINyJ
fPj5K/CWFiNXMU5skJWrmSg=
=QISO
-----END PGP SIGNATURE-----

--uQr8t48UFsdbeI+V--