summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2013-02-02 02:09:25 -0500
committerGravatar Jeffrey Hutzelman <jhutz@cmu.edu>2013-02-14 19:20:27 -0500
commite2bfb6322ce9f4323b83469dc06dd1ce1b0f4cf6 (patch)
tree507dab2f064c09996a002624d49c0dfb257a24a9
parent350312d5db9b0a968bbbbecb37bd600a2da389d0 (diff)
Clean up warnings
Eliminate compiler warnings due to various issues (listed below). This allows Zephyr to build cleanly under GCC versions ranging from 4.1.0 to 4.7.2 with all of the options shown below: -g -O2 -Wall -Werror -Wno-deprecated-declarations -Wmissing-declarations -Wpointer-arith -Wstrict-prototypes -Wshadow -Wextra -Wno-missing-field-initializers -Wno-unused-parameter and, on recent versions, -Wunreachable-code Test builds were done - On Ubuntu 12.10 (Quantal Quetzal) using both MIT Kerberos 1.10.1 and Heimdal 1.6, without krb4 and both with and without C-Ares and Hesiod - On Fedora 14 using Heimdal 0.6, without C-Ares or Hesiod and both with and without krb4 (KTH Kerberos 1.3rc2) - On Fedora Core 3, Fedora Core 5, Fedora 7, and Fedora 10, using Heimdal 0.6 and without C-Ares, Hesiod, or krb4 It also allows clean builds on Solaris 10 under the Sun Studio 12 (9/07) C compiler with the following options: -g -fd -v -errfmt -errhdr=%user -errtags=yes -errwarn=%all -erroff=E_OLD_STYLE_FUNC_DECL,E_ENUM_TYPE_MISMATCH_ARG,E_ARG_INCOMPATIBLE_WITH_ARG ... and under Solaris 9 with the Sun Forte 7 (3/02) C compiler with the above options and -erroff=E_FUNC_HAS_NO_RETURN_STMT. Solaris builds were done with Heimdal 0.6 and without C-Ares, Hesiod, or krb4. The following types of issues are addressed in this change: - Parameters and local variables with the same names as library functions - Parameters and local variables with the same names as globals - Declarations for exported global variables missing from headers - Prototypes for exported functions missing from headers - Missing 'static' on functions that shouldn't be exported - Old-style function declarations - Duplicate declarations - Type mismatches - Unused variables and functions - Uninitialized variables - Forward references to enums - Necessary header files not included - Violations of the aliasing rules, where GCC was able to detect them - Missing braces on if blocks that might be empty - Attempts to do pointer arithmetic on pointers of type void *, which is not permitted in standard C. - An attempt to pass a function pointer via a void * parameter, which is not permitted in standard C. Instead, we now pass a pointer to a structure, which then contains the required function pointer. - Unnecessary inclusion of <krb5_err.h>, which is already included by <krb5.h> when the former exists, and might not be protected against double inclusion, depending on which com_err was used. - Missing include of <com_err.h>, which was masked by the fact that it is included by headers generated by e2fsprogs compile_et - Use of com_err() with a non-constant value in place of the format string, which in every case was a fixed-size buffer in which a message was built using sprintf(!). Both the calls to sprintf and the fixed-size buffers have been removed, in favor of just letting com_err() do the formatting. - Various cases where X library functions expecting a parameter of type wchar_t * were instead passed a parameter of type XChar2b *. The two types look similar, but are not the same and are _not_ interchangeable. - An overly-simplistic configure test which failed to detect existence of <term.h> on Solaris, due to not including <curses.h>. - Using the wrong type for the flags output of krb5_auth_con_getflags() when building against Heimdal. A configure test is added to detect the correct type.
-rw-r--r--clients/zaway/zaway.c5
-rw-r--r--clients/zctl/zctl.c118
-rw-r--r--clients/zlocate/zlocate.c6
-rw-r--r--clients/zshutdown_notify/zshutdown_notify.c2
-rw-r--r--clients/zstat/zstat.c6
-rw-r--r--clients/zwrite/zwrite.c8
-rw-r--r--configure.ac28
-rw-r--r--h/internal.h5
-rw-r--r--h/zephyr/zephyr.h16
-rw-r--r--lib/ZCkZAut.c15
-rw-r--r--lib/ZExpnRlm.c3
-rw-r--r--lib/ZFmtAuth.c12
-rw-r--r--lib/ZInit.c15
-rw-r--r--lib/ZMakeZcode.c8
-rw-r--r--lib/ZMkAuth.c2
-rw-r--r--lib/ZParseNot.c16
-rw-r--r--lib/ZReadAscii.c2
-rw-r--r--lib/ZVariables.c5
-rw-r--r--lib/Zinternal.c38
-rw-r--r--lib/charset.c51
-rw-r--r--server/access.h4
-rw-r--r--server/acl_files.c12
-rw-r--r--server/bdump.c19
-rw-r--r--server/dispatch.c33
-rw-r--r--server/kstuff.c40
-rw-r--r--server/main.c2
-rw-r--r--server/realm.c25
-rw-r--r--server/server.c2
-rw-r--r--server/subscr.c16
-rw-r--r--server/utf8proc.c2
-rw-r--r--server/zserver.h62
-rw-r--r--server/zstring.c7
-rw-r--r--zhm/queue.c2
-rw-r--r--zhm/zhm.c8
-rw-r--r--zhm/zhm.h18
-rw-r--r--zhm/zhm_client.c6
-rw-r--r--zhm/zhm_server.c11
-rw-r--r--zwgc/X_driver.c46
-rw-r--r--zwgc/X_driver.h4
-rw-r--r--zwgc/X_gram.c12
-rw-r--r--zwgc/file.c4
-rw-r--r--zwgc/formatter.c3
-rw-r--r--zwgc/lexer.c2
-rw-r--r--zwgc/main.c19
-rw-r--r--zwgc/new_string.c4
-rw-r--r--zwgc/notice.c13
-rw-r--r--zwgc/plus.c15
-rw-r--r--zwgc/plus.h2
-rw-r--r--zwgc/standard_ports.c20
-rw-r--r--zwgc/string_dictionary_aux.c1
-rw-r--r--zwgc/subscriptions.c8
-rw-r--r--zwgc/tty_filter.c1
-rw-r--r--zwgc/tty_filter.h2
-rw-r--r--zwgc/xcut.c24
-rw-r--r--zwgc/xerror.c1
-rw-r--r--zwgc/xmark.c23
-rw-r--r--zwgc/xrevstack.c1
-rw-r--r--zwgc/xselect.c19
-rw-r--r--zwgc/xshow.c35
-rw-r--r--zwgc/zephyr.c22
60 files changed, 486 insertions, 425 deletions
diff --git a/clients/zaway/zaway.c b/clients/zaway/zaway.c
index 684609c..cb72c34 100644
--- a/clients/zaway/zaway.c
+++ b/clients/zaway/zaway.c
@@ -23,10 +23,12 @@ static const char rcsid_zaway_c[] = "$Id$";
#define DEFAULT_MSG "I'm sorry, but I am currently away from the terminal and am\nnot able to receive your message.\n"
#define RESPONSE_OPCODE ""
+static char *find_message(ZNotice_t *, FILE *);
+
RETSIGTYPE cleanup(int);
u_short port;
-void
+static void
usage(char *name)
{
printf("Usage: %s [OPTIONS] [FILE]\n"
@@ -51,7 +53,6 @@ main(int argc,
int optchar, watch_location;
char *cmdline_msg;
int nlocs;
- char *find_message(ZNotice_t *, FILE *);
char *charset = NULL;
unsigned short zcharset;
diff --git a/clients/zctl/zctl.c b/clients/zctl/zctl.c
index 599e146..706f3cd 100644
--- a/clients/zctl/zctl.c
+++ b/clients/zctl/zctl.c
@@ -66,6 +66,27 @@ static void run_command(int, char *[]);
static void show_commands(int, char *[]);
#endif
+/* Prototype all of the commands.
+ * These really should be in a header also visible to zctl_cmds.c,
+ * but mk_cmds doesn't make that easy.
+ */
+void cancel_subs(int argc, char *argv[]);
+void current(int argc, char *argv[]);
+void do_hide(int argc, char *argv[]);
+void do_punt(int argc, char *argv[]);
+void flush_locations(int argc, char *argv[]);
+void hm_control(int argc, char *argv[]);
+void list_punts(int argc, char *argv[]);
+void load_subs(int argc, char *argv[]);
+void set_file(int argc, char *argv[]);
+void set_var(int argc, char *argv[]);
+void show_var(int argc, char *argv[]);
+void sub_file(int argc, char *argv[]);
+void subscribe(int argc, char *argv[]);
+void unset_var(int argc, char *argv[]);
+void wgc_control(int argc, char *argv[]);
+
+
int
main(int argc,
char *argv[])
@@ -547,22 +568,19 @@ add_file(short wgport,
int unsub)
{
FILE *fp;
- char errbuf[BUFSIZ];
ZSubscription_t sub2;
Code_t retval;
(void) purge_subs(subs,ALL); /* remove copies in the subs file */
if (!(fp = fopen(subsname,"a"))) {
- (void) sprintf(errbuf,"while opening %s for append",subsname);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while opening %s for append", subsname);
return;
}
fprintf(fp,"%s%s,%s,%s\n",
unsub ? "!" : "",
subs->zsub_class, subs->zsub_classinst, subs->zsub_recipient);
if (fclose(fp) == EOF) {
- (void) sprintf(errbuf, "while closing %s", subsname);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while closing %s", subsname);
return;
}
fix_macros(subs,&sub2,1);
@@ -605,7 +623,7 @@ purge_subs(register ZSubscription_t *subs,
int which)
{
FILE *fp,*fpout;
- char errbuf[BUFSIZ],subline[BUFSIZ];
+ char subline[BUFSIZ];
char backup[BUFSIZ],ourline[BUFSIZ];
int delflag = NOT_REMOVED;
int keep = 0;
@@ -626,16 +644,14 @@ purge_subs(register ZSubscription_t *subs,
subs->zsub_recipient);
if (!(fp = fopen(subsname,"r"))) {
- (void) sprintf(errbuf,"while opening %s for read",subsname);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while opening %s for read", subsname);
return(ERR);
}
(void) strcpy(backup, subsname);
(void) strcat(backup, ".temp");
(void) unlink(backup);
if (!(fpout = fopen(backup,"w"))) {
- (void) sprintf(errbuf,"while opening %s for writing",backup);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while opening %s for writing", backup);
(void) fclose(fp);
return(ERR);
}
@@ -660,23 +676,20 @@ purge_subs(register ZSubscription_t *subs,
if (keep) {
fputs(subline, fpout);
if (ferror(fpout) || (fputc('\n', fpout) == EOF)) {
- (void) sprintf(errbuf, "while writing to %s",
- backup);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while writing to %s",
+ backup);
}
} else
delflag = REMOVED;
}
(void) fclose(fp); /* open read-only, ignore errs */
if (fclose(fpout) == EOF) {
- (void) sprintf(errbuf, "while closing %s",backup);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while closing %s", backup);
return(ERR);
}
if (rename(backup,subsname) == -1) {
- (void) sprintf(errbuf,"while renaming %s to %s\n",
- backup,subsname);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while renaming %s to %s\n",
+ backup, subsname);
return(ERR);
}
return(delflag);
@@ -823,8 +836,8 @@ load_subs(int argc,
#ifdef CMU_ZCTL_PUNT
if (pind == SUBSATONCE) {
fix_macros(punts,subs2,pind);
- if (retval = ZPunt(subs2,pind,(u_short)wgport) !=
- ZERR_NONE)
+ if ((retval = ZPunt(subs2,pind,(u_short)wgport) !=
+ ZERR_NONE))
{
com_err(whoami, retval,
"while punting");
@@ -895,8 +908,8 @@ load_subs(int argc,
#ifdef CMU_ZCTL_PUNT
if (pind) {
fix_macros(punts,subs2,pind);
- if (retval = ZPunt(subs2,pind,(u_short)wgport) !=
- ZERR_NONE)
+ if ((retval = ZPunt(subs2,pind,(u_short)wgport) !=
+ ZERR_NONE))
{
com_err(whoami,retval,
"while punting");
@@ -933,7 +946,6 @@ current(int argc,
char *argv[])
{
FILE *fp = NULL;
- char errbuf[BUFSIZ];
ZSubscription_t subs;
int i,nsubs,retval,save,one,defs;
short wgport;
@@ -983,9 +995,8 @@ current(int argc,
(void) strcpy(backup,file);
(void) strcat(backup,".temp");
if (!(fp = fopen(backup,"w"))) {
- (void) sprintf(errbuf,"while opening %s for write",
- backup);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while opening %s for write",
+ backup);
return;
}
}
@@ -1012,14 +1023,12 @@ current(int argc,
if (save) {
if (fclose(fp) == EOF) {
- (void) sprintf(errbuf, "while closing %s", backup);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while closing %s", backup);
return;
}
if (rename(backup,file) == -1) {
- (void) sprintf(errbuf,"while renaming %s to %s",
- backup,file);
- com_err(whoami, retval, errbuf);
+ com_err(whoami, retval, "while renaming %s to %s",
+ backup, file);
(void) unlink(backup);
}
}
@@ -1028,21 +1037,18 @@ current(int argc,
int
make_exist(char *filename)
{
- char errbuf[BUFSIZ];
FILE *fpout;
if (!access(filename,F_OK))
return (0);
if (!(fpout = fopen(filename,"w"))) {
- (void) sprintf(errbuf,"while opening %s for write",filename);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno,"while opening %s for write", filename);
return (1);
}
if (fclose(fpout) == EOF) {
- (void) sprintf(errbuf, "while closing %s", filename);
- com_err(whoami, errno, errbuf);
+ com_err(whoami, errno, "while closing %s", filename);
return(1);
}
return (0);
@@ -1078,17 +1084,17 @@ fix_macros2(char *src, char **dest)
*dest = ZGetSender();
}
-int
-do_punt(int argc, char **argv)
+void
+do_punt(int argc, char *argv[])
{
#ifdef CMU_ZCTL_PUNT
- char *class, *inst, *recip, *msg, *whoami = argv[0];
+ char *class, *inst, *recip, *msg, *cmd = argv[0];
int retval, punt;
short newport;
struct sockaddr_in newsin;
ZNotice_t notice;
- if (! strcmp(whoami, "punt")) punt = 1;
+ if (! strcmp(cmd, "punt")) punt = 1;
else punt = 0;
switch (argc) {
@@ -1114,28 +1120,28 @@ do_punt(int argc, char **argv)
break;
default:
fprintf(stderr, "Usages:\n");
- fprintf(stderr, "\t%s instance\n", whoami);
- fprintf(stderr, "\t%s class instance\n", whoami);
- fprintf(stderr, "\t%s class instance recipient\n", whoami);
- return 1;
+ fprintf(stderr, "\t%s instance\n", cmd);
+ fprintf(stderr, "\t%s class instance\n", cmd);
+ fprintf(stderr, "\t%s class instance recipient\n", cmd);
+ return;
}
retval = ZOpenPort((u_short *) 0);
if(retval != ZERR_NONE) {
com_err(whoami, retval, "while opening Zephyr port.");
- return 1;
+ return;
}
newsin = ZGetDestAddr();
if ((newport = ZGetWGPort()) == -1) {
fprintf(stderr, "%s: Can't find windowgram port\n", whoami);
- return 1;
+ return;
}
newsin.sin_port = (unsigned short) newport;
if ((retval = ZSetDestAddr(&newsin)) != ZERR_NONE) {
com_err(whoami,retval,"while setting destination address");
- return 1;
+ return;
}
msg = (char *) malloc(strlen(class) + strlen(inst) + strlen(recip) + 4);
@@ -1167,15 +1173,15 @@ do_punt(int argc, char **argv)
ZClosePort();
#endif
- return 0;
+ return;
}
-int
-list_punts(int argc, char **argv)
+void
+list_punts(int argc, char *argv[])
{
#ifdef CMU_ZCTL_PUNT
ZNotice_t notice;
- int retval, lensofar;
+ int retval;
struct sockaddr_in old, to, from;
u_short ourport, zwgcport;
char *msg;
@@ -1184,20 +1190,20 @@ list_punts(int argc, char **argv)
retval = ZOpenPort(&ourport);
if(retval != ZERR_NONE) {
com_err("zctl", retval, "while opening Zephyr port.");
- return 1;
+ return;
}
old = ZGetDestAddr();
to = old;
if ((zwgcport = ZGetWGPort()) == (u_short)-1) {
fprintf(stderr, "zctl: Can't find windowgram port\n");
- return 1;
+ return;
}
to.sin_port = (u_short) zwgcport;
if ((retval = ZSetDestAddr(&to)) != ZERR_NONE) {
com_err("zctl",retval,"while setting destination address");
- return 1;
+ return;
}
memset((char *) &notice, 0, sizeof(ZNotice_t));
@@ -1226,7 +1232,7 @@ list_punts(int argc, char **argv)
if ((retval = ZSetDestAddr(&old)) != ZERR_NONE) {
com_err("zctl",retval,"while resetting destination address");
- return 1;
+ return;
}
msg = (char *) malloc((notice.z_message_len+1) * sizeof(char));
@@ -1238,7 +1244,7 @@ list_punts(int argc, char **argv)
(void) ZClosePort();
#endif /* CMU_ZCTL_PUNT */
- return 0;
+ return;
}
#ifndef HAVE_SS
diff --git a/clients/zlocate/zlocate.c b/clients/zlocate/zlocate.c
index 9f048f3..0ade6a0 100644
--- a/clients/zlocate/zlocate.c
+++ b/clients/zlocate/zlocate.c
@@ -21,21 +21,21 @@ static const char rcsid_zlocate_c[] = "$Id$";
int numusers=0, numleft=0, parallel=0, oneline=0;
char *whoami;
-RETSIGTYPE
+static RETSIGTYPE
timeout(int sig)
{
fprintf (stderr, "%s: no response from server\n", whoami);
exit(1);
}
-void
+static void
usage(void)
{
printf("Usage: %s [ -a | -d ] [ -p ] [ -1 ] user ... \n",whoami);
exit(1);
}
-void
+static void
print_locs(char *user,
int nlocs)
{
diff --git a/clients/zshutdown_notify/zshutdown_notify.c b/clients/zshutdown_notify/zshutdown_notify.c
index a682abf..2f51cc0 100644
--- a/clients/zshutdown_notify/zshutdown_notify.c
+++ b/clients/zshutdown_notify/zshutdown_notify.c
@@ -92,7 +92,7 @@ main(int argc,
}
retval = krb_get_svc_in_tkt(SVC_NAME, hn2, rlm,
SERVER_SERVICE, SERVER_INSTANCE, 1,
- KEYFILE);
+ (char *)KEYFILE);
if (retval) {
fprintf(stderr, "%s: can't get tickets: %s\n",
argv[0], krb_get_err_text(retval));
diff --git a/clients/zstat/zstat.c b/clients/zstat/zstat.c
index c18bb60..7ae5954 100644
--- a/clients/zstat/zstat.c
+++ b/clients/zstat/zstat.c
@@ -55,7 +55,7 @@ void do_stat(char *);
int srv_stat(char *);
int hm_stat(char *, char *);
-RETSIGTYPE
+static RETSIGTYPE
timeout(int ignored)
{
outoftime = 1;
@@ -69,8 +69,6 @@ main(int argc,
char hostname[NS_MAXDNAME];
int optchar;
struct servent *sp;
- extern char *optarg;
- extern int optind;
if ((ret = ZInitialize()) != ZERR_NONE) {
com_err("zstat", ret, "initializing");
@@ -145,7 +143,7 @@ hm_stat(char *host,
Code_t code;
char *line[20],*mp;
- int i,nf;
+ unsigned int i,nf;
struct hostent *hp;
time_t runtime;
struct tm *tim;
diff --git a/clients/zwrite/zwrite.c b/clients/zwrite/zwrite.c
index 41d2bf3..49dd06a 100644
--- a/clients/zwrite/zwrite.c
+++ b/clients/zwrite/zwrite.c
@@ -344,7 +344,7 @@ void
send_off(ZNotice_t *notice, int real)
{
int i, success, retval;
- char bfr[BUFSIZ], realm_recip[BUFSIZ], dest[3 * BUFSIZ];
+ char realm_recip[BUFSIZ], dest[3 * BUFSIZ];
ZNotice_t retnotice;
success = 0;
@@ -370,8 +370,7 @@ send_off(ZNotice_t *notice, int real)
class, inst,
nrecips?notice->z_recipient:"everyone");
if ((retval = ZSendNotice(notice, auth)) != ZERR_NONE) {
- (void) sprintf(bfr, "while sending notice to %s", dest);
- com_err(whoami, retval, bfr);
+ com_err(whoami, retval, "while sending notice to %s", dest);
break;
}
if (real && !quiet) {
@@ -384,9 +383,8 @@ send_off(ZNotice_t *notice, int real)
if ((retval = ZIfNotice(&retnotice, (struct sockaddr_in *) 0,
ZCompareUIDPred,
(char *)&notice->z_uid)) != ZERR_NONE) {
- (void) sprintf(bfr, "while waiting for acknowledgement for %s",
+ com_err(whoami, retval, "while waiting for acknowledgement for %s",
dest);
- com_err(whoami, retval, bfr);
continue;
}
if (retnotice.z_kind == SERVNAK) {
diff --git a/configure.ac b/configure.ac
index 77524a3..7ea77dd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -36,10 +36,15 @@ dnl Checks for header files.
AC_PATH_XTRA
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
-AC_CHECK_HEADERS(fcntl.h paths.h sgtty.h unistd.h malloc.h term.h)
+AC_CHECK_HEADERS(fcntl.h paths.h sgtty.h unistd.h malloc.h)
AC_CHECK_HEADERS(sys/filio.h sys/ioctl.h sys/time.h sys/file.h sys/utsname.h)
AC_CHECK_HEADERS(sys/select.h sys/msgbuf.h sys/cdefs.h krb5_err.h termcap.h)
AC_CHECK_HEADERS(arpa/nameser_compat.h stdbool.h termio.h curses.h)
+AC_CHECK_HEADERS([term.h], [], [],
+[#ifdef HAVE_CURSES_H
+#include <curses.h>
+#endif
+])
if test "$no_x" != "yes"; then
ZWGC_LIBX11=-lX11
@@ -301,6 +306,27 @@ if test "$ac_cv_krb5_auth_con_getauthenticator_takes_double_pointer" = yes; then
fi
AC_MSG_RESULT($krb5_authent_type)
+AC_CACHE_CHECK([krb5_auth_con_getflags out argument type],
+ [ac_cv_krb5_auth_con_flags_type], [
+local_save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="${CPPFLAGS} ${KRB5_INC_FLAGS}"
+for t in krb5_flags int32_t ; do
+ AC_TRY_COMPILE(
+ [#include <krb5.h>
+ extern krb5_error_code
+ krb5_auth_con_getflags(krb5_context, krb5_auth_context, $t *);],
+ [krb5_error_code foo = krb5_auth_con_getflags(0, 0, 0);],
+ [ac_cv_krb5_auth_con_flags_type=$t; break])
+done
+CPPFLAGS="${local_save_CPPFLAGS}"
+if test "x$ac_cv_krb5_auth_con_flags_type" = x ; then
+ AC_MSG_ERROR([Cannot identify krb5_auth_con_getflags function signature])
+fi
+])
+AC_DEFINE_UNQUOTED([KRB5_AUTH_CON_FLAGS_TYPE],
+ [$ac_cv_krb5_auth_con_flags_type],
+ [krb5_auth_con_getflags() output arg type])
+
AC_MSG_CHECKING(for enc_part2 in struct krb5_ticket)
AC_CACHE_VAL(ac_cv_have_krb5_ticket_enc_part2, [
local_save_CPPFLAGS="$CPPFLAGS"
diff --git a/h/internal.h b/h/internal.h
index 8ae74b0..5cf2128 100644
--- a/h/internal.h
+++ b/h/internal.h
@@ -105,6 +105,7 @@ typedef Code_t (*Z_SendProc) (ZNotice_t *, char *, int, int);
struct _Z_InputQ *Z_GetFirstComplete (void);
struct _Z_InputQ *Z_GetNextComplete (struct _Z_InputQ *);
+struct _Z_InputQ *Z_SearchQueue (ZUnique_Id_t *, ZNotice_Kind_t);
Code_t Z_XmitFragment (ZNotice_t*, char *,int,int);
void Z_RemQueue (struct _Z_InputQ *);
Code_t Z_AddNoticeToEntry (struct _Z_InputQ*, ZNotice_t*, int);
@@ -114,6 +115,7 @@ Code_t Z_FormatRawHeader (ZNotice_t *, char*, int,
int*, char **, char **);
Code_t Z_ReadEnqueue (void);
Code_t Z_ReadWait (void);
+int Z_PacketWaiting (void);
Code_t Z_SendLocation (char*, char*, Z_AuthProc, char*);
Code_t Z_SendFragmentedNotice (ZNotice_t *notice, int len,
Z_AuthProc cert_func,
@@ -153,6 +155,9 @@ unsigned long z_quad_cksum(const unsigned char *, uint32_t *, long,
int, unsigned char *);
Code_t ZFormatAuthenticNoticeV5(ZNotice_t*, char*, int, int*, krb5_keyblock *);
#endif
+#ifdef HAVE_KRB4
+Code_t ZFormatAuthenticNotice(ZNotice_t*, char*, int, int*, C_Block);
+#endif
#ifdef HAVE_KRB5_CREDS_KEYBLOCK_ENCTYPE
#define Z_keydata(keyblock) ((keyblock)->contents)
diff --git a/h/zephyr/zephyr.h b/h/zephyr/zephyr.h
index 536175a..a7eb17f 100644
--- a/h/zephyr/zephyr.h
+++ b/h/zephyr/zephyr.h
@@ -16,6 +16,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
+#include <com_err.h>
#include <zephyr/zephyr_err.h>
@@ -154,6 +155,7 @@ typedef Code_t (*Z_AuthProc)(ZNotice_t*, char *, int, int *);
Code_t ZMakeAuthentication(ZNotice_t*, char *,int, int*);
Code_t ZMakeZcodeAuthentication(ZNotice_t*, char *,int, int*);
Code_t ZMakeZcodeRealmAuthentication(ZNotice_t*, char *,int, int*, char*);
+Code_t ZResetAuthentication(void);
char *ZGetSender(void);
char *ZGetVariable(char *);
@@ -161,8 +163,6 @@ Code_t ZSetVariable(char *var, char *value);
Code_t ZUnsetVariable(char *var);
int ZGetWGPort(void);
Code_t ZSetDestAddr(struct sockaddr_in *);
-Code_t ZFormatNoticeList(ZNotice_t*, char**, int,
- char **, int*, Z_AuthProc);
Code_t ZParseNotice(char*, int, ZNotice_t *);
Code_t ZReadAscii(char*, int, unsigned char*, int);
Code_t ZReadAscii32(char *, int, unsigned long *);
@@ -172,14 +172,20 @@ Code_t ZSendPacket(char*, int, int);
Code_t ZSendList(ZNotice_t*, char *[], int, Z_AuthProc);
Code_t ZSrvSendList(ZNotice_t*, char*[], int, Z_AuthProc,
Code_t (*)(ZNotice_t *, char *, int, int));
+Code_t ZSendRawList(ZNotice_t*, char *[], int);
Code_t ZSendNotice(ZNotice_t *, Z_AuthProc);
+Code_t ZSendRawNotice(ZNotice_t *);
Code_t ZSrvSendNotice(ZNotice_t*, Z_AuthProc,
Code_t (*)(ZNotice_t *, char *, int, int));
Code_t ZFormatNotice(ZNotice_t*, char**, int*, Z_AuthProc);
-Code_t ZFormatSmallNotice(ZNotice_t*, ZPacket_t, int*, Z_AuthProc);
+Code_t ZNewFormatNotice(ZNotice_t*, char**, int*, Z_AuthProc);
+Code_t ZFormatNoticeList(ZNotice_t*, char**, int,
+ char **, int*, Z_AuthProc);
Code_t ZFormatRawNoticeList(ZNotice_t *, char *[], int, char **, int *);
+Code_t ZFormatSmallNotice(ZNotice_t*, ZPacket_t, int*, Z_AuthProc);
Code_t ZFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
Code_t ZNewFormatSmallRawNotice(ZNotice_t *, ZPacket_t, int *);
+Code_t ZFormatSmallRawNoticeList(ZNotice_t *, char *[], int, ZPacket_t, int *);
Code_t ZLocateUser(char *, int *, Z_AuthProc);
Code_t ZRequestLocations(char *, ZAsyncLocateData_t *,
ZNotice_Kind_t, Z_AuthProc);
@@ -187,7 +193,6 @@ Code_t ZhmStat(struct in_addr *, ZNotice_t *);
Code_t ZInitialize(void);
Code_t ZSetServerState(int);
Code_t ZSetFD(int);
-Code_t ZFormatSmallRawNotice(ZNotice_t*, ZPacket_t, int*);
int ZCompareUID(ZUnique_Id_t*, ZUnique_Id_t*);
Code_t ZSrvSendRawList(ZNotice_t*, char*[], int,
Code_t (*)(ZNotice_t *, char *, int, int));
@@ -228,6 +233,9 @@ Code_t ZPeekPacket(char **buffer, int *ret_len,
Code_t ZPeekNotice(ZNotice_t *notice, struct sockaddr_in *from);
Code_t ZIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
int (*predicate)(ZNotice_t *, void *), void *args);
+Code_t ZPeekIfNotice(ZNotice_t *notice, struct sockaddr_in *from,
+ int (*predicate)(ZNotice_t *, char *), char *args);
+Code_t ZPunt(ZSubscription_t *sublist, int nitems, unsigned int port);
Code_t ZSubscribeTo(ZSubscription_t *sublist, int nitems,
unsigned int port);
Code_t ZSubscribeToSansDefaults(ZSubscription_t *sublist, int nitems,
diff --git a/lib/ZCkZAut.c b/lib/ZCkZAut.c
index bc2e88f..4bc3e2a 100644
--- a/lib/ZCkZAut.c
+++ b/lib/ZCkZAut.c
@@ -44,7 +44,7 @@ Code_t ZCheckZcodeAuthentication(ZNotice_t *notice,
int valid;
char *cksum0_base, *cksum1_base = NULL, *cksum2_base;
char *x;
- unsigned char *asn1_data, *key_data;
+ unsigned char *asn1_data, *key_data, *cksum_data;
int asn1_len, key_len, cksum0_len = 0, cksum1_len = 0, cksum2_len = 0;
#endif
@@ -129,9 +129,9 @@ Code_t ZCheckZcodeAuthentication(ZNotice_t *notice,
away once Kerberos 4 does. */
if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') &&
key_len == 8 &&
- (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
+ (enctype == (krb5_enctype)ENCTYPE_DES_CBC_CRC ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD4 ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD5)) {
/* try old-format checksum (covers cksum0 only) */
ZChecksum_t our_checksum;
@@ -153,10 +153,11 @@ Code_t ZCheckZcodeAuthentication(ZNotice_t *notice,
}
/* HOLDING: creds, cksumbuf.data */
- memcpy(cksumbuf.data, cksum0_base, cksum0_len);
+ cksum_data = (unsigned char *)cksumbuf.data;
+ memcpy(cksum_data, cksum0_base, cksum0_len);
if (cksum1_len)
- memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
+ memcpy(cksum_data + cksum0_len, cksum1_base, cksum1_len);
+ memcpy(cksum_data + cksum0_len + cksum1_len,
cksum2_base, cksum2_len);
/* decode zcoded checksum */
diff --git a/lib/ZExpnRlm.c b/lib/ZExpnRlm.c
index 54c2fdb..6f904b6 100644
--- a/lib/ZExpnRlm.c
+++ b/lib/ZExpnRlm.c
@@ -3,8 +3,7 @@
#include <ctype.h>
char *
-ZExpandRealm(realm)
-char *realm;
+ZExpandRealm(char *realm)
{
char *cp1, *cp2;
static char expand[REALM_SZ];
diff --git a/lib/ZFmtAuth.c b/lib/ZFmtAuth.c
index 50e4073..f658f7c 100644
--- a/lib/ZFmtAuth.c
+++ b/lib/ZFmtAuth.c
@@ -38,7 +38,7 @@ ZFormatAuthenticNotice(ZNotice_t *notice,
return (retval);
newnotice.z_checksum =
- (ZChecksum_t)des_quad_cksum((unsigned char *)buffer, NULL, ptr - buffer, 0, (C_Block *)session);
+ (ZChecksum_t)des_quad_cksum((void *)buffer, NULL, ptr - buffer, 0, (C_Block *)session);
if ((retval = Z_FormatRawHeader(&newnotice, buffer, buffer_len,
&hdrlen, NULL, NULL)) != ZERR_NONE)
@@ -73,19 +73,23 @@ ZFormatAuthenticNoticeV5(ZNotice_t *notice,
int retval, hdrlen, hdr_adj;
krb5_enctype enctype;
krb5_cksumtype cksumtype;
+#ifdef HAVE_KRB4
int key_len;
+#endif
char *cksum_start, *cstart, *cend;
int cksum_len;
+#ifdef HAVE_KRB4
key_len = Z_keylen(keyblock);
+#endif
retval = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
if (retval)
return (ZAUTH_FAILED);
#ifdef HAVE_KRB4
- if (key_len == 8 && (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
+ if (key_len == 8 && (enctype == (krb5_enctype)ENCTYPE_DES_CBC_CRC ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD4 ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD5)) {
C_Block tmp;
memcpy(&tmp, Z_keydata(keyblock), key_len);
return ZFormatAuthenticNotice(notice, buffer, buffer_len, len,
diff --git a/lib/ZInit.c b/lib/ZInit.c
index 23dd4af..abaa2a4 100644
--- a/lib/ZInit.c
+++ b/lib/ZInit.c
@@ -24,9 +24,6 @@ static const char rcsid_ZInitialize_c[] =
#ifdef HAVE_KRB5
#include <krb5.h>
#endif
-#ifdef HAVE_KRB5_ERR_H
-#include <krb5_err.h>
-#endif
#ifndef INADDR_NONE
#define INADDR_NONE 0xffffffff
@@ -54,7 +51,8 @@ ZInitialize(void)
char addr[4], hostname[NS_MAXDNAME];
struct in_addr servaddr;
struct sockaddr_in sin;
- unsigned int s, sinsize = sizeof(sin);
+ unsigned int sinsize = sizeof(sin);
+ int s;
Code_t code;
ZNotice_t notice;
#ifdef HAVE_KRB5
@@ -244,10 +242,11 @@ struct sockaddr_in ZGetDestAddr (void) {
static int txt_lookup(char *qname, char **result) {
int ret, buflen, left;
void *buf = NULL;
+ void *bufend = NULL;
HEADER *hdr;
unsigned char *p;
char dname[NS_MAXDNAME];
- int queries, answers, stored;
+ int queries, answers;
ret = res_init();
if (ret < 0)
@@ -266,6 +265,7 @@ static int txt_lookup(char *qname, char **result) {
buflen = ret;
left = ret;
+ bufend = buflen + (unsigned char *)buf;
hdr = (HEADER *)buf;
p = buf;
@@ -275,7 +275,7 @@ static int txt_lookup(char *qname, char **result) {
left -= sizeof (HEADER);
while (queries--) {
- ret = dn_expand(buf, buf + buflen, p, dname, sizeof dname);
+ ret = dn_expand(buf, bufend, p, dname, sizeof dname);
if (ret < 0 || (ret + 4) > left)
return -1;
p += ret + 4;
@@ -285,11 +285,10 @@ static int txt_lookup(char *qname, char **result) {
if (!ret || !answers)
return -1;
- stored = 0;
while (answers--) {
int class, type;
- ret = dn_expand(buf, buf + buflen, p, dname, sizeof dname);
+ ret = dn_expand(buf, bufend, p, dname, sizeof dname);
if (ret < 0 || ret > left)
return -1;
p += ret;
diff --git a/lib/ZMakeZcode.c b/lib/ZMakeZcode.c
index 85c6f9d..63397a5 100644
--- a/lib/ZMakeZcode.c
+++ b/lib/ZMakeZcode.c
@@ -54,16 +54,16 @@ ZMakeZcode(register char *ptr,
case 0x00:
if (len < 3)
return ZERR_FIELDLEN;
- *ptr++ = 0xff;
- *ptr++ = 0xf0;
+ *(unsigned char *)ptr++ = 0xff;
+ *(unsigned char *)ptr++ = 0xf0;
len -= 2;
continue;
case 0xff:
if (len < 3)
return ZERR_FIELDLEN;
- *ptr++ = 0xff;
- *ptr++ = 0xf1;
+ *(unsigned char *)ptr++ = 0xff;
+ *(unsigned char *)ptr++ = 0xf1;
len -= 2;
continue;
diff --git a/lib/ZMkAuth.c b/lib/ZMkAuth.c
index 8b74570..8989481 100644
--- a/lib/ZMkAuth.c
+++ b/lib/ZMkAuth.c
@@ -123,7 +123,7 @@ ZMakeZcodeRealmAuthentication(register ZNotice_t *notice,
krb5_auth_context authctx;
krb5_data *authent;
char *cksum_start, *cstart, *cend;
- int cksum_len, zcode_len, phdr_adj;
+ int cksum_len, zcode_len = 0, phdr_adj;
notice->z_ascii_authent = NULL;
diff --git a/lib/ZParseNot.c b/lib/ZParseNot.c
index 9143a12..48311b5 100644
--- a/lib/ZParseNot.c
+++ b/lib/ZParseNot.c
@@ -242,7 +242,7 @@ ZParseNotice(char *buffer,
/* we will take it on faith that ipv6 addresses are longer than ipv4
addresses */
unsigned char addrbuf[sizeof(notice->z_sender_sockaddr.ip6.sin6_addr)];
- int len;
+ int alen;
/* because we're paranoid about naughtily misformatted packets */
if (memchr(ptr, '\0', end - ptr) == NULL)
@@ -250,24 +250,24 @@ ZParseNotice(char *buffer,
if (*ptr == 'Z') {
if (ZReadZcode((unsigned char *)ptr, addrbuf,
- sizeof(addrbuf), &len) == ZERR_BADFIELD)
+ sizeof(addrbuf), &alen) == ZERR_BADFIELD)
BAD_PACKET("parsing Zcode address");
} else {
- len = sizeof(notice->z_sender_sockaddr.ip4.sin_addr);
+ alen = sizeof(notice->z_sender_sockaddr.ip4.sin_addr);
if (ZReadAscii(ptr, end - ptr, (unsigned char *)addrbuf,
- len) == ZERR_BADFIELD)
+ alen) == ZERR_BADFIELD)
BAD_PACKET("parsing NetASCII address");
}
- if (len == sizeof(notice->z_sender_sockaddr.ip6.sin6_addr)) {
+ if (alen == sizeof(notice->z_sender_sockaddr.ip6.sin6_addr)) {
notice->z_sender_sockaddr.ip6.sin6_family = AF_INET6;
- memcpy(&notice->z_sender_sockaddr.ip6.sin6_addr, addrbuf, len);
+ memcpy(&notice->z_sender_sockaddr.ip6.sin6_addr, addrbuf, alen);
#ifdef HAVE_SOCKADDR_IN6_SIN6_LEN
notice->z_sender_sockaddr.ip6.sin6_len = sizeof(notice->z_sender_sockaddr.ip6);
#endif
- } else if (len == sizeof(notice->z_sender_sockaddr.ip4.sin_addr)) {
+ } else if (alen == sizeof(notice->z_sender_sockaddr.ip4.sin_addr)) {
notice->z_sender_sockaddr.ip4.sin_family = AF_INET;
- memcpy(&notice->z_sender_sockaddr.ip4.sin_addr, addrbuf, len);
+ memcpy(&notice->z_sender_sockaddr.ip4.sin_addr, addrbuf, alen);
#ifdef HAVE_SOCKADDR_IN_SIN_LEN
notice->z_sender_sockaddr.ip4.sin_len = sizeof(notice->z_sender_sockaddr.ip4);
#endif
diff --git a/lib/ZReadAscii.c b/lib/ZReadAscii.c
index 49aaa58..69c1ecd 100644
--- a/lib/ZReadAscii.c
+++ b/lib/ZReadAscii.c
@@ -28,7 +28,7 @@ ZReadAscii(char *ptr,
int i;
unsigned int hexbyte;
register int c1, c2;
- register unsigned int temp;
+ register int temp;
for (i=0;i<num;i++) {
if (len >= 1 && *ptr == ' ') {
diff --git a/lib/ZVariables.c b/lib/ZVariables.c
index 6f06bab..fb8c9e5 100644
--- a/lib/ZVariables.c
+++ b/lib/ZVariables.c
@@ -168,7 +168,7 @@ static int
varline(char *bfr, char *var)
{
register char *cp;
-
+ size_t namelen;
if (!bfr[0] || bfr[0] == '#') /* comment or null line */
return (0);
@@ -179,7 +179,8 @@ varline(char *bfr, char *var)
#define max(a,b) ((a > b) ? (a) : (b))
- if (strncasecmp(bfr, var, max(strlen(var),cp - bfr)))
+ namelen = cp - bfr;
+ if (strncasecmp(bfr, var, max(strlen(var), namelen)))
return(0); /* var is not the var in
bfr ==> no match */
diff --git a/lib/Zinternal.c b/lib/Zinternal.c
index 7e3e904..0f692f3 100644
--- a/lib/Zinternal.c
+++ b/lib/Zinternal.c
@@ -87,7 +87,7 @@ Code_t
Z_krb5_lookup_cksumtype(krb5_enctype e,
krb5_cksumtype *c)
{
- int i;
+ unsigned int i;
for (i = 0; i < N_CKSUM_MAP; i++) {
if (cksum_map[i].e == e) {
@@ -188,12 +188,12 @@ int
Z_PacketWaiting(void)
{
struct timeval tv;
- fd_set read;
+ fd_set readfds;
tv.tv_sec = tv.tv_usec = 0;
- FD_ZERO(&read);
- FD_SET(ZGetFD(), &read);
- return (select(ZGetFD() + 1, &read, NULL, NULL, &tv));
+ FD_ZERO(&readfds);
+ FD_SET(ZGetFD(), &readfds);
+ return (select(ZGetFD() + 1, &readfds, NULL, NULL, &tv));
}
@@ -254,7 +254,8 @@ Z_SearchQueue(ZUnique_Id_t *uid,
if (ZCompareUID(uid, &qptr->uid) && qptr->kind == kind)
return (qptr);
next = qptr->next;
- if (qptr->timep && (qptr->timep+Z_NOTICETIMELIMIT < tv.tv_sec))
+ if (qptr->timep &&
+ (qptr->timep+Z_NOTICETIMELIMIT < (unsigned long)tv.tv_sec))
Z_RemQueue(qptr);
qptr = next;
}
@@ -1154,9 +1155,9 @@ Z_SendFragmentedNotice(ZNotice_t *notice,
Code_t Z_XmitFragment(ZNotice_t *notice,
char *buf,
int len,
- int wait)
+ int waitforack)
{
- return(ZSendPacket(buf, len, wait));
+ return(ZSendPacket(buf, len, waitforack));
}
/* For debugging printing */
@@ -1285,14 +1286,13 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock,
int cksum1_len; /* length of part after checksum */
krb5_data cksumbuf;
krb5_data cksum;
- unsigned char *key_data;
- int key_len;
+ unsigned char *cksum_data;
+ unsigned int cksum_data_len;
+ char *cksum_out_data;
krb5_enctype enctype;
krb5_cksumtype cksumtype;
Code_t result;
- key_data = Z_keydata(keyblock);
- key_len = Z_keylen(keyblock);
result = Z_ExtractEncCksum(keyblock, &enctype, &cksumtype);
if (result)
return (ZAUTH_FAILED);
@@ -1306,19 +1306,22 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock,
cksumbuf.data = malloc(cksumbuf.length);
if (!cksumbuf.data)
return ENOMEM;
- memcpy(cksumbuf.data, cksum_start, cksum0_len);
- memcpy(cksumbuf.data + cksum0_len, cend, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
+ cksum_data = (unsigned char *)cksumbuf.data;
+ memcpy(cksum_data, cksum_start, cksum0_len);
+ memcpy(cksum_data + cksum0_len, cend, cksum1_len);
+ memcpy(cksum_data + cksum0_len + cksum1_len,
notice->z_message, notice->z_message_len);
/* compute the checksum */
result = Z_Checksum(&cksumbuf, keyblock, cksumtype,
from_server ? Z_KEYUSAGE_SRV_CKSUM
: Z_KEYUSAGE_CLT_CKSUM,
- (char **)&cksum.data, &cksum.length);
+ &cksum_out_data, &cksum_data_len);
if (result) {
free(cksumbuf.data);
return result;
}
+ cksum.data = cksum_out_data;
+ cksum.length = cksum_data_len;
/*
* OK.... we can zcode to a space starting at 'cstart',
@@ -1332,7 +1335,7 @@ Z_InsertZcodeChecksum(krb5_keyblock *keyblock,
free(cksum.data);
if (!result) {
int zcode_len = strlen(cstart) + 1;
- memcpy(cstart + zcode_len, cksumbuf.data + cksum0_len, cksum1_len);
+ memcpy(cstart + zcode_len, cksum_data + cksum0_len, cksum1_len);
*length_adjust = zcode_len - cksum_len + (cksum0_len + cksum1_len);
}
free(cksumbuf.data);
@@ -1366,7 +1369,6 @@ Z_krb5_verify_cksum(krb5_keyblock *keyblock,
#else
krb5_crypto cryptctx;
Checksum checksum;
- size_t xlen;
#endif
memset(&checksum, 0, sizeof(checksum));
diff --git a/lib/charset.c b/lib/charset.c
index 34806e3..14aec28 100644
--- a/lib/charset.c
+++ b/lib/charset.c
@@ -104,32 +104,33 @@ ZTransliterate(char *in, int inlen, char *inset, char *outset, char **out, int *
free(outset_t);
- if (ih != (iconv_t)-1) {
- size = inlen; /* doubling this should be enough, but.. */
- do {
- size = size * 2;
-
- *out = malloc(size);
- if (*out == NULL) {
- iconv_close(ih);
- return errno;
- }
-
- inleft = inlen;
- outleft = size;
-
- inp = in;
- outp = *out;
-
- retval = iconv(ih, &inp, &inleft, &outp, &outleft);
- if (retval < 0)
- free(*out);
- } while (retval < 0 && errno == E2BIG);
-
- iconv_close(ih);
- }
+ if (ih == (iconv_t)-1)
+ return errno;
+
+ size = inlen; /* doubling this should be enough, but.. */
+ do {
+ size = size * 2;
+
+ *out = malloc(size);
+ if (*out == NULL) {
+ iconv_close(ih);
+ return errno;
+ }
+
+ inleft = inlen;
+ outleft = size;
+
+ inp = in;
+ outp = *out;
+
+ retval = iconv(ih, &inp, &inleft, &outp, &outleft);
+ if (retval < 0)
+ free(*out);
+ } while (retval < 0 && errno == E2BIG);
+
+ iconv_close(ih);
- if (ih == (iconv_t)-1 || retval < 0)
+ if (retval < 0)
return errno;
*outlen = size - outleft;
diff --git a/server/access.h b/server/access.h
index d9802d0..910770f 100644
--- a/server/access.h
+++ b/server/access.h
@@ -36,7 +36,3 @@ void access_reinit(void);
/* found in acl_files.c */
int acl_load(char *);
-
-/* external data relevant */
-extern int zdebug;
-
diff --git a/server/acl_files.c b/server/acl_files.c
index e62451a..e7bfc0c 100644
--- a/server/acl_files.c
+++ b/server/acl_files.c
@@ -60,8 +60,8 @@ static const char rcsid_acl_files_c[] = "$Id$";
/* If realm is missing, it becomes the local realm */
/* Canonicalized form is put in canon, which must be big enough to hold
MAX_PRINCIPAL_SIZE characters */
-void acl_canonicalize_principal(char *principal,
- char *canon)
+static void
+acl_canonicalize_principal(char *principal, char *canon)
{
char *end;
char *dot, *atsign;
@@ -240,7 +240,8 @@ add_host(struct host_ace **list,
{
struct host_ace *e;
struct in_addr addr;
- unsigned long mask = 0, i;
+ unsigned long mask = 0;
+ long i;
char *m, *x;
m = strchr(buf, '/');
@@ -395,7 +396,7 @@ acl_cache_reset(void)
/* Returns nonzero if it can be determined that acl contains principal */
/* Principal is not canonicalized, and no wildcarding is done */
/* If neg is nonzero, we look for negative entries */
-int
+static int
acl_exact_match(char *acl,
char *principal,
int neg)
@@ -412,7 +413,7 @@ acl_exact_match(char *acl,
/* Returns nonzero if it can be determined that acl contains who */
/* If neg is nonzero, we look for negative entries */
-int
+static int
acl_host_match(char *acl,
unsigned long who,
int neg)
@@ -442,7 +443,6 @@ acl_check(char *acl,
char buf[MAX_PRINCIPAL_SIZE];
char canon[MAX_PRINCIPAL_SIZE];
char *instance, *realm;
- unsigned long mask;
int p, i, r, result = 0;
if (principal) {
diff --git a/server/bdump.c b/server/bdump.c
index 9982271..c790d8f 100644
--- a/server/bdump.c
+++ b/server/bdump.c
@@ -411,7 +411,7 @@ bdump_send(void)
(void) strcpy(instance, "*"); /* let Kerberos fill it in */
ticket.length = len;
- memcpy(&ticket.dat, data, MIN(len, sizeof(ticket.dat)));
+ memcpy(&ticket.dat, data, MIN(len, (int)sizeof(ticket.dat)));
retval = krb_rd_req(&ticket, SERVER_SERVICE, instance,
from.sin_addr.s_addr, &kdata, srvtab_file);
/*
@@ -858,7 +858,8 @@ transmit_tcp(char *pack, int packlen)
syslog(LOG_WARNING, "transmit_tcp: writing length: %m");
retval = errno;
} else {
- syslog(LOG_WARNING, "transmit_tcp: writing length: %d vs %d", sizeof(length), count);
+ syslog(LOG_WARNING, "transmit_tcp: writing length: %lu vs %d",
+ (unsigned long)sizeof(length), count);
retval = ZSRV_LEN;
}
goto cleanup;
@@ -1177,6 +1178,8 @@ bdump_recv_loop(Server *server)
Client *client = NULL;
struct sockaddr_in who;
#ifdef HAVE_KRB5
+ uint32_t client_enctype;
+ uint32_t client_keysize;
unsigned char buf[512];
int blen;
#endif
@@ -1318,9 +1321,11 @@ bdump_recv_loop(Server *server)
syslog(LOG_ERR,"bdump_recv_loop: bad keyblock read: %s (%s)",
error_message(retval), cp);
} else {
+ memcpy(&client_enctype, &buf[0], sizeof(uint32_t));
+ memcpy(&client_keysize, &buf[4], sizeof(uint32_t));
retval = Z_krb5_init_keyblock(Z_krb5_ctx,
- ntohl(*(krb5_enctype *)&buf[0]),
- ntohl(*(uint32_t *)&buf[4]),
+ ntohl(client_enctype),
+ ntohl(client_keysize),
&client->session_keyblock);
if (retval) {
syslog(LOG_ERR, "bdump_recv_loop: failed to allocate keyblock: %s",
@@ -1533,12 +1538,12 @@ get_packet(char **packet, int *buflen, int *retlen)
char *p;
result = net_read(input, (char *) &length, sizeof(unsigned short));
- if (result < sizeof(short)) {
+ if (result < (int)sizeof(short)) {
if (result < 0) {
return errno;
} else {
- syslog(LOG_ERR, "get_packet: received length: %d vs %d (%m)", result,
- sizeof(short));
+ syslog(LOG_ERR, "get_packet: received length: %d vs %lu (%m)",
+ result, (unsigned long)sizeof(short));
return ZSRV_LEN;
}
}
diff --git a/server/dispatch.c b/server/dispatch.c
index eaacc2c..8b9507a 100644
--- a/server/dispatch.c
+++ b/server/dispatch.c
@@ -230,7 +230,6 @@ dispatch(ZNotice_t *notice,
{
Code_t status;
String *notice_class;
- struct sockaddr_in who2;
int authflag;
ZRealm *realm;
char *cp;
@@ -252,8 +251,6 @@ dispatch(ZNotice_t *notice,
return;
}
- who2 = *who;
-
notice_class = make_string(notice->z_class,1);
if (from_server) {
@@ -681,12 +678,13 @@ xmit(ZNotice_t *notice,
}
/* now we've sent it, mark it as not ack'ed */
- if (!retval)
+ if (!retval) {
nacked = (Unacked *) malloc(sizeof(Unacked));
- if (!nacked) {
- /* no space: just punt */
- syslog(LOG_WARNING, "xmit nack malloc");
- retval = ENOMEM;
+ if (!nacked) {
+ /* no space: just punt */
+ syslog(LOG_WARNING, "xmit nack malloc");
+ retval = ENOMEM;
+ }
}
if (!retval) {
@@ -777,7 +775,6 @@ clt_ack(ZNotice_t *notice,
ZNotice_t acknotice;
ZPacket_t ackpack;
int packlen;
- char *sent_name;
Code_t retval;
if (bdumping) { /* don't ack while dumping */
@@ -791,21 +788,17 @@ clt_ack(ZNotice_t *notice,
switch (sent) {
case SENT:
acknotice.z_message = ZSRVACK_SENT;
- sent_name = "sent";
break;
case NOT_FOUND:
acknotice.z_message = ZSRVACK_FAIL;
acknotice.z_kind = SERVNAK;
- sent_name = "fail";
break;
case AUTH_FAILED:
acknotice.z_kind = SERVNAK;
acknotice.z_message = ZSRVACK_NOTSENT;
- sent_name = "nak/not_sent";
break;
case NOT_SENT:
acknotice.z_message = ZSRVACK_NOTSENT;
- sent_name = "not_sent";
break;
default:
abort ();
@@ -892,7 +885,7 @@ hostm_dispatch(ZNotice_t *notice,
Server *server)
{
char *opcode = notice->z_opcode;
- int i, add = 0, remove = 0;
+ int i, add_it = 0, remove_it = 0;
if (notice->z_kind == HMACK) {
/* Ignore. */
@@ -908,23 +901,23 @@ hostm_dispatch(ZNotice_t *notice,
if (server == me_server) {
server_forward(notice, auth, who);
ack(notice, who);
- add = 1;
+ add_it = 1;
}
} else if (strcmp(opcode, HM_ATTACH) == 0) {
if (server == me_server) {
server_forward(notice, auth, who);
ack(notice, who);
- add = 1;
+ add_it = 1;
} else {
- remove = 1;
+ remove_it = 1;
}
} else if (strcmp(opcode, HM_DETACH) == 0) {
- remove = 1;
+ remove_it = 1;
} else {
syslog(LOG_WARNING, "hm_dispatch: unknown opcode %s", opcode);
}
- if (add) {
+ if (add_it) {
for (i = 0; i < num_hosts; i++) {
if (hosts[i].s_addr == who->sin_addr.s_addr)
break;
@@ -945,7 +938,7 @@ hostm_dispatch(ZNotice_t *notice,
}
hosts[num_hosts++] = who->sin_addr;
}
- } else if (remove) {
+ } else if (remove_it) {
for (i = 0; i < num_hosts; i++) {
if (hosts[i].s_addr == who->sin_addr.s_addr) {
memmove(&hosts[i], &hosts[i + 1], num_hosts - (i + 1));
diff --git a/server/kstuff.c b/server/kstuff.c
index 290a1e4..e405734 100644
--- a/server/kstuff.c
+++ b/server/kstuff.c
@@ -45,7 +45,7 @@ GetKerberosData(int fd, /* file descr. to read from */
{
char p[20];
KTEXT_ST ticket; /* will get Kerberos ticket from client */
- int i;
+ unsigned int i;
char instance[INST_SZ];
/*
@@ -105,8 +105,8 @@ SendKerberosData(int fd, /* file descriptor to write onto */
{
int rem;
char p[32];
- int written;
- int size_to_write;
+ size_t written;
+ size_t size_to_write;
rem = krb_mk_req(ticket, service, host, (char *)ZGetRealm(), (u_long) 0);
if (rem != KSUCCESS)
@@ -115,10 +115,10 @@ SendKerberosData(int fd, /* file descriptor to write onto */
(void) sprintf(p,"%d ",ticket->length);
size_to_write = strlen (p);
if ((written = write(fd, p, size_to_write)) != size_to_write)
- return (written < 0) ? errno : ZSRV_PKSHORT;
+ return ((ssize_t)written < 0) ? errno : ZSRV_PKSHORT;
if ((written = write(fd, ticket->dat, ticket->length))
!= ticket->length)
- return (written < 0) ? errno : ZSRV_PKSHORT;
+ return ((ssize_t)written < 0) ? errno : ZSRV_PKSHORT;
return 0;
}
@@ -190,7 +190,7 @@ ReadKerberosData(int fd, int *size, char **data, int *proto) {
Code_t
GetKrb5Data(int fd, krb5_data *data) {
char p[20];
- int i;
+ unsigned int i;
char *dst;
for (i=0; i<20; i++) {
@@ -229,12 +229,12 @@ GetKrb5Data(int fd, krb5_data *data) {
Code_t
SendKrb5Data(int fd, krb5_data *data) {
char p[32];
- int written, size_to_write;
- sprintf(p, "V5-%d ", data->length);
+ size_t written, size_to_write;
+ sprintf(p, "V5-%lu ", (unsigned long)data->length);
size_to_write = strlen (p);
if (size_to_write != (written = write(fd, p, size_to_write)) ||
data->length != (written = write(fd, data->data, data->length))) {
- return (written < 0) ? errno : ZSRV_PKSHORT;
+ return ((ssize_t)written < 0) ? errno : ZSRV_PKSHORT;
}
return 0;
}
@@ -262,9 +262,9 @@ ZCheckSrvAuthentication(ZNotice_t *notice,
int valid;
char *cksum0_base, *cksum1_base = NULL, *cksum2_base;
char *x;
- unsigned char *asn1_data, *key_data;
+ unsigned char *asn1_data, *key_data, *cksum_data;
int asn1_len, key_len, cksum0_len = 0, cksum1_len = 0, cksum2_len = 0;
- krb5_flags acflags;
+ KRB5_AUTH_CON_FLAGS_TYPE acflags;
#ifdef KRB5_AUTH_CON_GETAUTHENTICATOR_TAKES_DOUBLE_POINTER
krb5_authenticator *authenticator;
#define KRB5AUTHENT authenticator
@@ -511,9 +511,9 @@ ZCheckSrvAuthentication(ZNotice_t *notice,
/*XXX we may wish to ditch this code someday?*/
if ((!notice->z_ascii_checksum || *notice->z_ascii_checksum != 'Z') &&
key_len == 8 &&
- (enctype == ENCTYPE_DES_CBC_CRC ||
- enctype == ENCTYPE_DES_CBC_MD4 ||
- enctype == ENCTYPE_DES_CBC_MD5)) {
+ (enctype == (krb5_enctype)ENCTYPE_DES_CBC_CRC ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD4 ||
+ enctype == (krb5_enctype)ENCTYPE_DES_CBC_MD5)) {
/* try old-format checksum (covers cksum0 only) */
ZChecksum_t our_checksum;
@@ -548,10 +548,11 @@ ZCheckSrvAuthentication(ZNotice_t *notice,
}
/* HOLDING: authctx, authenticator, cksumbuf.data */
- memcpy(cksumbuf.data, cksum0_base, cksum0_len);
+ cksum_data = (unsigned char *)cksumbuf.data;
+ memcpy(cksum_data, cksum0_base, cksum0_len);
if (cksum1_len)
- memcpy(cksumbuf.data + cksum0_len, cksum1_base, cksum1_len);
- memcpy(cksumbuf.data + cksum0_len + cksum1_len,
+ memcpy(cksum_data + cksum0_len, cksum1_base, cksum1_len);
+ memcpy(cksum_data + cksum0_len + cksum1_len,
cksum2_base, cksum2_len);
/* decode zcoded checksum */
@@ -685,10 +686,9 @@ static ZChecksum_t compute_rlm_checksum(ZNotice_t *notice,
unsigned char *session_key)
{
ZChecksum_t checksum;
- char *cstart, *cend, *hstart = notice->z_packet;
+ char *cstart, *hstart = notice->z_packet;
cstart = notice->z_default_format + strlen(notice->z_default_format) + 1;
- cend = cstart + strlen(cstart) + 1;
checksum = z_quad_cksum((unsigned char *)hstart, NULL,
cstart - hstart, 0, session_key);
@@ -734,7 +734,7 @@ ZSetSession(krb5_keyblock *keyblock) {
}
if (result) /*XXX we're out of memory? */
- ;
+ return;
}
#endif
#ifdef HAVE_KRB4
diff --git a/server/main.c b/server/main.c
index ee4cc18..6cab996 100644
--- a/server/main.c
+++ b/server/main.c
@@ -151,8 +151,6 @@ main(int argc,
struct sigaction action;
#endif
int optchar; /* option processing */
- extern char *optarg;
- extern int optind;
sprintf(list_file, "%s/zephyr/%s", SYSCONFDIR, SERVER_LIST_FILE);
#ifdef HAVE_KRB4
diff --git a/server/realm.c b/server/realm.c
index aef23c5..858a397 100644
--- a/server/realm.c
+++ b/server/realm.c
@@ -144,7 +144,7 @@ kill_realm_pids(void)
return;
}
-ZRealmname *
+static ZRealmname *
get_realm_lists(char *file)
{
ZRealmname *rlm_list, *rlm;
@@ -277,18 +277,6 @@ realm_sender_in_realm(const char *realm, char *sender)
return 0;
}
-int sender_in_realm(ZNotice_t *notice)
-{
- char *realm;
-
- realm = strchr(notice->z_sender, '@');
-
- if (!realm || !strcmp(realm + 1, ZGetRealm()))
- return 1;
-
- return 0;
-}
-
ZRealm *
realm_which_realm(struct sockaddr_in *who)
{
@@ -471,11 +459,11 @@ realm_init(void)
int ii, jj, found;
struct in_addr *addresses;
struct hostent *hp;
- char list_file[128];
+ char realm_list_file[128];
char rlmprinc[MAX_PRINCIPAL_SIZE];
- sprintf(list_file, "%s/zephyr/%s", SYSCONFDIR, REALM_LIST_FILE);
- rlmnames = get_realm_lists(list_file);
+ sprintf(realm_list_file, "%s/zephyr/%s", SYSCONFDIR, REALM_LIST_FILE);
+ rlmnames = get_realm_lists(realm_list_file);
if (!rlmnames) {
zdbug((LOG_DEBUG, "No other realms"));
nrealms = 0;
@@ -1035,9 +1023,10 @@ rlm_rexmit(void *arg)
nackpacket->timer =
timer_set_rel(rexmit_times[nackpacket->rexmits%NUM_REXMIT_TIMES],
rlm_rexmit, nackpacket);
- if (rexmit_times[nackpacket->rexmits%NUM_REXMIT_TIMES] == -1)
+ if (rexmit_times[nackpacket->rexmits%NUM_REXMIT_TIMES] == -1) {
zdbug((LOG_DEBUG, "rlm_rexmit(%s): would send at -1 to %s",
realm->name, inet_ntoa((realm->addrs[realm->idx]).sin_addr)));
+ }
return;
}
@@ -1142,7 +1131,7 @@ realm_sendit_auth(ZNotice_t *notice,
*/
if (!retval &&
- ((notice->z_message_len+hdrlen > sizeof(ZPacket_t)) ||
+ ((notice->z_message_len+hdrlen > (int)sizeof(ZPacket_t)) ||
(notice->z_message_len+hdrlen > Z_MAXPKTLEN))) {
/* Reallocate buffers inside the refragmenter */
diff --git a/server/server.c b/server/server.c
index b393f64..40551bc 100644
--- a/server/server.c
+++ b/server/server.c
@@ -446,7 +446,7 @@ server_timo(void *arg)
auth = 0;
break;
default:
- syslog(LOG_ERR,"Bad server state, server 0x%p\n", which);
+ syslog(LOG_ERR,"Bad server state, server 0x%p\n", (void *)which);
abort();
}
/* now he's either TARDY, STARTING, or DEAD
diff --git a/server/subscr.c b/server/subscr.c
index d276958..b788663 100644
--- a/server/subscr.c
+++ b/server/subscr.c
@@ -20,6 +20,10 @@ static const char rcsid_subscr_c[] = "$Id$";
#endif
#endif
+#ifndef INADDR_NONE
+#define INADDR_NONE 0xffffffff
+#endif
+
/*
* The subscription manager.
*
@@ -347,7 +351,6 @@ subscr_realm_cancel(struct sockaddr_in *sin,
ZRealm *realm)
{
Destlist *cancel_subs, *subs, *client_subs, *next, *next2;
- Code_t retval;
int found = 0;
if (!realm)
@@ -366,7 +369,7 @@ subscr_realm_cancel(struct sockaddr_in *sin,
next2 = client_subs->next;
if (ZDest_eq(&client_subs->dest, &subs->dest)) {
Destlist_delete(client_subs);
- retval = triplet_deregister(realm->client, &client_subs->dest, realm);
+ triplet_deregister(realm->client, &client_subs->dest, realm);
free_subscription(client_subs);
found = 1;
break;
@@ -1235,19 +1238,24 @@ Code_t subscr_foreign_user(ZNotice_t *notice,
Client *client;
ZNotice_t snotice;
struct sockaddr_in newwho;
- char *cp, *tp0, *tp1;
+ char *cp, *tp0;
+#ifdef DEBUG
+ char *tp1;
+#endif
char rlm_recipient[REALM_SZ + 1];
tp0 = cp = notice->z_message;
newwho.sin_addr.s_addr = inet_addr(cp);
- if (newwho.sin_addr.s_addr == -1) {
+ if (newwho.sin_addr.s_addr == INADDR_NONE) {
syslog(LOG_ERR, "malformed addr from %s", notice->z_sender);
return(ZERR_NONE);
}
I_ADVANCE(0);
+#ifdef DEBUG
tp1 = cp;
+#endif
snotice = *notice;
diff --git a/server/utf8proc.c b/server/utf8proc.c
index 1c02241..40530b9 100644
--- a/server/utf8proc.c
+++ b/server/utf8proc.c
@@ -385,7 +385,7 @@ ssize_t utf8proc_decompose(
if (decomp_result < 0) return decomp_result;
wpos += decomp_result;
// prohibiting integer overflows due to too long strings:
- if (wpos < 0 || wpos > SSIZE_MAX/sizeof(int32_t)/2)
+ if (wpos < 0 || wpos > (ssize_t)(SSIZE_MAX/sizeof(int32_t)/2))
return UTF8PROC_ERROR_OVERFLOW;
}
}
diff --git a/server/zserver.h b/server/zserver.h
index 874b11a..cb36749 100644
--- a/server/zserver.h
+++ b/server/zserver.h
@@ -64,6 +64,27 @@ typedef struct {
} Sched;
#endif
+enum _ZRealm_state {
+ REALM_UP, /* ZRealm is up */
+ REALM_TARDY, /* ZRealm due for a hello XXX */
+ REALM_DEAD, /* ZRealm is considered dead */
+ REALM_STARTING /* ZRealm is between dead and up */
+};
+
+enum _Server_state {
+ SERV_UP, /* Server is up */
+ SERV_TARDY, /* Server due for a hello */
+ SERV_DEAD, /* Server is considered dead */
+ SERV_STARTING /* Server is between dead and up */
+};
+
+enum _Sent_type {
+ NOT_SENT, /* message was not xmitted */
+ SENT, /* message was xmitted */
+ AUTH_FAILED, /* authentication failed */
+ NOT_FOUND /* user not found for uloc */
+};
+
typedef struct _Destination Destination;
typedef struct _Destlist Destlist;
typedef struct _ZRealm ZRealm;
@@ -89,13 +110,6 @@ struct _Destlist {
struct _Destlist *next, **prev_p;
};
-enum _ZRealm_state {
- REALM_UP, /* ZRealm is up */
- REALM_TARDY, /* ZRealm due for a hello XXX */
- REALM_DEAD, /* ZRealm is considered dead */
- REALM_STARTING /* ZRealm is between dead and up */
-};
-
struct _ZRealm {
char name[REALM_SZ];
int count;
@@ -141,13 +155,6 @@ struct _Triplet {
struct _Triplet *next, **prev_p;
};
-enum _Server_state {
- SERV_UP, /* Server is up */
- SERV_TARDY, /* Server due for a hello */
- SERV_DEAD, /* Server is considered dead */
- SERV_STARTING /* Server is between dead and up */
-};
-
struct _Unacked {
Timer *timer; /* timer for retransmit */
Client *client; /* responsible client, or NULL */
@@ -188,13 +195,6 @@ struct _Server {
char addr_str[16]; /* text version of address */
};
-enum _Sent_type {
- NOT_SENT, /* message was not xmitted */
- SENT, /* message was xmitted */
- AUTH_FAILED, /* authentication failed */
- NOT_FOUND /* user not found for uloc */
-};
-
/* statistics gathering */
struct _Statistic {
int val;
@@ -226,14 +226,14 @@ struct _Statistic {
if((elem)->next) (elem)->next->prev_p = (elem)->prev_p; \
}
-MAKE_LIST_INSERT(Destlist);
-MAKE_LIST_DELETE(Destlist);
-MAKE_LIST_INSERT(Client);
-MAKE_LIST_DELETE(Client);
-MAKE_LIST_INSERT(Triplet);
-MAKE_LIST_DELETE(Triplet);
-MAKE_LIST_INSERT(Unacked);
-MAKE_LIST_DELETE(Unacked);
+MAKE_LIST_INSERT(Destlist)
+MAKE_LIST_DELETE(Destlist)
+MAKE_LIST_INSERT(Client)
+MAKE_LIST_DELETE(Client)
+MAKE_LIST_INSERT(Triplet)
+MAKE_LIST_DELETE(Triplet)
+MAKE_LIST_INSERT(Unacked)
+MAKE_LIST_DELETE(Unacked)
/* found in bdump.c */
void bdump_get(ZNotice_t *notice, int auth, struct sockaddr_in *who,
@@ -339,6 +339,7 @@ void subscr_reset(void);
Code_t subscr_def_subs(Client *who);
Code_t subscr_realm(ZRealm *, ZNotice_t *);
Code_t subscr_send_realm_subs(ZRealm *);
+Code_t subscr_realm_subs(ZRealm *);
Code_t subscr_realm_cancel(struct sockaddr_in *, ZNotice_t *, ZRealm *);
/* found in uloc.c */
@@ -411,7 +412,7 @@ extern char subs_file[];
extern const char version[];
extern u_long npackets; /* num of packets processed */
extern time_t uptime; /* time we started */
-extern struct in_addr my_addr;
+extern struct in_addr my_addr; /* my inet address */
extern struct timeval t_local; /* current time */
/* found in bdump.c */
@@ -435,7 +436,6 @@ extern String *wildcard_instance;
extern ZRealm *otherrealms;
extern int nrealms;
-extern struct in_addr my_addr; /* my inet address */
#define class_is_control(classname) (classname == class_control)
#define class_is_admin(classname) (classname == class_admin)
diff --git a/server/zstring.c b/server/zstring.c
index 8ae9ade..e7d0820 100644
--- a/server/zstring.c
+++ b/server/zstring.c
@@ -22,7 +22,8 @@ static const char rcsid_zstring_c[] =
static String *zhash[STRING_HASH_TABLE_SIZE];
-int valid_utf8_p(const char* s)
+static int
+valid_utf8_p(const char* s)
{
ssize_t len;
int32_t uc;
@@ -38,16 +39,18 @@ int valid_utf8_p(const char* s)
static char *zdowncase(const char* s)
{
+ unsigned char *new_s_u; /* Avoid strict aliasing violation */
char *new_s, *p;
if (valid_utf8_p(s)) {
/* Use utf8proc if we're dealing with UTF-8.
* Rather than downcase, casefold and normalize to NFKC.
*/
- utf8proc_map((const unsigned char *)s, 0, (unsigned char **)&new_s,
+ utf8proc_map((const unsigned char *)s, 0, (unsigned char **)&new_s_u,
UTF8PROC_NULLTERM | UTF8PROC_STABLE
| UTF8PROC_CASEFOLD | UTF8PROC_COMPAT
| UTF8PROC_COMPOSE);
+ new_s = (char *)new_s_u;
} else {
/* If not, fall back to old methods. */
new_s = strsave(s);
diff --git a/zhm/queue.c b/zhm/queue.c
index c44a19a..993e131 100644
--- a/zhm/queue.c
+++ b/zhm/queue.c
@@ -33,8 +33,6 @@ static int retransmits_enabled = 0;
static Queue *find_notice_in_queue(ZNotice_t *notice);
static void queue_timeout(void *arg);
-extern void new_server(char *);
-
int rexmit_times[] = { 2, 2, 4, 4, 8, -1 };
#ifdef DEBUG
diff --git a/zhm/zhm.c b/zhm/zhm.c
index c2f1daf..bd888d0 100644
--- a/zhm/zhm.c
+++ b/zhm/zhm.c
@@ -51,12 +51,6 @@ static void detach(void);
static void send_stats(ZNotice_t *, struct sockaddr_in *);
static char *strsave(const char *);
-extern void send_flush_notice(char *);
-extern void server_manager(ZNotice_t *);
-extern void send_boot_notice(char *);
-extern void find_next_server(char *);
-extern int optind;
-
static RETSIGTYPE
deactivate(int ignored)
{
@@ -258,10 +252,10 @@ main(int argc,
static void
choose_server(void)
{
+#ifdef HAVE_HESIOD
int i = 0;
char **clust_info, **cpp;
-#ifdef HAVE_HESIOD
if (use_hesiod) {
/* Free up any previously used resources */
diff --git a/zhm/zhm.h b/zhm/zhm.h
index 4af8787..40cd34e 100644
--- a/zhm/zhm.h
+++ b/zhm/zhm.h
@@ -63,12 +63,26 @@ void retransmit_queue(struct sockaddr_in *);
void disable_queue_retransmits(void);
int queue_len(void);
-struct sockaddr_in serv_sin;
+/* zhm.c */
+extern void new_server(char *sugg_serv);
+extern void send_boot_notice(char *);
+extern void send_flush_notice(char *);
+
+/* zhm_server.c */
+extern void find_next_server(char *);
+extern void server_manager(ZNotice_t *);
+
+extern u_short cli_port;
+extern char **serv_list;
+extern char cur_serv[], prim_serv[];
+extern struct sockaddr_in cli_sin, serv_sin, from;
+extern int no_server, deactivated, noflushflag, rebootflag;
+extern int timeout_type, hmdebug, nservchang, booting, nclt, nserv, numserv;
extern int rexmit_times[];
#ifdef HAVE_ETEXT
extern int etext;
-#define adjust_size(size) size -= (unsigned int) &etext;
+#define adjust_size(size) size -= (unsigned long) &etext;
#else
/* Pick a var that tends to be near the start of data section. */
extern char **environ;
diff --git a/zhm/zhm_client.c b/zhm/zhm_client.c
index 0c5b68e..36c81ed 100644
--- a/zhm/zhm_client.c
+++ b/zhm/zhm_client.c
@@ -18,12 +18,6 @@ static const char rcsid_hm_client_c[] = "$Id$";
#endif /* SABER */
#endif /* lint */
-extern int no_server, nclt, deactivated, noflushflag;
-extern struct sockaddr_in cli_sin, serv_sin, from;
-
-extern void send_flush_notice(char *);
-extern void new_server(char *sugg_serv);
-
void transmission_tower(ZNotice_t *notice,
char *packet,
int pak_len)
diff --git a/zhm/zhm_server.c b/zhm/zhm_server.c
index ecfa5f3..0209054 100644
--- a/zhm/zhm_server.c
+++ b/zhm/zhm_server.c
@@ -26,18 +26,9 @@ static int serv_rexmit_times[] = { 5, 10, 20, 40 };
static int serv_timeouts = 0;
int serv_loop = 0;
-extern u_short cli_port;
-extern struct sockaddr_in serv_sin, from;
-extern int timeout_type, hmdebug, nservchang, booting, nserv, no_server;
-extern int deactivated, rebootflag;
-extern int numserv;
-extern char **serv_list;
-extern char cur_serv[], prim_serv[];
-extern void die_gracefully(void);
void hm_control(ZNotice_t *);
void send_back(ZNotice_t *);
-void new_server(char *);
/* Argument is whether we are actually booting, or just attaching
* after a server switch */
@@ -104,7 +95,7 @@ send_flush_notice(char *op)
void
find_next_server(char *sugg_serv)
{
- struct hostent *hp;
+ struct hostent *hp = 0;
int done = 0;
char **parse = serv_list;
char *new_serv;
diff --git a/zwgc/X_driver.c b/zwgc/X_driver.c
index 51c8ea0..374b9fd 100644
--- a/zwgc/X_driver.c
+++ b/zwgc/X_driver.c
@@ -44,10 +44,10 @@ static const char rcsid_X_driver_c[] = "$Id$";
char *app_instance;
/*
- * dpy - the display we are outputting to
+ * x_dpy - the display we are outputting to
*/
-Display *dpy = NULL;
+Display *x_dpy = NULL;
/****************************************************************************/
/* */
@@ -184,10 +184,11 @@ x_string_to_color(char *name,
if (exists) {
return((unsigned long) binding->value);
} else {
- if (XParseColor(dpy,DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy)),
+ if (XParseColor(x_dpy,
+ DefaultColormapOfScreen(DefaultScreenOfDisplay(x_dpy)),
name,&xc)) {
- if (XAllocColor(dpy,
- DefaultColormapOfScreen(DefaultScreenOfDisplay(dpy)),
+ if (XAllocColor(x_dpy,
+ DefaultColormapOfScreen(DefaultScreenOfDisplay(x_dpy)),
&xc)) {
binding->value = (unsigned long) xc.pixel;
return(xc.pixel);
@@ -242,7 +243,7 @@ static XrmOptionDescRec cmd_options[] = {
*
*/
-int
+static int
open_display_and_load_resources(int *pargc,
char **argv)
{
@@ -264,8 +265,8 @@ open_display_and_load_resources(int *pargc,
* Try and open the display using the display specified if given.
* If can't open the display, return an error code.
*/
- dpy = XOpenDisplay(get_string_resource("display", "display"));
- if (!dpy)
+ x_dpy = XOpenDisplay(get_string_resource("display", "display"));
+ if (!x_dpy)
return(1);
/* Read in our application-specific resources: */
@@ -275,7 +276,7 @@ open_display_and_load_resources(int *pargc,
/*
* Get resources from the just opened display:
*/
- xdef = XResourceManagerString(dpy);
+ xdef = XResourceManagerString(x_dpy);
if (xdef)
temp_db2 = XrmGetStringDatabase(xdef);
else
@@ -291,7 +292,7 @@ open_display_and_load_resources(int *pargc,
#if XlibSpecificationRelease > 4
/* X11 R5 per-screen resources */
- res = XScreenResourceString (DefaultScreenOfDisplay (dpy));
+ res = XScreenResourceString (DefaultScreenOfDisplay (x_dpy));
if (res != NULL)
XrmMergeDatabases(XrmGetStringDatabase(res), &temp_db1);
#endif
@@ -322,12 +323,13 @@ open_display_and_load_resources(int *pargc,
*
*/
-int
+static int
X_driver_ioerror(Display *display)
{
ERROR2("X IO error on display '%s'--exiting\n", DisplayString(display));
finalize_zephyr();
exit(1);
+ return 1;
}
/****************************************************************************/
/* */
@@ -343,7 +345,7 @@ X_driver_init(char *drivername,
char **argv)
{
string temp;
- int sync;
+ int is_sync;
/*
* Attempt to open display and read resources, including from the
@@ -360,9 +362,9 @@ X_driver_init(char *drivername,
/*
* For now, set some useful variables using resources:
*/
- sync = get_bool_resource("synchronous", "Synchronous", 0);
- if (sync)
- XSynchronize(dpy, sync);
+ is_sync = get_bool_resource("synchronous", "Synchronous", 0);
+ if (is_sync)
+ XSynchronize(x_dpy, is_sync);
temp = get_string_resource("geometry", "Geometry");
if (temp)
var_set_variable("default_X_geometry", temp);
@@ -374,19 +376,15 @@ X_driver_init(char *drivername,
color_dict = unsigned_long_dictionary_Create(37);
xshowinit();
- x_gram_init(dpy);
- xicccmInitAtoms(dpy);
+ x_gram_init(x_dpy);
+ xicccmInitAtoms(x_dpy);
- mux_add_input_source(ConnectionNumber(dpy), (void(*)(void *))x_get_input, dpy);
+ mux_add_input_source(ConnectionNumber(x_dpy),
+ (void(*)(void *))x_get_input, x_dpy);
return(0);
}
-void
-X_driver_reset(void)
-{
-}
-
/****************************************************************************/
/* */
/* The display routine itself: */
@@ -403,7 +401,7 @@ X_driver(string text)
text_copy = string_Copy(text);
desc = disp_get_cmds(text_copy, &numstr, &numnl);
- xshow(dpy, desc, numstr, numnl);
+ xshow(x_dpy, desc, numstr, numnl);
free(text_copy);
free_desc(desc);
diff --git a/zwgc/X_driver.h b/zwgc/X_driver.h
index b32562e..7a77b91 100644
--- a/zwgc/X_driver.h
+++ b/zwgc/X_driver.h
@@ -21,8 +21,10 @@
#include "new_string.h"
-extern Display *dpy;
+extern Display *x_dpy;
+extern char *X_driver(string);
+extern int X_driver_init(char *, char, int *, char **);
extern char *get_string_resource(string, string);
extern int get_bool_resource(string, string, int);
extern unsigned long x_string_to_color(char *, unsigned long);
diff --git a/zwgc/X_gram.c b/zwgc/X_gram.c
index 998d087..bd80dde 100644
--- a/zwgc/X_gram.c
+++ b/zwgc/X_gram.c
@@ -91,17 +91,17 @@ static Atom net_wm_window_type_utility = None;
*/
/*ARGSUSED*/
-void
+static void
x_set_icccm_hints(Display *dpy,
Window w,
char *name,
- char *icon_name,
+ char *wm_icon_name,
XSizeHints *psizehints,
XWMHints *pwmhints,
Window main_window)
{
XStoreName(dpy,w,name);
- XSetIconName(dpy,w,icon_name);
+ XSetIconName(dpy,w,wm_icon_name);
XSetWMNormalHints(dpy,w,psizehints);
XSetWMHints(dpy,w,pwmhints);
XSetClassHint(dpy,w,&classhint);
@@ -279,7 +279,7 @@ x_gram_init(Display *dpy)
}
}
-int
+static int
x_calc_gravity(int xalign,
int yalign)
{
@@ -424,7 +424,7 @@ SetFG(Display *dpy, GC gc, unsigned long foreground) {
XChangeGC(dpy, gc, GCForeground, &gcvals);
}
-void
+static void
x_gram_draw(Display *dpy, Window w, x_gram *gram, Region region)
{
int i;
@@ -509,7 +509,7 @@ x_gram_draw(Display *dpy, Window w, x_gram *gram, Region region)
#ifdef X_HAVE_UTF8_STRING
text.chars = xb->wstr;
#else
- text.chars = (XChar2b *)xb->wstr;
+ text.chars = (wchar_t *)xb->wstr;
#endif
text.nchars = xb->wlen;
text.delta = 0;
diff --git a/zwgc/file.c b/zwgc/file.c
index b448e5c..8d5bdd0 100644
--- a/zwgc/file.c
+++ b/zwgc/file.c
@@ -23,6 +23,7 @@ static const char rcsid_file_c[] = "$Id$";
#include "new_memory.h"
#include "new_string.h"
#include "error.h"
+#include "file.h"
/*
* char *get_home_directory()
@@ -38,7 +39,8 @@ static const char rcsid_file_c[] = "$Id$";
* if necessary.
*/
-char *get_home_directory(void)
+static char
+*get_home_directory(void)
{
char *result;
struct passwd *passwd_entry;
diff --git a/zwgc/formatter.c b/zwgc/formatter.c
index f5d3c87..65ac5c3 100644
--- a/zwgc/formatter.c
+++ b/zwgc/formatter.c
@@ -235,7 +235,8 @@ verbatim(string str, int bracketsonly)
char *temp,*temp2;
int bracketnum,len;
- if (strlen(str) == pure_text_length(str,0)) {
+ len = strlen(str);
+ if (len == pure_text_length(str,0)) {
/* No environments, so consider the fast-and-easy methods */
if (not_contains(str,allbracket_set)) {
diff --git a/zwgc/lexer.c b/zwgc/lexer.c
index e821eb9..f59cdb8 100644
--- a/zwgc/lexer.c
+++ b/zwgc/lexer.c
@@ -186,7 +186,7 @@ lex_open(FILE *file)
* Initialize keyword_dict from keywords if needed:
*/
if (!keyword_dict) {
- int i;
+ unsigned int i;
keyword_dict = int_dictionary_Create(101);
diff --git a/zwgc/main.c b/zwgc/main.c
index 7383f09..7986242 100644
--- a/zwgc/main.c
+++ b/zwgc/main.c
@@ -223,20 +223,20 @@ run_initprogs(void)
*/
int status;
- char *progname = ZGetVariable("initprogs");
+ char *iprogname = ZGetVariable("initprogs");
- if (!progname)
+ if (!iprogname)
return;
- status = system(progname);
+ status = system(iprogname);
if (status == 127) {
perror("zwgc initprog exec");
fprintf(stderr,"zwgc initprog of <%s> failed: no shell.\n",
- progname);
+ iprogname);
} else if (status!=-1 && status>>8) {
perror("zwgc initprog exec");
fprintf(stderr,"zwgc initprog of <%s> failed with status [%d].\n",
- progname, status>>8);
+ iprogname, status>>8);
}
}
@@ -359,11 +359,10 @@ main(int argc, char **argv)
extern int_dictionary puntable_addresses_dict;
ZNotice_t punt_reply;
-void
-create_punt_reply(int_dictionary_binding *punt)
+static void
+create_punt_reply(int_dictionary_binding *punt_ent)
{
- string binding;
- int key_len = strlen(punt->key);
+ int key_len = strlen(punt_ent->key);
char *tmp;
if (!punt_reply.z_message) {
@@ -382,7 +381,7 @@ create_punt_reply(int_dictionary_binding *punt)
punt_reply.z_message = new_message;
}
tmp = punt_reply.z_message + strlen(punt_reply.z_message);
- strcat (punt_reply.z_message, punt->key);
+ strcat (punt_reply.z_message, punt_ent->key);
strcat (punt_reply.z_message, "\n");
punt_reply.z_message_len += key_len + 1;
diff --git a/zwgc/new_string.c b/zwgc/new_string.c
index 906a2b9..4d95244 100644
--- a/zwgc/new_string.c
+++ b/zwgc/new_string.c
@@ -12,6 +12,7 @@
*/
#include <sysdep.h>
+#include "new_string.h"
#if (!defined(lint) && !defined(SABER))
static const char rcsid_new_string_c[] = "$Id$";
@@ -43,9 +44,6 @@ static const char rcsid_new_string_c[] = "$Id$";
#include "new_memory.h"
-#define string_Length(s) strlen(s)
-typedef char *string;
-
/*
* string string_CreateFromData(char *data, int length):
* Requires: data[0], data[1], ..., data[length-1] != 0
diff --git a/zwgc/notice.c b/zwgc/notice.c
index 47a58ac..21d0676 100644
--- a/zwgc/notice.c
+++ b/zwgc/notice.c
@@ -257,10 +257,7 @@ decode_notice(ZNotice_t *notice,
char *hostname)
{
char *temp;
- string time, notyear, year, date_string, time_string;
-#ifdef CMU_ZWGCPLUS
- extern char *getSelectedText();
-#endif
+ string when, notyear, year, date_string, time_string;
/*
* Convert useful notice fields to ascii and store away in
@@ -319,12 +316,12 @@ decode_notice(ZNotice_t *notice,
/* the fields of struct timeval might not be the right type to pass
to ctime, so use a temporary */
time_t sec = notice->z_time.tv_sec;
- time = ctime(&sec);
+ when = ctime(&sec);
}
- time_string = string_CreateFromData(time+11,8);
+ time_string = string_CreateFromData(when+11,8);
var_set_variable_then_free_value("time", time_string);
- date_string = string_Concat(notyear=string_CreateFromData(time,11),
- year=string_CreateFromData(time+20,4));
+ date_string = string_Concat(notyear=string_CreateFromData(when,11),
+ year=string_CreateFromData(when+20,4));
var_set_variable_then_free_value("date", date_string);
free(notyear);
free(year);
diff --git a/zwgc/plus.c b/zwgc/plus.c
index d9860b1..761109c 100644
--- a/zwgc/plus.c
+++ b/zwgc/plus.c
@@ -56,7 +56,7 @@ TimeNode *timeq_head = NULL;
int list_hash_fun(ZNotice_t *notice);
-TimeNode *
+static TimeNode *
addtimenode(TimeNode *head, TimeNode *node)
{
if(head == NULL) {
@@ -79,7 +79,7 @@ addtimenode(TimeNode *head, TimeNode *node)
return head;
}
-void
+static void
handle_timeq_event(TimeNode *event)
{
char buf[128];
@@ -112,7 +112,7 @@ handle_timeq_event(TimeNode *event)
#endif
}
-void
+static void
schedule_event(long secs, char *name, ZNotice_t *notice)
{
time_t eventtime = (time(NULL)) + secs;
@@ -146,7 +146,7 @@ schedule_event(long secs, char *name, ZNotice_t *notice)
#endif
}
-void
+static void
free_timenode(TimeNode *node)
{
#ifdef DEBUG_TIMEQUEUE
@@ -158,7 +158,7 @@ free_timenode(TimeNode *node)
}
/* returns the number of notices destroyed */
-int
+static int
destroy_timeq_notice(ZNotice_t *notice, char *name)
{
TimeNode *curr = timeq_head;
@@ -274,7 +274,7 @@ plus_queue_notice(ZNotice_t *notice)
int
list_hash_fun(ZNotice_t *notice)
{
- int ix;
+ unsigned int ix;
int res = 0, val = 1, ptval;
char *pt = (char *)(notice);
@@ -310,7 +310,8 @@ dump_noticelist(void)
for (bx=0; bx<HASHSIZE; bx++) {
for (pt=notlist[bx]; pt; pt=pt->next) {
- fprintf(stderr, "Not %p: %d [%d]\n", pt->notice, pt->refcount, bx);
+ fprintf(stderr, "Not %p: %d [%d]\n", (void *)pt->notice,
+ pt->refcount, bx);
}
}
}
diff --git a/zwgc/plus.h b/zwgc/plus.h
index f0a39a5..e6e5183 100644
--- a/zwgc/plus.h
+++ b/zwgc/plus.h
@@ -25,3 +25,5 @@ extern void plus_window_deletions(ZNotice_t *notice); /* actually in xshow.c */
extern void plus_queue_notice(ZNotice_t *notice);
extern long plus_timequeue_events(void);
void plus_set_hname(ZNotice_t *notice, char *hname);
+
+extern char *getSelectedText(void); /* actually in xcut.c */
diff --git a/zwgc/standard_ports.c b/zwgc/standard_ports.c
index bfbd81a..2d6d685 100644
--- a/zwgc/standard_ports.c
+++ b/zwgc/standard_ports.c
@@ -31,22 +31,22 @@ static const char rcsid_standard_ports_c[] = "$Id$";
#include "variables.h"
#include "error.h"
#include "main.h"
+#include "tty_filter.h"
+#ifndef X_DISPLAY_MISSING
+#include "X_driver.h"
+#endif
+
extern char *tty_filter(string, int);
extern int tty_filter_init(char *, char, int *, char **);
-#ifndef X_DISPLAY_MISSING
-extern char *X_driver(string);
-extern int X_driver_init(char *, char, int *, char **);
-#endif
-
extern void usage(void);
/*
*
*/
-char *
+static char *
plain_driver(string input)
{
string processed_input = tty_filter(input, 0);
@@ -61,7 +61,7 @@ plain_driver(string input)
*
*/
-char *
+static char *
tty_driver(string input)
{
string processed_input = tty_filter(input, 1);
@@ -76,7 +76,7 @@ tty_driver(string input)
*
*/
-string
+static string
noop_filter(string input)
{
return(input);
@@ -86,7 +86,7 @@ noop_filter(string input)
*
*/
-string
+static string
plain_filter(string input)
{
return(tty_filter(input, 0));
@@ -96,7 +96,7 @@ plain_filter(string input)
*
*/
-string
+static string
fancy_filter(string input)
{
return(tty_filter(input, 1));
diff --git a/zwgc/string_dictionary_aux.c b/zwgc/string_dictionary_aux.c
index 5dfd89d..0c2b306 100644
--- a/zwgc/string_dictionary_aux.c
+++ b/zwgc/string_dictionary_aux.c
@@ -34,6 +34,7 @@ static const char rcsid_string_dictionary_aux_c[] = "$Id$";
#include <sysdep.h>
#include "new_memory.h"
#include "string_dictionary.h"
+#include "string_dictionary_aux.h"
/*
* void string_dictionary_Set(string_dictionary d, string key,string value):
diff --git a/zwgc/subscriptions.c b/zwgc/subscriptions.c
index e146554..23b1c3d 100644
--- a/zwgc/subscriptions.c
+++ b/zwgc/subscriptions.c
@@ -88,16 +88,16 @@ int puntable_address_p(string class,
string recipient)
{
string temp;
- int ret;
if (!puntable_addresses_dict)
init_puntable_dict();
temp = address_to_string(class, instance, recipient);
- ret = (int)int_dictionary_Lookup(puntable_addresses_dict, temp);
+ if (int_dictionary_Lookup(puntable_addresses_dict, temp)) {
+ free(temp);
+ return 1;
+ }
free(temp);
- if (ret)
- return 1;;
/* This kludge is to allow punts of wildcard instance to work */
temp = address_to_string(class, "*", recipient);
diff --git a/zwgc/tty_filter.c b/zwgc/tty_filter.c
index ee2409c..7e4924a 100644
--- a/zwgc/tty_filter.c
+++ b/zwgc/tty_filter.c
@@ -48,6 +48,7 @@ static const char rcsid_tty_filter_c[] = "$Id$";
#include "formatter.h"
#include "zwgc.h"
#include "error.h"
+#include "tty_filter.h"
/***************************************************************************/
#ifndef HAVE_TERMCAP_H
diff --git a/zwgc/tty_filter.h b/zwgc/tty_filter.h
new file mode 100644
index 0000000..77f0e28
--- /dev/null
+++ b/zwgc/tty_filter.h
@@ -0,0 +1,2 @@
+extern int tty_filter_init(char *, char, int *, char **);
+extern string tty_filter(string, int);
diff --git a/zwgc/xcut.c b/zwgc/xcut.c
index fea0c27..a5d5b39 100644
--- a/zwgc/xcut.c
+++ b/zwgc/xcut.c
@@ -91,8 +91,9 @@ x_gram_to_string(x_gram *gram)
*
*/
+#if 0
/*ARGSUSED*/
-Bool
+static Bool
isShiftButton1(Display *dpy,
XEvent *event,
char *arg)
@@ -101,7 +102,7 @@ isShiftButton1(Display *dpy,
}
/*ARGSUSED*/
-Bool
+static Bool
isShiftButton3(Display *dpy,
XEvent *event,
char *arg)
@@ -109,7 +110,7 @@ isShiftButton3(Display *dpy,
return(event->xbutton.state & (ShiftMask|Button3Mask));
}
-void
+static void
getLastEvent(Display *dpy,
unsigned int state,
XEvent *event)
@@ -124,16 +125,21 @@ getLastEvent(Display *dpy,
*event=xev;
}
}
+#endif
-void
+static void
xunmark(Display *dpy,
Window w,
x_gram *gram,
XContext desc_context)
{
- if (gram == NULL)
- if (XFindContext(dpy, w, desc_context, (XPointer *) &gram))
+ XPointer gramp; /* Avoid strict aliasing violation */
+
+ if (gram == NULL) {
+ if (XFindContext(dpy, w, desc_context, &gramp))
return;
+ gram = (x_gram *)gramp;
+ }
xmarkClear();
xmarkRedraw(dpy,w,gram,XMARK_REDRAW_OLD);
@@ -198,6 +204,7 @@ xcut(Display *dpy,
XEvent *event,
XContext desc_context)
{
+ XPointer gramp; /* Avoid strict aliasing violation */
x_gram *gram;
Window w = event->xany.window;
int changedbound;
@@ -206,8 +213,9 @@ xcut(Display *dpy,
* If event is for a window that's not ours anymore (say we're
* in the process of deleting it...), ignore it:
*/
- if (XFindContext(dpy, w, desc_context, (XPointer *) &gram))
+ if (XFindContext(dpy, w, desc_context, &gramp))
return;
+ gram = (x_gram *)gramp;
/*
* Dispatch on the event type:
@@ -247,7 +255,7 @@ xcut(Display *dpy,
case ClientMessage:
if ((event->xclient.message_type == XA_WM_PROTOCOLS) &&
(event->xclient.format == 32) &&
- (event->xclient.data.l[0] == XA_WM_DELETE_WINDOW))
+ (event->xclient.data.l[0] == (long)XA_WM_DELETE_WINDOW))
xdestroygram(dpy,w,desc_context,gram);
break;
diff --git a/zwgc/xerror.c b/zwgc/xerror.c
index 4a5a0ae..cb934b5 100644
--- a/zwgc/xerror.c
+++ b/zwgc/xerror.c
@@ -23,6 +23,7 @@ static const char rcsid_xerror_c[] = "$Id$";
#include <X11/Xlib.h>
#include "mux.h"
+#include "xerror.h"
int xerror_happened;
diff --git a/zwgc/xmark.c b/zwgc/xmark.c
index d67c4f9..d25796b 100644
--- a/zwgc/xmark.c
+++ b/zwgc/xmark.c
@@ -121,7 +121,7 @@ xmarkSetBound(x_gram *gram,
Xutf8TextPerCharExtents(font, xb->wstr, xb->wlen,
NULL, NULL, -1, &num_chars, NULL, NULL);
#else
- XwcTextPerCharExtents(font, (XChar2b *)xb->wstr, xb->wlen,
+ XwcTextPerCharExtents(font, (wchar_t *)xb->wstr, xb->wlen,
NULL, NULL, -1, &num_chars, NULL, NULL);
#endif
ink = malloc(num_chars * sizeof(XRectangle));
@@ -130,7 +130,7 @@ xmarkSetBound(x_gram *gram,
Xutf8TextPerCharExtents(font, xb->wstr, xb->wlen,
ink, logical, num_chars, &num_chars, NULL, NULL);
#else
- XwcTextPerCharExtents(font, (XChar2b *)xb->wstr, xb->wlen,
+ XwcTextPerCharExtents(font, (wchar_t *)xb->wstr, xb->wlen,
ink, logical, num_chars, &num_chars, NULL, NULL);
#endif
for (i=0;i<num_chars;i++) {
@@ -177,7 +177,7 @@ xmarkNearest(int x,
}
}
-void
+static void
xmarkExpose(Display *dpy,
Window w,
x_gram *gram,
@@ -187,11 +187,12 @@ xmarkExpose(Display *dpy,
unsigned int p2)
{
#define swap(x,y) temp=(x); (x)=(y); (y)=temp
- int i,temp;
+ unsigned int i,temp;
XEvent event;
#define expose (event.xexpose)
- if ((b1==-1) || (p1==-1) || (b2==-1) || (p2==-1)) return;
+ if (((int)b1==-1) || ((int)p1==-1) || ((int)b2==-1) || ((int)p2==-1))
+ return;
if ((b1 > b2) || ((b1 == b2) && (p1 > p2))) {
swap(b1,b2);
@@ -371,7 +372,7 @@ xmarkExtendFromNearest(x_gram *gram,
char *
xmarkGetText(void)
{
- int i, index, len;
+ int i, idx, len;
int last_y = -1;
string temp;
string text_so_far = string_Copy("");
@@ -394,17 +395,17 @@ xmarkGetText(void)
for (i=startblock; i<=endblock; i++) {
if (last_y != -1 && last_y != markgram->blocks[i].y)
text_so_far = string_Concat2(text_so_far, "\n");
- index = markgram->blocks[i].strindex;
+ idx = markgram->blocks[i].strindex;
len = markgram->blocks[i].strlen;
if (startblock == endblock)
- temp = string_CreateFromData(text+index+startchar,
+ temp = string_CreateFromData(text+idx+startchar,
endchar-startchar);
else if (i==startblock)
- temp = string_CreateFromData(text+index+startchar,len-startchar);
+ temp = string_CreateFromData(text+idx+startchar,len-startchar);
else if (i==endblock)
- temp = string_CreateFromData(text+index,endchar);
+ temp = string_CreateFromData(text+idx,endchar);
else
- temp = string_CreateFromData(text+index,len);
+ temp = string_CreateFromData(text+idx,len);
text_so_far = string_Concat2(text_so_far, temp);
free(temp);
last_y = markgram->blocks[i].y;
diff --git a/zwgc/xrevstack.c b/zwgc/xrevstack.c
index 12e15ab..d9fc8a0 100644
--- a/zwgc/xrevstack.c
+++ b/zwgc/xrevstack.c
@@ -24,6 +24,7 @@ static const char rcsid_xrevstack_c[] = "$Id$";
#ifndef TRUEREVSTACK
#include <zephyr/zephyr.h>
#include "X_gram.h"
+#include "xrevstack.h"
x_gram *bottom_gram = NULL;
x_gram *unlinked = NULL;
diff --git a/zwgc/xselect.c b/zwgc/xselect.c
index 2192182..89f594d 100644
--- a/zwgc/xselect.c
+++ b/zwgc/xselect.c
@@ -96,17 +96,18 @@ xselSetProperties(Display *dpy,
} else if (target==ZA_MULTIPLE) {
Atom atype;
int aformat;
+ unsigned char *alistp; /* Avoid strict aliasing violation, we hope */
Atom *alist;
unsigned long alistsize,i;
XGetWindowProperty(dpy,w,property,0L,0L,False,ZA_ATOM_PAIR,&atype,
- &aformat,&i,&alistsize,(unsigned char **) &alist);
+ &aformat,&i,&alistsize,&alistp);
if (alistsize)
XGetWindowProperty(dpy,w,property,0L,alistsize/sizeof(Atom),False,
- ZA_ATOM_PAIR,&atype,&aformat,&alistsize,&i,
- (unsigned char **) &alist);
+ ZA_ATOM_PAIR,&atype,&aformat,&alistsize,&i, &alistp);
+ alist = (Atom *)alistp;
alistsize/=(sizeof(Atom)/4);
for (i=0;i<alistsize;i+=2)
xselSetProperties(dpy,w,alist[i+1],alist[i],selreq);
@@ -141,7 +142,7 @@ xselSetProperties(Display *dpy,
void
xicccmInitAtoms(Display *dpy)
{
- int i;
+ unsigned int i;
for (i=0;i<NumZAtoms;i++)
*(ZAtom[i].patom)=XInternAtom(dpy,ZAtom[i].name,False);
@@ -153,15 +154,15 @@ xicccmInitAtoms(Display *dpy)
int
xselGetOwnership(Display *dpy,
Window w,
- Time time)
+ Time when)
{
int temp;
- XSetSelectionOwner(dpy,XA_PRIMARY,w,time);
+ XSetSelectionOwner(dpy,XA_PRIMARY,w,when);
temp=(w == XGetSelectionOwner(dpy,XA_PRIMARY));
if (temp)
- ownership_start = time;
+ ownership_start = when;
return(temp);
}
@@ -194,9 +195,9 @@ xselProcessSelection(Display *dpy,
}
void
-xselOwnershipLost(Time time)
+xselOwnershipLost(Time when)
{
- ownership_end = time;
+ ownership_end = when;
}
/*ARGSUSED*/
diff --git a/zwgc/xshow.c b/zwgc/xshow.c
index 894e25d..3e1b2ce 100644
--- a/zwgc/xshow.c
+++ b/zwgc/xshow.c
@@ -109,7 +109,7 @@ static struct res_dict_type fgcolor_resources = {
};
/*ARGSUSED*/
-char *
+static char *
mode_to_colorname (Display *dpy,
char *style,
xmode *mode)
@@ -123,7 +123,7 @@ mode_to_colorname (Display *dpy,
return result;
}
-void
+static void
fixup_and_draw(Display *dpy,
char *style,
xauxblock *auxblocks,
@@ -171,7 +171,7 @@ fixup_and_draw(Display *dpy,
blocks[block].wlen);
#else
ssize = XwcTextEscapement(auxblocks[block].font,
- (XChar2b *)blocks[block].wstr,
+ (wchar_t *)blocks[block].wstr,
blocks[block].wlen);
#endif
auxblocks[block].width = ssize;
@@ -361,7 +361,7 @@ fixup_and_draw(Display *dpy,
}
/* Silly almost-but-not-quite-useless helper function */
-char *
+static char *
no_dots_downcase_var(char *str)
{
register char *var, *var2;
@@ -412,6 +412,7 @@ xshow(Display *dpy, desctype *desc, int numstr, int numnl)
blocks = (xblock *)malloc(sizeof(xblock) * numstr);
auxblocks = (xauxblock *)malloc(sizeof(xauxblock) * numstr);
+ memset(&curmode, 0, sizeof(curmode));
curmode.bold = 0;
curmode.italic = 0;
curmode.size = MEDIUM_SIZE;
@@ -600,10 +601,12 @@ xhandleevent(Display *dpy,
Window w,
XEvent *event)
{
+ XPointer gramp; /* Avoid strict aliasing violation */
x_gram *gram;
- if (XFindContext(dpy, w, desc_context, (XPointer *)&gram))
+ if (XFindContext(dpy, w, desc_context, &gramp))
return;
+ gram = (x_gram *)gramp;
if (event->type == Expose)
x_gram_expose(dpy, w, gram,&(event->xexpose));
@@ -645,7 +648,7 @@ plus_window_deletions(ZNotice_t *notice)
int done;
static char class_nm[NAMESIZE], instance_nm[NAMESIZE], recip_nm[NAMESIZE];
- if (!dpy)
+ if (!x_dpy)
return;
val = var_get_variable("delete_window");
@@ -662,7 +665,7 @@ plus_window_deletions(ZNotice_t *notice)
if (tmp->notice == notice) {
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -680,7 +683,7 @@ plus_window_deletions(ZNotice_t *notice)
if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_sender, class_nm)) {
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -698,7 +701,7 @@ plus_window_deletions(ZNotice_t *notice)
if (!!strcasecmp(((ZNotice_t *)(tmp->notice))->z_sender, class_nm)) {
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -715,7 +718,7 @@ plus_window_deletions(ZNotice_t *notice)
if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm)) {
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -732,7 +735,7 @@ plus_window_deletions(ZNotice_t *notice)
if (!!strcasecmp(((ZNotice_t *)(tmp->notice))->z_recipient, recip_nm)) {
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -754,7 +757,7 @@ plus_window_deletions(ZNotice_t *notice)
{
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -774,7 +777,7 @@ plus_window_deletions(ZNotice_t *notice)
{
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -794,7 +797,7 @@ plus_window_deletions(ZNotice_t *notice)
{
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -811,7 +814,7 @@ plus_window_deletions(ZNotice_t *notice)
if (!strcasecmp(((ZNotice_t *)(tmp->notice))->z_class, class_nm)) {
fry = tmp;
tmp = tmp->above;
- xdestroygram(dpy, fry->w, desc_context, fry);
+ xdestroygram(x_dpy, fry->w, desc_context, fry);
done = 0;
} else {
tmp = tmp->above;
@@ -821,7 +824,7 @@ plus_window_deletions(ZNotice_t *notice)
}
else if (!strcmp(val, "all")) {
while (bottom_gram) {
- xdestroygram(dpy, bottom_gram->w, desc_context, bottom_gram);
+ xdestroygram(x_dpy, bottom_gram->w, desc_context, bottom_gram);
}
}
}
diff --git a/zwgc/zephyr.c b/zwgc/zephyr.c
index 9c9fbd9..6acfe81 100644
--- a/zwgc/zephyr.c
+++ b/zwgc/zephyr.c
@@ -100,8 +100,12 @@ write_wgfile(void)
*
*/
+struct notice_handler_ptr {
+ void (*notice_handler)(ZNotice_t *);
+};
+
static void
-handle_zephyr_input(void (*notice_handler)(ZNotice_t *))
+handle_zephyr_input(struct notice_handler_ptr *nhp)
{
ZNotice_t *notice;
struct sockaddr_in from;
@@ -120,7 +124,7 @@ handle_zephyr_input(void (*notice_handler)(ZNotice_t *))
TRAP( ZReceiveNotice(notice, &from), "while getting zephyr notice" );
if (!error_code) {
notice->z_auth = ZCheckAuthentication(notice, &from);
- notice_handler(notice);
+ nhp->notice_handler(notice);
}
#ifdef CMU_ZWGCPLUS
if (get_list_refcount(notice) <= 0) {
@@ -138,6 +142,7 @@ handle_zephyr_input(void (*notice_handler)(ZNotice_t *))
void zephyr_init(void (*notice_handler)(ZNotice_t *))
{
+ struct notice_handler_ptr *nhp;
char *temp;
char *exposure;
char *tty = NULL;
@@ -146,6 +151,11 @@ void zephyr_init(void (*notice_handler)(ZNotice_t *))
/*
* Initialize zephyr. If error, print error message & exit.
*/
+ nhp = malloc(sizeof(struct notice_handler_ptr));
+ if (!nhp) {
+ fprintf(stderr, "Out of memory setting up zephyr notice handler.\n");
+ exit(3);
+ }
FATAL_TRAP( ZInitialize(), "while initializing Zephyr" );
FATAL_TRAP( ZOpenPort(&zephyr_port), "while opening Zephyr port" );
@@ -168,8 +178,8 @@ void zephyr_init(void (*notice_handler)(ZNotice_t *))
if (location_override)
tty = location_override;
#ifndef X_DISPLAY_MISSING
- else if (dpy)
- tty = DisplayString(dpy);
+ else if (x_dpy)
+ tty = DisplayString(x_dpy);
#endif
error_code = ZInitLocationInfo(NULL, tty);
TRAP( error_code, "while initializing location information" );
@@ -210,8 +220,8 @@ void zephyr_init(void (*notice_handler)(ZNotice_t *))
/*
* <<<>>>
*/
- mux_add_input_source(ZGetFD(), (void (*)(void *))handle_zephyr_input,
- notice_handler);
+ nhp->notice_handler = notice_handler;
+ mux_add_input_source(ZGetFD(), (void (*)(void *))handle_zephyr_input, nhp);
zephyr_inited = 1;
return;
}