Fix up a bunch of clang warnings and errors. This includes some bug fixes, because clang found a couple things that were decidedly wrong/broken; therefore PKGREVISION -> 3. This package has too many patches (it only looks like a moderate number compared to xview) and many/most of them should be rolled into a jumbo patch and posted as a distfile. One of these years...diff -r1.12 -r1.13 pkgsrc/x11/xmx/Makefile
(dholland)
@@ -1,18 +1,18 @@ | @@ -1,18 +1,18 @@ | |||
1 | # $NetBSD: Makefile,v 1.12 2011/06/19 09:30:49 alnsn Exp $ | 1 | # $NetBSD: Makefile,v 1.13 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | DISTNAME= xmx-2.1alpha.pl7 | 3 | DISTNAME= xmx-2.1alpha.pl7 | |
4 | PKGNAME= xmx-2.1a7 | 4 | PKGNAME= xmx-2.1a7 | |
5 | PKGREVISION= 2 | 5 | PKGREVISION= 3 | |
6 | CATEGORIES= x11 | 6 | CATEGORIES= x11 | |
7 | MASTER_SITES= ftp://ftp.cs.brown.edu/pub/xmx/ | 7 | MASTER_SITES= ftp://ftp.cs.brown.edu/pub/xmx/ | |
8 | 8 | |||
9 | MAINTAINER= pkgsrc-users@NetBSD.org | 9 | MAINTAINER= pkgsrc-users@NetBSD.org | |
10 | HOMEPAGE= http://www.cs.brown.edu/software/xmx/ | 10 | HOMEPAGE= http://www.cs.brown.edu/software/xmx/ | |
11 | COMMENT= X11 Protocol Multiplexor | 11 | COMMENT= X11 Protocol Multiplexor | |
12 | 12 | |||
13 | PKG_DESTDIR_SUPPORT= user-destdir | 13 | PKG_DESTDIR_SUPPORT= user-destdir | |
14 | 14 | |||
15 | MAKE_JOBS_SAFE= no | 15 | MAKE_JOBS_SAFE= no | |
16 | USE_IMAKE= yes | 16 | USE_IMAKE= yes | |
17 | 17 | |||
18 | .include "../../mk/bsd.prefs.mk" | 18 | .include "../../mk/bsd.prefs.mk" |
@@ -1,32 +1,32 @@ | @@ -1,32 +1,32 @@ | |||
1 | $NetBSD: distinfo,v 1.6 2011/07/03 20:15:58 dholland Exp $ | 1 | $NetBSD: distinfo,v 1.7 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | SHA1 (xmx-2.1alpha.pl7.tar.gz) = b517b20a7bfa352b12ffb7dd260d50ea6c1ec21b | 3 | SHA1 (xmx-2.1alpha.pl7.tar.gz) = b517b20a7bfa352b12ffb7dd260d50ea6c1ec21b | |
4 | RMD160 (xmx-2.1alpha.pl7.tar.gz) = 18560824a35ffc55ce90fa63d1894362afa45405 | 4 | RMD160 (xmx-2.1alpha.pl7.tar.gz) = 18560824a35ffc55ce90fa63d1894362afa45405 | |
5 | Size (xmx-2.1alpha.pl7.tar.gz) = 498352 bytes | 5 | Size (xmx-2.1alpha.pl7.tar.gz) = 498352 bytes | |
6 | SHA1 (patch-aa) = 029b20a8630ccf99cfb95381414671d5963cd49b | 6 | SHA1 (patch-aa) = 029b20a8630ccf99cfb95381414671d5963cd49b | |
7 | SHA1 (patch-ab) = cca7e590b5432e5fed68658ff10dd21981c0aed7 | 7 | SHA1 (patch-ab) = 542962f3f21d39ddbb8ac585934fa7ced1c7d3dd | |
8 | SHA1 (patch-ac) = 2b5ecb1f621d86ff00637a7e8070b6419354a8f4 | 8 | SHA1 (patch-ac) = 720dc25a7b45534967c3ce3363d443d949525ea6 | |
9 | SHA1 (patch-ad) = 0a61fcd53dcc23cac02588a750dec829ac554376 | 9 | SHA1 (patch-ad) = 0a61fcd53dcc23cac02588a750dec829ac554376 | |
10 | SHA1 (patch-ae) = 50bb4842042e9297484c6bb8986212e82d84dbd4 | 10 | SHA1 (patch-ae) = 29a67d85c02e74e8850f4b58e8c28d5332b29b95 | |
11 | SHA1 (patch-af) = f495e95579f2d4c0f6f97b5933f1f420992a3968 | 11 | SHA1 (patch-af) = f495e95579f2d4c0f6f97b5933f1f420992a3968 | |
12 | SHA1 (patch-ag) = ec6d1d0a6e0a96c7b40f86763b04e32e74a8f6ef | 12 | SHA1 (patch-ag) = 9f20298dbccee1c4acfd7495bdf86a62bc9a665d | |
13 | SHA1 (patch-ah) = 913a8b122e570c1f105761ee83889e09d2e3e8dd | 13 | SHA1 (patch-ah) = 66bbff2795d877ce9557c1819a12bba6e9e09974 | |
14 | SHA1 (patch-ai) = 19ca5fa6a18639df41dbd6d6bce275a64293e3b5 | 14 | SHA1 (patch-ai) = 19ca5fa6a18639df41dbd6d6bce275a64293e3b5 | |
15 | SHA1 (patch-aj) = da1ce04aa5b4c0701686bd1295880c9774634f63 | 15 | SHA1 (patch-aj) = da1ce04aa5b4c0701686bd1295880c9774634f63 | |
16 | SHA1 (patch-ak) = 52080a7d9ffc0c614e998a76733cace6c29234e7 | 16 | SHA1 (patch-ak) = 52080a7d9ffc0c614e998a76733cace6c29234e7 | |
17 | SHA1 (patch-al) = 905f48024c4101a6678a036566684c4c8ecd858e | 17 | SHA1 (patch-al) = 905f48024c4101a6678a036566684c4c8ecd858e | |
18 | SHA1 (patch-am) = 4f6b01d9d3c843af850ff79acd21be3aa0b6f5e5 | 18 | SHA1 (patch-am) = 4f6b01d9d3c843af850ff79acd21be3aa0b6f5e5 | |
19 | SHA1 (patch-ba) = ef2aae029305f9b5fa975805622466db418f197d | 19 | SHA1 (patch-ba) = e7f905a5fcd776eb417c3a592f674264ff97716d | |
20 | SHA1 (patch-bb) = 595b93c221294fa5c61753c944acdf0f06d28748 | 20 | SHA1 (patch-bb) = 595b93c221294fa5c61753c944acdf0f06d28748 | |
21 | SHA1 (patch-bc) = 95653bf85c440158fe332cf114b3af22ffef5980 | 21 | SHA1 (patch-bc) = 95653bf85c440158fe332cf114b3af22ffef5980 | |
22 | SHA1 (patch-bd) = 37db161da309dd0178756d17be1c5b87c91a8f4b | 22 | SHA1 (patch-bd) = 37db161da309dd0178756d17be1c5b87c91a8f4b | |
23 | SHA1 (patch-be) = 7a4e8fe2e5a0a47a0cef4cfe7f0227be985fdd33 | 23 | SHA1 (patch-be) = 7a4e8fe2e5a0a47a0cef4cfe7f0227be985fdd33 | |
24 | SHA1 (patch-bf) = 5320d394fbd71fb1b03032c49b0f19cf3e330be7 | 24 | SHA1 (patch-bf) = 5320d394fbd71fb1b03032c49b0f19cf3e330be7 | |
25 | SHA1 (patch-bg) = b7807809e2860274158d908482e702078fed3f85 | 25 | SHA1 (patch-bg) = b7807809e2860274158d908482e702078fed3f85 | |
26 | SHA1 (patch-bh) = d2ad6793cf458957029bc17a457ab7b21a7d4957 | 26 | SHA1 (patch-bh) = d2ad6793cf458957029bc17a457ab7b21a7d4957 | |
27 | SHA1 (patch-bi) = e9ee7b76c15cf0b1a8579426988d3878b115db57 | 27 | SHA1 (patch-bi) = e9ee7b76c15cf0b1a8579426988d3878b115db57 | |
28 | SHA1 (patch-bj) = f907b9c16e4c447dbc59723238eb0e05d511be05 | 28 | SHA1 (patch-bj) = f907b9c16e4c447dbc59723238eb0e05d511be05 | |
29 | SHA1 (patch-bk) = 6995b1743b59ce4d6e62827832d66916e5c74632 | 29 | SHA1 (patch-bk) = 6995b1743b59ce4d6e62827832d66916e5c74632 | |
30 | SHA1 (patch-bl) = c6ff8f66385c8982c4831e5abef3f26980302d42 | 30 | SHA1 (patch-bl) = c6ff8f66385c8982c4831e5abef3f26980302d42 | |
31 | SHA1 (patch-bm) = 2e13b0695ac77ef9c305b79682b25a8b0c51d49a | 31 | SHA1 (patch-bm) = 2e13b0695ac77ef9c305b79682b25a8b0c51d49a | |
32 | SHA1 (patch-bn) = 7afce6231f8bf26da03bccec1a2a870528a99460 | 32 | SHA1 (patch-bn) = 7afce6231f8bf26da03bccec1a2a870528a99460 | |
@@ -72,17 +72,18 @@ SHA1 (patch-da) = ffc505a7ce98a42a30e18d | @@ -72,17 +72,18 @@ SHA1 (patch-da) = ffc505a7ce98a42a30e18d | |||
72 | SHA1 (patch-db) = 5011c2224e1d9048672bd51f68ef197e593ef5d3 | 72 | SHA1 (patch-db) = 5011c2224e1d9048672bd51f68ef197e593ef5d3 | |
73 | SHA1 (patch-dc) = dc69f4c20d6a98abaedf76fd0bff1548ac4f0ba5 | 73 | SHA1 (patch-dc) = dc69f4c20d6a98abaedf76fd0bff1548ac4f0ba5 | |
74 | SHA1 (patch-dd) = a90a26457089ac0b34558977bfd63d47c52f2632 | 74 | SHA1 (patch-dd) = a90a26457089ac0b34558977bfd63d47c52f2632 | |
75 | SHA1 (patch-de) = d42d1dc6aac51f30009c5311f9a7976627062053 | 75 | SHA1 (patch-de) = d42d1dc6aac51f30009c5311f9a7976627062053 | |
76 | SHA1 (patch-df) = a443d061ab3858353b09be89362f4179e35f9635 | 76 | SHA1 (patch-df) = a443d061ab3858353b09be89362f4179e35f9635 | |
77 | SHA1 (patch-dg) = 9c02cf84a4a9ab14288437795dd0196c432ee2a8 | 77 | SHA1 (patch-dg) = 9c02cf84a4a9ab14288437795dd0196c432ee2a8 | |
78 | SHA1 (patch-dh) = a86ccf3c41e16661c5bfc84ceff48ac89702e615 | 78 | SHA1 (patch-dh) = a86ccf3c41e16661c5bfc84ceff48ac89702e615 | |
79 | SHA1 (patch-di) = c86c82837ca1b6c30696f2e95ad69b78ef8dcd98 | 79 | SHA1 (patch-di) = c86c82837ca1b6c30696f2e95ad69b78ef8dcd98 | |
80 | SHA1 (patch-dj) = 1fa9a07981c7d40df912702707052a163da28f53 | 80 | SHA1 (patch-dj) = 1fa9a07981c7d40df912702707052a163da28f53 | |
81 | SHA1 (patch-dk) = 6934d373b18fa2558156fc91c160d4e54fda6f07 | 81 | SHA1 (patch-dk) = 6934d373b18fa2558156fc91c160d4e54fda6f07 | |
82 | SHA1 (patch-ea) = 4fc96cc0846af3c465205f7c428a453185f15b0d | 82 | SHA1 (patch-ea) = 4fc96cc0846af3c465205f7c428a453185f15b0d | |
83 | SHA1 (patch-eb) = 66c4b8b6b3fed8c431cfb60ce6d52a9d0805ca5f | 83 | SHA1 (patch-eb) = 66c4b8b6b3fed8c431cfb60ce6d52a9d0805ca5f | |
84 | SHA1 (patch-ec) = 9ce390570b6144471dc02fffdb0bd5ff714bddf0 | 84 | SHA1 (patch-ec) = 9ce390570b6144471dc02fffdb0bd5ff714bddf0 | |
85 | SHA1 (patch-ed) = e200f4b965fbfdb16fa4554028772cbf2693b2d0 | 85 | SHA1 (patch-ed) = 4637d40b1a149ab062f8c57730c89eb98e6b0ba1 | |
86 | SHA1 (patch-ee) = 9a22f1d7312e21c07c12dbbe308b492606ff1343 | 86 | SHA1 (patch-ee) = 9a22f1d7312e21c07c12dbbe308b492606ff1343 | |
87 | SHA1 (patch-ef) = 2b0bf5a3bb2fc25ed545d082cdf724cb0e627f8a | 87 | SHA1 (patch-ef) = b6a6e4fefc075900a7b700e548f17f9ac1e228fc | |
88 | SHA1 (patch-eg) = fffaaddaf67708b90c44b76ac4b9a301ffef6530 | 88 | SHA1 (patch-eg) = fffaaddaf67708b90c44b76ac4b9a301ffef6530 | |
89 | SHA1 (patch-eh) = 5ab3f93b24cdbe0cb8f5b8be9b0da22bb1ba98a5 |
@@ -1,15 +1,89 @@ | @@ -1,15 +1,89 @@ | |||
1 | $NetBSD: patch-ab,v 1.2 2011/07/03 20:15:58 dholland Exp $ | 1 | $NetBSD: patch-ab,v 1.3 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | - use modern C | 3 | - use modern C | |
4 | - use isdigit() correctly | |||
5 | - silence warnings about assignments within if conditions | |||
6 | - fix parenthesization, caught by clang | |||
4 | 7 | |||
5 | --- lib/Xmc/common.c~ 1998-04-01 18:51:21.000000000 -0500 | 8 | --- lib/Xmc/common.c.orig 1998-04-01 23:51:21.000000000 +0000 | |
6 | +++ lib/Xmc/common.c 2008-08-31 00:16:29.000000000 -0400 | 9 | +++ lib/Xmc/common.c | |
7 | @@ -27,6 +27,8 @@ | 10 | @@ -27,8 +27,14 @@ | |
8 | #include <sys/select.h> | 11 | #include <sys/select.h> | |
9 | #endif | 12 | #endif | |
10 | #include <sys/socket.h> | 13 | #include <sys/socket.h> | |
14 | +#include <stdio.h> | |||
11 | +#include <stdlib.h> | 15 | +#include <stdlib.h> | |
12 | +#include <string.h> | 16 | +#include <string.h> | |
17 | +#include <unistd.h> | |||
18 | +#include <ctype.h> | |||
13 | #include <errno.h> | 19 | #include <errno.h> | |
14 | #include <netdb.h> | 20 | #include <netdb.h> | |
21 | +#include <arpa/inet.h> | |||
15 | #include <xmc.h> | 22 | #include <xmc.h> | |
23 | #include <xmclib.h> | |||
24 | #include <xmcp.h> | |||
25 | @@ -103,7 +109,7 @@ Xmc_event_shift | |||
26 | { | |||
27 | XmcEventList *elp; | |||
28 | ||||
29 | - if (elp = muxp->qhead) { | |||
30 | + if ((elp = muxp->qhead) != NULL) { | |||
31 | *event = elp->event; | |||
32 | muxp->qhead = elp->next; | |||
33 | if (muxp->qhead == 0) | |||
34 | @@ -212,7 +218,7 @@ Xmc_newId | |||
35 | { | |||
36 | static ulong_t id; | |||
37 | ||||
38 | - return muxp->base | (++id << muxp->shift) & muxp->mask; | |||
39 | + return muxp->base | ((++id << muxp->shift) & muxp->mask); | |||
40 | } | |||
41 | ||||
42 | void | |||
43 | @@ -642,7 +648,7 @@ Xmc_parse_display | |||
44 | if (n == 0 || n > sizeof(nbuf) - 1) /* sanity check */ | |||
45 | return -1; | |||
46 | for (i=0; i<n; i++) | |||
47 | - if (isdigit(display[i])) | |||
48 | + if (isdigit((unsigned char)display[i])) | |||
49 | nbuf[i] = display[i]; | |||
50 | else | |||
51 | return -1; | |||
52 | @@ -658,7 +664,7 @@ Xmc_parse_display | |||
53 | if (n == 0 || n > sizeof(nbuf) - 1) | |||
54 | return -1; | |||
55 | for (i=0; i<n; i++) | |||
56 | - if (isdigit(display[i])) | |||
57 | + if (isdigit((unsigned char)display[i])) | |||
58 | nbuf[i] = display[i]; | |||
59 | else | |||
60 | return -1; | |||
61 | @@ -666,7 +672,7 @@ Xmc_parse_display | |||
62 | scrno = atoi(nbuf); | |||
63 | } | |||
64 | ||||
65 | - if (n = strlen(hostbuf)) { | |||
66 | + if ((n = strlen(hostbuf)) != 0) { | |||
67 | if ((cp = (char *)malloc(n + 1)) == 0) | |||
68 | return 0; | |||
69 | strcpy(cp, hostbuf); | |||
70 | @@ -713,8 +719,8 @@ Xmc_host_addr | |||
71 | static ulong_t iaddr; | |||
72 | static struct hostent *hp; | |||
73 | ||||
74 | - if (isdigit(*hostname)) { | |||
75 | - for (cp=hostname; *cp && (isdigit(*cp) || *cp == '.'); cp++); | |||
76 | + if (isdigit((unsigned char)*hostname)) { | |||
77 | + for (cp=hostname; *cp && (isdigit((unsigned char)*cp) || *cp == '.'); cp++); | |||
78 | if (*cp == '\0') { /* it's an inet number */ | |||
79 | if ((long)(iaddr = inet_addr(hostname)) != -1) { | |||
80 | *famp = AddrFamInternet; | |||
81 | @@ -724,7 +730,7 @@ Xmc_host_addr | |||
82 | } | |||
83 | } | |||
84 | } | |||
85 | - if (hp = gethostbyname(hostname)) { | |||
86 | + if ((hp = gethostbyname(hostname)) != NULL) { | |||
87 | *famp = Xmc_family_utox(hp->h_addrtype); | |||
88 | *lenp = hp->h_length; | |||
89 | *addrp = *hp->h_addr_list; |
@@ -1,14 +1,15 @@ | @@ -1,14 +1,15 @@ | |||
1 | $NetBSD: patch-ac,v 1.2 2011/07/03 20:15:58 dholland Exp $ | 1 | $NetBSD: patch-ac,v 1.3 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | - use modern C | 3 | - use modern C | |
4 | 4 | |||
5 | --- lib/Xmc/AddDis.c~ 1998-02-01 14:02:27.000000000 -0500 | 5 | --- lib/Xmc/AddDis.c.orig 1998-02-01 19:02:27.000000000 +0000 | |
6 | +++ lib/Xmc/AddDis.c 2008-08-31 00:17:18.000000000 -0400 | 6 | +++ lib/Xmc/AddDis.c | |
7 | @@ -20,6 +20,7 @@ | 7 | @@ -20,6 +20,8 @@ | |
8 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 8 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
9 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 9 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
10 | */ | 10 | */ | |
11 | +#include <stdlib.h> | |||
11 | +#include <string.h> | 12 | +#include <string.h> | |
12 | #include <xmc.h> | 13 | #include <xmc.h> | |
13 | #include <xmclib.h> | 14 | #include <xmclib.h> | |
14 | #include <xmcp.h> | 15 | #include <xmcp.h> |
@@ -1,14 +1,55 @@ | @@ -1,14 +1,55 @@ | |||
1 | $NetBSD: patch-ae,v 1.2 2011/07/03 20:15:58 dholland Exp $ | 1 | $NetBSD: patch-ae,v 1.3 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | - use modern C | 3 | - use modern C | |
4 | - return something from the error handler insertion routines (caught by clang) | |||
5 | - fix a format string (caught by clang) | |||
4 | 6 | |||
5 | --- lib/Xmc/ErrHndlr.c~ 1998-02-01 14:03:30.000000000 -0500 | 7 | --- lib/Xmc/ErrHndlr.c.orig 1998-02-01 19:03:30.000000000 +0000 | |
6 | +++ lib/Xmc/ErrHndlr.c 2008-08-31 00:18:23.000000000 -0400 | 8 | +++ lib/Xmc/ErrHndlr.c | |
7 | @@ -21,6 +21,7 @@ | 9 | @@ -21,6 +21,7 @@ | |
8 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 10 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
9 | */ | 11 | */ | |
10 | #include <stdio.h> | 12 | #include <stdio.h> | |
11 | +#include <stdlib.h> | 13 | +#include <stdlib.h> | |
12 | #include <xmc.h> | 14 | #include <xmc.h> | |
13 | #include <xmclib.h> | 15 | #include <xmclib.h> | |
14 | #include <xmcp.h> | 16 | #include <xmcp.h> | |
17 | @@ -44,10 +45,14 @@ XmcSetErrorHandler | |||
18 | DB XmcErrorHandler handler | |||
19 | DE | |||
20 | { | |||
21 | + XmcErrorHandler prev; | |||
22 | + | |||
23 | + prev = error_handler; | |||
24 | if (handler) | |||
25 | error_handler = handler; | |||
26 | else | |||
27 | error_handler = default_eh; | |||
28 | + return prev; | |||
29 | } | |||
30 | ||||
31 | XmcIOErrorHandler | |||
32 | @@ -56,10 +61,14 @@ XmcSetIOErrorHandler | |||
33 | DB XmcIOErrorHandler handler | |||
34 | DE | |||
35 | { | |||
36 | + XmcIOErrorHandler prev; | |||
37 | + | |||
38 | + prev = io_error_handler; | |||
39 | if (handler) | |||
40 | io_error_handler = handler; | |||
41 | else | |||
42 | io_error_handler = default_io_eh; | |||
43 | + return prev; | |||
44 | } | |||
45 | ||||
46 | void | |||
47 | @@ -121,7 +130,7 @@ default_eh | |||
48 | fprintf(stderr, "XMC Protocol Error:\n"); | |||
49 | fprintf(stderr, "\tcode %d\n", ep->errorCode); | |||
50 | fprintf(stderr, "\trequest code %d\n", ep->opcode); | |||
51 | - fprintf(stderr, "\tdata 0x%08x\n", ep->data); | |||
52 | + fprintf(stderr, "\tdata 0x%08lx\n", ep->data); | |||
53 | exit(1); | |||
54 | } | |||
55 |
@@ -1,15 +1,25 @@ | @@ -1,15 +1,25 @@ | |||
1 | $NetBSD: patch-ag,v 1.2 2011/07/03 20:15:58 dholland Exp $ | 1 | $NetBSD: patch-ag,v 1.3 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | - use modern C | 3 | - use modern C | |
4 | - silence warnings about assignments within if conditions | |||
4 | 5 | |||
5 | --- lib/Xmc/ListDis.c~ 1998-02-01 15:07:47.000000000 -0500 | 6 | --- lib/Xmc/ListDis.c.orig 1998-02-01 20:07:47.000000000 +0000 | |
6 | +++ lib/Xmc/ListDis.c 2008-08-31 00:19:09.000000000 -0400 | 7 | +++ lib/Xmc/ListDis.c | |
7 | @@ -20,6 +20,8 @@ | 8 | @@ -20,6 +20,8 @@ | |
8 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | 9 | * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
9 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | 10 | * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
10 | */ | 11 | */ | |
11 | +#include <stdlib.h> | 12 | +#include <stdlib.h> | |
12 | +#include <string.h> | 13 | +#include <string.h> | |
13 | #include <xmc.h> | 14 | #include <xmc.h> | |
14 | #include <xmclib.h> | 15 | #include <xmclib.h> | |
15 | #include <xmcp.h> | 16 | #include <xmcp.h> | |
17 | @@ -50,7 +52,7 @@ XmcListDisplays | |||
18 | return 0; | |||
19 | ||||
20 | sz = r->length - sz_xmcListDisplaysReply; | |||
21 | - if (dp = (DispId *)malloc(sz)) { | |||
22 | + if ((dp = malloc(sz)) != NULL) { | |||
23 | bcopy((char *)(r+1), (char *)dp, sz); | |||
24 | *ndisp = r->nDisplays; | |||
25 | } |
@@ -1,16 +1,27 @@ | @@ -1,16 +1,27 @@ | |||
1 | $NetBSD: patch-ah,v 1.2 2011/07/03 20:15:58 dholland Exp $ | 1 | $NetBSD: patch-ah,v 1.3 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | - use modern C | 3 | - use modern C | |
4 | - silence warnings about assignments within if conditions | |||
4 | 5 | |||
5 | --- lib/Xmc/Open.c~ 1998-02-12 09:13:22.000000000 -0500 | 6 | --- lib/Xmc/Open.c.orig 1998-02-12 14:13:22.000000000 +0000 | |
6 | +++ lib/Xmc/Open.c 2008-08-31 00:19:40.000000000 -0400 | 7 | +++ lib/Xmc/Open.c | |
7 | @@ -32,6 +32,9 @@ | 8 | @@ -32,6 +32,10 @@ | |
8 | #ifdef SVR4 | 9 | #ifdef SVR4 | |
9 | #include <sys/filio.h> | 10 | #include <sys/filio.h> | |
10 | #endif | 11 | #endif | |
11 | +#include <stdio.h> | 12 | +#include <stdio.h> | |
12 | +#include <stdlib.h> | 13 | +#include <stdlib.h> | |
13 | +#include <string.h> | 14 | +#include <string.h> | |
15 | +#include <unistd.h> | |||
14 | #include <fcntl.h> | 16 | #include <fcntl.h> | |
15 | #include <netdb.h> | 17 | #include <netdb.h> | |
16 | #include <xmc.h> | 18 | #include <xmc.h> | |
19 | @@ -118,7 +122,7 @@ XmcOpen | |||
20 | #endif | |||
21 | #endif | |||
22 | #endif | |||
23 | - if (muxp = (Mux *)malloc(sizeof(Mux))) { | |||
24 | + if ((muxp = malloc(sizeof(Mux))) != NULL) { | |||
25 | muxp->fd = fd; | |||
26 | muxp->hostname = hostname; | |||
27 | Xmc_zerobuf(&muxp->inbuf); |
@@ -1,17 +1,109 @@ | @@ -1,17 +1,109 @@ | |||
1 | $NetBSD: patch-ba,v 1.2 2011/07/03 20:15:59 dholland Exp $ | 1 | $NetBSD: patch-ba,v 1.3 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | - use modern C | 3 | - use modern C | |
4 | - silence compiler warnings about assignments within if conditionals | |||
5 | - remove uses of implicit int to avoid warning noise | |||
6 | - use printf("%s", str) instead of printf(str) | |||
7 | - apply some const | |||
4 | 8 | |||
5 | --- server/args.c~ 1998-03-27 10:11:58.000000000 -0500 | 9 | --- server/args.c.orig 1998-03-27 15:11:58.000000000 +0000 | |
6 | +++ server/args.c 2008-08-31 00:25:23.000000000 -0400 | 10 | +++ server/args.c | |
7 | @@ -686,6 +686,9 @@ tok | 11 | @@ -45,7 +45,7 @@ | |
12 | ||||
13 | #define USAGE "usage: %s [:displaynum] [-option...]\n" | |||
14 | ||||
15 | -static char *options[] = { | |||
16 | +static const char *options[] = { | |||
17 | "-a # ignored\n", | |||
18 | "-af filename read command line arguments from filename\n", | |||
19 | "-auth path select authorization file\n", | |||
20 | @@ -97,7 +97,7 @@ static char *options[] = { | |||
21 | "-wm forces default backing store to WhenMapped\n", | |||
22 | "-view disp... the following displays may only watch\n", | |||
23 | "-x extension ignored\n", | |||
24 | - (char *)0}; | |||
25 | + NULL}; | |||
26 | ||||
27 | /* | |||
28 | ** private data | |||
29 | @@ -420,7 +420,7 @@ args_get | |||
30 | if (util_parse_display(hosts[i], &host, &family, | |||
31 | &display, &screen, &window)==0) { | |||
32 | host_pattern(host); | |||
33 | - if (name = host_match(&family, &length, &address)) | |||
34 | + if ((name = host_match(&family, &length, &address)) != NULL) | |||
35 | (void) server_alloc(did++, name, strlen(name), family, length, | |||
36 | address, display, screen, modes[i], window, 0); | |||
37 | } | |||
38 | @@ -432,17 +432,22 @@ args_get | |||
39 | ** | |||
40 | ** Print usage message and options. | |||
41 | */ | |||
42 | + | |||
43 | +#ifdef __GNUC__ | |||
44 | +static void usage(int) __attribute__((__noreturn__)); | |||
45 | +#endif | |||
46 | + | |||
47 | static void | |||
48 | usage | |||
49 | AL((status)) | |||
50 | DB int status | |||
51 | DE | |||
52 | { | |||
53 | - register i; | |||
54 | + register int i; | |||
55 | ||||
56 | fprintf(stderr, USAGE, command); | |||
57 | for (i=0; options[i]; i++) | |||
58 | - fprintf(stderr, options[i]); | |||
59 | + fprintf(stderr, "%s", options[i]); | |||
60 | exit(status); | |||
61 | } | |||
62 | ||||
63 | @@ -518,7 +523,7 @@ opt_str_arg | |||
64 | char *rv; | |||
65 | ||||
66 | if (fp) | |||
67 | - if (rv = tok(fp)) | |||
68 | + if ((rv = tok(fp)) != NULL) | |||
69 | return rv; | |||
70 | else { | |||
71 | fclose(fp); | |||
72 | @@ -540,7 +545,7 @@ opt_debug_arg | |||
73 | { | |||
74 | int i, level; | |||
75 | char *rv; | |||
76 | - static char *debugopts[] = { | |||
77 | + static const char *debugopts[] = { | |||
78 | "1 trace incoming client X protocol\n", | |||
79 | "2 trace outgoing virtual client X protocol\n", | |||
80 | "3 trace incoming server X protocol\n", | |||
81 | @@ -573,7 +578,7 @@ opt_debug_arg | |||
82 | "w trace byte swapping operations\n", | |||
83 | "x trace XMC protocol\n", | |||
84 | "? print this message\n", | |||
85 | - (char *)0}; | |||
86 | + NULL}; | |||
87 | ||||
88 | if (fp && (rv = tok(fp)) == 0) { | |||
89 | fclose(fp); | |||
90 | @@ -621,7 +626,7 @@ opt_debug_arg | |||
91 | case '?': | |||
92 | fprintf(stderr, "debug options:\n"); | |||
93 | for (i=0; debugopts[i]; i++) | |||
94 | - fprintf(stderr, debugopts[i]); | |||
95 | + fprintf(stderr, "%s", debugopts[i]); | |||
96 | exit(0); | |||
97 | default: | |||
98 | warn("unknown debug option '%c'\n", *rv); | |||
99 | @@ -686,6 +691,9 @@ tok | |||
8 | buf[i++] = (char)ch; | 100 | buf[i++] = (char)ch; | |
9 | break; | 101 | break; | |
10 | } | 102 | } | |
11 | - return (char *)err(0, "tok: token too long\n"); | 103 | - return (char *)err(0, "tok: token too long\n"); | |
12 | + /* this err() returns its first arg */ | 104 | + /* this err() returns its first arg */ | |
13 | + /*return (char *)err(0, "tok: token too long\n");*/ | 105 | + /*return (char *)err(0, "tok: token too long\n");*/ | |
14 | + err(0, "tok: token too long\n"); | 106 | + err(0, "tok: token too long\n"); | |
15 | + return NULL; | 107 | + return NULL; | |
16 | } | 108 | } | |
17 | #undef MAXTOKLEN | 109 | #undef MAXTOKLEN |
@@ -1,30 +1,154 @@ | @@ -1,30 +1,154 @@ | |||
1 | $NetBSD: patch-ed,v 1.2 2011/07/03 20:16:00 dholland Exp $ | 1 | $NetBSD: patch-ed,v 1.3 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | - use modern C | 3 | - use modern C | |
4 | - terminate calls to XtVa[GS]etValues properly (caught by clang) | |||
5 | - declare functions not returning values as void (otherwise clang belches) | |||
4 | 6 | |||
5 | --- clients/xmtg/ui.c.orig 1998-04-01 18:55:00.000000000 -0500 | 7 | --- clients/xmtg/ui.c.orig 1998-04-01 23:55:00.000000000 +0000 | |
6 | +++ clients/xmtg/ui.c 2008-08-31 02:40:34.000000000 -0400 | 8 | +++ clients/xmtg/ui.c | |
7 | @@ -22,10 +22,14 @@ | 9 | @@ -22,10 +22,14 @@ | |
8 | */ | 10 | */ | |
9 | /* next line is debugging...TODO */ | 11 | /* next line is debugging...TODO */ | |
10 | #include <stdio.h> | 12 | #include <stdio.h> | |
11 | +#include <stdlib.h> | 13 | +#include <stdlib.h> | |
12 | +#include <string.h> | 14 | +#include <string.h> | |
13 | #ifdef __STDC__ | 15 | #ifdef __STDC__ | |
14 | +#include <stdint.h> | 16 | +#include <stdint.h> | |
15 | #include <stdarg.h> | 17 | #include <stdarg.h> | |
16 | #else | 18 | #else | |
17 | #include <varargs.h> | 19 | #include <varargs.h> | |
18 | +typedef long intptr_t; /* best guess... */ | 20 | +typedef long intptr_t; /* best guess... */ | |
19 | #endif | 21 | #endif | |
20 | #include <X11/Xlib.h> | 22 | #include <X11/Xlib.h> | |
21 | 23 | |||
22 | @@ -440,7 +444,7 @@ ui_get_add_info(adp, strp, modep) | 24 | @@ -121,7 +125,7 @@ ui_create(top, floor, seat, view, gridp) | |
25 | ** Telepointer toggle | |||
26 | */ | |||
27 | w = XtCreateManagedWidget("teleptr", toggleWidgetClass, parent, 0,0); | |||
28 | - XtVaSetValues(w, XtNstate, True, 0); | |||
29 | + XtVaSetValues(w, XtNstate, True, (void *)NULL); | |||
30 | XtAddCallback(w, XtNcallback, teleptr_cb, 0); | |||
31 | ||||
32 | /* | |||
33 | @@ -186,9 +190,9 @@ ui_create_radio(name, parent, value, lea | |||
34 | w = XtCreateManagedWidget(name, toggleWidgetClass, parent, 0, 0); | |||
35 | ||||
36 | if (leader) | |||
37 | - XtVaSetValues(w, XtNradioData, value, XtNradioGroup, leader, 0); | |||
38 | + XtVaSetValues(w, XtNradioData, value, XtNradioGroup, leader, (void *)NULL); | |||
39 | else | |||
40 | - XtVaSetValues(w, XtNradioData, value, 0); | |||
41 | + XtVaSetValues(w, XtNradioData, value, (void *)NULL); | |||
42 | ||||
43 | if (buttonp) | |||
44 | *buttonp = w; | |||
45 | @@ -202,6 +206,7 @@ blort(w, c, d) | |||
46 | printf("BLORT!\n"); | |||
47 | } | |||
48 | ||||
49 | +void | |||
50 | ui_create_add_dialog(dp, parent, prompt, floor, seat, view) | |||
51 | dialog_t *dp; | |||
52 | Widget parent; | |||
53 | @@ -229,7 +234,7 @@ XtAddCallback(dp->enable, XtNcallback, b | |||
54 | w = XtCreateManagedWidget("add_label", labelWidgetClass, dp->dialog,0,0); | |||
55 | XtVaSetValues(w, XtNlabel, prompt, | |||
56 | XtNborderWidth, 0, | |||
57 | - 0); | |||
58 | + (void *)NULL); | |||
59 | ||||
60 | input = XtCreateManagedWidget( "input", | |||
61 | asciiTextWidgetClass, | |||
62 | @@ -239,7 +244,7 @@ XtAddCallback(dp->enable, XtNcallback, b | |||
63 | XtVaSetValues(input, XtNeditType, XawtextEdit, | |||
64 | XtNpieceSize, 128, | |||
65 | XtNtype, XawAsciiString, | |||
66 | - 0); | |||
67 | + (void *)NULL); | |||
68 | ||||
69 | /* | |||
70 | ** Floor/Seat/View radio group | |||
71 | @@ -247,7 +252,7 @@ XtAddCallback(dp->enable, XtNcallback, b | |||
72 | w = XtCreateManagedWidget("mode_label", labelWidgetClass,dp->dialog,0,0); | |||
73 | XtVaSetValues(w, XtNlabel, "Input mode:", | |||
74 | XtNborderWidth, 0, | |||
75 | - 0); | |||
76 | + (void *)NULL); | |||
77 | ui_create_radio("floor", dp->dialog, floor, 0, &radio); | |||
78 | ui_create_radio("seat", dp->dialog, seat, radio, 0); | |||
79 | ui_create_radio("view", dp->dialog, view, radio, 0); | |||
80 | @@ -261,6 +266,7 @@ XtAddCallback(dp->enable, XtNcallback, b | |||
81 | } | |||
82 | } | |||
83 | ||||
84 | +void | |||
85 | ui_create_drop_dialog(dp, parent, prompt) | |||
86 | dialog_t *dp; | |||
87 | Widget parent; | |||
88 | @@ -285,7 +291,7 @@ ui_create_drop_dialog(dp, parent, prompt | |||
89 | w = XtCreateManagedWidget("drop_label", labelWidgetClass, dp->dialog,0,0); | |||
90 | XtVaSetValues(w, XtNlabel, prompt, | |||
91 | XtNborderWidth, 0, | |||
92 | - 0); | |||
93 | + (void *)NULL); | |||
94 | ||||
95 | ui_create_dialog_dismiss("accept", dp, drop_cb, 0); | |||
96 | ui_create_dialog_dismiss("cancel", dp, 0, 0); | |||
97 | @@ -333,7 +339,7 @@ ui_create_dialog(name, dp, parent, promp | |||
98 | dp->shell, | |||
99 | 0, | |||
100 | 0); | |||
101 | - XtVaSetValues(dp->dialog, XtNlabel, prompt, XtNvalue, "", 0); | |||
102 | + XtVaSetValues(dp->dialog, XtNlabel, prompt, XtNvalue, "", (void *)NULL); | |||
103 | XtAddCallback(dp->enable, XtNcallback, center_popup, (XtPointer)dp); | |||
104 | XtAddCallback(dp->enable,XtNcallback,XtCallbackNone,(XtPointer)dp->shell); | |||
105 | } | |||
106 | @@ -427,7 +433,7 @@ ui_get_toggle_state(w) | |||
107 | { | |||
108 | Boolean state; | |||
109 | ||||
110 | - XtVaGetValues(w, XtNstate, &state, 0); | |||
111 | + XtVaGetValues(w, XtNstate, &state, (void *)NULL); | |||
112 | ||||
113 | return (state == True); | |||
114 | } | |||
115 | @@ -439,8 +445,8 @@ ui_get_add_info(adp, strp, modep) | |||
116 | int *modep; | |||
23 | { | 117 | { | |
24 | 118 | |||
25 | XtVaGetValues(adp->input, XtNstring, strp, 0); | 119 | - XtVaGetValues(adp->input, XtNstring, strp, 0); | |
26 | - *modep = (int)XawToggleGetCurrent(adp->mode_radio); | 120 | - *modep = (int)XawToggleGetCurrent(adp->mode_radio); | |
121 | + XtVaGetValues(adp->input, XtNstring, strp, (void *)NULL); | |||
27 | + *modep = (int)(intptr_t)XawToggleGetCurrent(adp->mode_radio); | 122 | + *modep = (int)(intptr_t)XawToggleGetCurrent(adp->mode_radio); | |
28 | } | 123 | } | |
29 | 124 | |||
30 | void | 125 | void | |
126 | @@ -531,8 +537,8 @@ center_popup(w, client_data, call_data) | |||
127 | if (!XtIsRealized(dp->shell)) | |||
128 | XtRealizeWidget(dp->shell); | |||
129 | ||||
130 | - XtVaGetValues(dp->top, XtNwidth, &sw, XtNheight, &sh, 0); | |||
131 | - XtVaGetValues(dp->shell, XtNwidth, &dw, XtNheight, &dh, 0); | |||
132 | + XtVaGetValues(dp->top, XtNwidth, &sw, XtNheight, &sh, (void *)NULL); | |||
133 | + XtVaGetValues(dp->shell, XtNwidth, &dw, XtNheight, &dh, (void *)NULL); | |||
134 | x = (Position)(sw/2 - dw/2); | |||
135 | y = (Position)(sh/2 - dh/2); | |||
136 | XtTranslateCoords(dp->top, x, y, &x, &y); | |||
137 | @@ -542,7 +548,7 @@ center_popup(w, client_data, call_data) | |||
138 | printf("center_popup: doing XtVaSetValues of x and y..."); | |||
139 | fflush(stdout); | |||
140 | */ | |||
141 | - XtVaSetValues(dp->shell, XtNx, x, XtNy, y, 0); | |||
142 | + XtVaSetValues(dp->shell, XtNx, x, XtNy, y, (void *)NULL); | |||
143 | printf("done.\n"); | |||
144 | fflush(stdout); | |||
145 | } | |||
146 | @@ -569,7 +575,7 @@ ui_error | |||
147 | #endif | |||
148 | ||||
149 | vsprintf(buf, msg, pvar); | |||
150 | - XtVaSetValues(errors->text, XtNstring, buf, 0); | |||
151 | + XtVaSetValues(errors->text, XtNstring, buf, (void *)NULL); | |||
152 | ||||
153 | XtPopup(errors->shell, XtGrabNone); | |||
154 | } |
@@ -1,46 +1,205 @@ | @@ -1,46 +1,205 @@ | |||
1 | $NetBSD: patch-ef,v 1.2 2011/07/03 20:16:00 dholland Exp $ | 1 | $NetBSD: patch-ef,v 1.3 2011/09/19 07:15:52 dholland Exp $ | |
2 | 2 | |||
3 | - use modern C | 3 | - use modern C | |
4 | - use stdarg.h for printf wrappers instead of ancient-style fake varargs | |||
5 | - declare printf functions as such for format checking | |||
6 | - mark functions not returning values as void; otherwise clang belches | |||
7 | - remove uses of implicit int to avoid warning noise | |||
8 | - silence warnings about assignment within an if conditional | |||
4 | 9 | |||
5 | --- clients/xmxinit/xmxinit.c~ 1995-04-19 23:05:04.000000000 -0400 | 10 | --- clients/xmxinit/xmxinit.c.orig 1995-04-20 03:05:04.000000000 +0000 | |
6 | +++ clients/xmxinit/xmxinit.c 2008-08-31 02:38:46.000000000 -0400 | 11 | +++ clients/xmxinit/xmxinit.c | |
7 | @@ -30,7 +30,6 @@ Modified from X11R6 MIT source for xinit | 12 | @@ -24,13 +24,13 @@ Modified from X11R6 MIT source for xinit | |
13 | #include <X11/Xos.h> | |||
14 | #include <X11/Xmu/SysUtil.h> | |||
15 | #include <stdio.h> | |||
16 | +#include <stdarg.h> | |||
17 | #include <ctype.h> | |||
18 | #include <signal.h> | |||
19 | #ifndef SYSV | |||
8 | #include <sys/wait.h> | 20 | #include <sys/wait.h> | |
9 | #endif | 21 | #endif | |
10 | #include <errno.h> | 22 | #include <errno.h> | |
11 | -extern int sys_nerr; | 23 | -extern int sys_nerr; | |
12 | #include <setjmp.h> | 24 | #include <setjmp.h> | |
13 | 25 | |||
14 | #ifndef X_NOT_STDC_ENV | 26 | #ifndef X_NOT_STDC_ENV | |
15 | @@ -86,8 +85,8 @@ char **client = clientargv + 2; /* make | 27 | @@ -41,6 +41,12 @@ extern char *getenv(); | |
28 | extern char **environ; | |||
29 | char **newenviron = NULL; | |||
30 | ||||
31 | +#if defined(__GNUC__) || defined(__CLANG__) | |||
32 | +#define PF(a, b) __attribute__((__format__(__printf__, a, b))) | |||
33 | +#else | |||
34 | +#define PF(a, b) | |||
35 | +#endif | |||
36 | + | |||
37 | #ifndef SHELL | |||
38 | #define SHELL "sh" | |||
39 | #endif | |||
40 | @@ -59,6 +65,15 @@ char **newenviron = NULL; | |||
41 | #define setpgrp setpgid | |||
42 | #endif | |||
43 | ||||
44 | +static void shutdown(void); | |||
45 | +int processTimeout(int timeout, char *string); | |||
46 | +void set_environment(void); | |||
47 | +void Fatal(const char *fmt, ...) PF(1, 2); | |||
48 | +void Error(const char *fmt, ...) PF(1, 2); | |||
49 | +void vError(const char *fmt, va_list ap) PF(1, 0); | |||
50 | +int startServer(char *server[]); | |||
51 | +pid_t startClient(char *client[]); | |||
52 | + | |||
53 | char *bindir = BINDIR; | |||
54 | ||||
55 | #ifndef XMXINITRC | |||
56 | @@ -86,8 +101,8 @@ char **client = clientargv + 2; /* make | |||
16 | char *displayNum; | 57 | char *displayNum; | |
17 | char *program; | 58 | char *program; | |
18 | Display *xd; /* server connection */ | 59 | Display *xd; /* server connection */ | |
19 | -#ifndef SYSV | 60 | -#ifndef SYSV | |
20 | -#if defined(SVR4) || defined(_POSIX_SOURCE) | 61 | -#if defined(SVR4) || defined(_POSIX_SOURCE) | |
21 | +#if 1 /*ndef SYSV*/ | 62 | +#if 1 /*ndef SYSV*/ | |
22 | +#if 1 /*defined(SVR4) || defined(_POSIX_SOURCE)*/ | 63 | +#if 1 /*defined(SVR4) || defined(_POSIX_SOURCE)*/ | |
23 | int status; | 64 | int status; | |
24 | #else | 65 | #else | |
25 | union wait status; | 66 | union wait status; | |
26 | @@ -350,7 +349,7 @@ processTimeout(timeout, string) | 67 | @@ -95,9 +110,6 @@ union wait status; | |
68 | #endif /* SYSV */ | |||
69 | int serverpid = -1; | |||
70 | int clientpid = -1; | |||
71 | -extern int errno; | |||
72 | - | |||
73 | -static shutdown(); | |||
74 | ||||
75 | #ifdef SIGNALRETURNSINT | |||
76 | #define SIGVAL int | |||
77 | @@ -146,6 +158,7 @@ static Execute (vec) | |||
78 | return; | |||
79 | } | |||
80 | ||||
81 | +int | |||
82 | main(argc, argv) | |||
83 | int argc; | |||
84 | register char **argv; | |||
85 | @@ -197,7 +210,7 @@ register char **argv; | |||
86 | */ | |||
87 | if (argc == 0 || | |||
88 | (**argv != '/' && **argv != '.')) { | |||
89 | - if (*sptr = getenv("XMX")) | |||
90 | + if ((*sptr = getenv("XMX")) != NULL) | |||
91 | sptr++; | |||
92 | else | |||
93 | *sptr++ = default_server; | |||
94 | @@ -312,13 +325,14 @@ register char **argv; | |||
95 | * waitforserver - wait for X server to start up | |||
96 | */ | |||
97 | ||||
98 | -waitforserver() | |||
99 | +int | |||
100 | +waitforserver(void) | |||
101 | { | |||
102 | int ncycles = 120; /* # of cycles to wait */ | |||
103 | int cycles; /* Wait cycle count */ | |||
104 | ||||
105 | for (cycles = 0; cycles < ncycles; cycles++) { | |||
106 | - if (xd = XOpenDisplay(displayNum)) { | |||
107 | + if ((xd = XOpenDisplay(displayNum)) != NULL) { | |||
108 | return(TRUE); | |||
109 | } | |||
110 | else { | |||
111 | @@ -336,6 +350,7 @@ waitforserver() | |||
112 | /* | |||
113 | * return TRUE if we timeout waiting for pid to exit, FALSE otherwise. | |||
114 | */ | |||
115 | +int | |||
116 | processTimeout(timeout, string) | |||
117 | int timeout; | |||
118 | char *string; | |||
119 | @@ -350,7 +365,7 @@ processTimeout(timeout, string) | |||
27 | break; | 120 | break; | |
28 | alarm(0); | 121 | alarm(0); | |
29 | #else /* SYSV */ | 122 | #else /* SYSV */ | |
30 | -#if defined(SVR4) || defined(_POSIX_SOURCE) | 123 | -#if defined(SVR4) || defined(_POSIX_SOURCE) | |
31 | +#if 1 /*defined(SVR4) || defined(_POSIX_SOURCE)*/ | 124 | +#if 1 /*defined(SVR4) || defined(_POSIX_SOURCE)*/ | |
32 | if ((pidfound = waitpid(serverpid, &status, WNOHANG)) == serverpid) | 125 | if ((pidfound = waitpid(serverpid, &status, WNOHANG)) == serverpid) | |
33 | break; | 126 | break; | |
34 | #else | 127 | #else | |
35 | @@ -588,10 +587,8 @@ Fatal(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9 | 128 | @@ -375,6 +390,7 @@ processTimeout(timeout, string) | |
36 | Error(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9) | 129 | return( serverpid != pidfound ); | |
37 | char *fmt; | 130 | } | |
131 | ||||
132 | +int | |||
133 | startServer(server) | |||
134 | char *server[]; | |||
135 | { | |||
136 | @@ -457,6 +473,7 @@ startServer(server) | |||
137 | return(serverpid); | |||
138 | } | |||
139 | ||||
140 | +pid_t | |||
141 | startClient(client) | |||
142 | char *client[]; | |||
143 | { | |||
144 | @@ -490,8 +507,8 @@ static int ignorexio (dpy) | |||
145 | /*NOTREACHED*/ | |||
146 | } | |||
147 | ||||
148 | -static | |||
149 | -shutdown() | |||
150 | +static void | |||
151 | +shutdown(void) | |||
152 | { | |||
153 | /* have kept display opened, so close it now */ | |||
154 | if (clientpid > 0) { | |||
155 | @@ -544,7 +561,8 @@ shutdown() | |||
156 | * make a new copy of environment that has room for DISPLAY | |||
157 | */ | |||
158 | ||||
159 | -set_environment () | |||
160 | +void | |||
161 | +set_environment(void) | |||
162 | { | |||
163 | int nenvvars; | |||
164 | char **newPtr, **oldPtr; | |||
165 | @@ -578,20 +596,32 @@ set_environment () | |||
166 | return; | |||
167 | } | |||
168 | ||||
169 | -Fatal(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9) | |||
170 | - char *fmt; | |||
171 | +void | |||
172 | +Fatal(const char *fmt, ...) | |||
173 | { | |||
174 | - Error(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); | |||
175 | + va_list ap; | |||
176 | + | |||
177 | + va_start(ap, fmt); | |||
178 | + vError(fmt, ap); | |||
179 | + va_end(ap); | |||
180 | exit(ERR_EXIT); | |||
181 | } | |||
182 | ||||
183 | -Error(fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9) | |||
184 | - char *fmt; | |||
185 | +void | |||
186 | +Error(const char *fmt, ...) | |||
38 | { | 187 | { | |
39 | - extern char *sys_errlist[]; | 188 | - extern char *sys_errlist[]; | |
40 | - | 189 | + va_list ap; | |
190 | ||||
191 | + va_start(ap, fmt); | |||
192 | + vError(fmt, ap); | |||
193 | + va_end(ap); | |||
194 | +} | |||
195 | + | |||
196 | +void | |||
197 | +vError(const char *fmt, va_list ap) | |||
198 | +{ | |||
41 | fprintf(stderr, "%s: ", program); | 199 | fprintf(stderr, "%s: ", program); | |
42 | if (errno > 0 && errno < sys_nerr) | 200 | if (errno > 0 && errno < sys_nerr) | |
43 | - fprintf (stderr, "%s (errno %d): ", sys_errlist[errno], errno); | 201 | - fprintf (stderr, "%s (errno %d): ", sys_errlist[errno], errno); | |
202 | - fprintf(stderr, fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); | |||
44 | + fprintf (stderr, "%s (errno %d): ", strerror(errno), errno); | 203 | + fprintf (stderr, "%s (errno %d): ", strerror(errno), errno); | |
45 | fprintf(stderr, fmt, x0,x1,x2,x3,x4,x5,x6,x7,x8,x9); | 204 | + vfprintf(stderr, fmt, ap); | |
46 | } | 205 | } |
$NetBSD: patch-eh,v 1.1 2011/09/19 07:15:52 dholland Exp $
- silence warning about assignment in an if condition
- fix parenthesization, caught by clang
--- clients/xmtg/pathfind.c~ 1997-05-21 17:15:13.000000000 +0000
+++ clients/xmtg/pathfind.c
@@ -72,7 +72,7 @@ pathfind
if (i) {
if ((dirp = opendir(pbuf)) == 0)
continue;
- while (dep = readdir(dirp)) {
+ while ((dep = readdir(dirp)) != NULL) {
if (strcmp(name, dep->d_name) == 0) {
pbuf[i] = '\0'; /* reset path */
(void)strcat(pbuf, "/");
@@ -86,25 +86,25 @@ pathfind
for (mp=mode; *mp && okay; mp++) {
switch (*mp) {
case 'r':
- if ( st.st_mode & S_IROTH == 0 &&
- (st.st_mode & S_IRUSR == 0 || uid != st.st_uid))
- if (st.st_mode & S_IRGRP == 0 || gid != st.st_gid)
+ if ( (st.st_mode & S_IROTH) == 0 &&
+ ((st.st_mode & S_IRUSR) == 0 || uid != st.st_uid))
+ if ((st.st_mode & S_IRGRP) == 0 || gid != st.st_gid)
okay = 0;
else
chkgrp = 1;
break;
case 'w':
- if ( st.st_mode & S_IWOTH == 0 &&
- (st.st_mode & S_IWUSR == 0 || uid != st.st_uid))
- if (st.st_mode & S_IWGRP == 0 || gid != st.st_gid)
+ if ( (st.st_mode & S_IWOTH) == 0 &&
+ ((st.st_mode & S_IWUSR) == 0 || uid != st.st_uid))
+ if ((st.st_mode & S_IWGRP) == 0 || gid != st.st_gid)
okay = 0;
else
chkgrp = 1;
break;
case 'x':
- if ( st.st_mode & S_IXOTH == 0 &&
- (st.st_mode & S_IXUSR == 0 || uid != st.st_uid))
- if (st.st_mode & S_IXGRP == 0 || gid != st.st_gid)
+ if ( (st.st_mode & S_IXOTH == 0) &&
+ ((st.st_mode & S_IXUSR == 0) || uid != st.st_uid))
+ if ((st.st_mode & S_IXGRP == 0) || gid != st.st_gid)
okay = 0;
else
chkgrp = 1;
@@ -125,13 +125,13 @@ pathfind
okay = S_ISFIFO(st.st_mode);
break;
case 'u':
- okay = (st.st_mode & S_ISUID != 0);
+ okay = ((st.st_mode & S_ISUID) != 0);
break;
case 'g':
- okay = (st.st_mode & S_ISGID != 0);
+ okay = ((st.st_mode & S_ISGID) != 0);
break;
case 'k':
- okay = (st.st_mode & S_ISVTX != 0);
+ okay = ((st.st_mode & S_ISVTX) != 0);
break;
case 's':
okay = (st.st_size != 0);