summaryrefslogtreecommitdiff
path: root/zwgc
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 /zwgc
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.
Diffstat (limited to 'zwgc')
-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
23 files changed, 155 insertions, 126 deletions
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;
}