diff options
author | Jeffrey Hutzelman <jhutz@cmu.edu> | 2013-02-02 02:09:25 -0500 |
---|---|---|
committer | Jeffrey Hutzelman <jhutz@cmu.edu> | 2013-02-14 19:20:27 -0500 |
commit | e2bfb6322ce9f4323b83469dc06dd1ce1b0f4cf6 (patch) | |
tree | 507dab2f064c09996a002624d49c0dfb257a24a9 /zwgc/X_driver.c | |
parent | 350312d5db9b0a968bbbbecb37bd600a2da389d0 (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/X_driver.c')
-rw-r--r-- | zwgc/X_driver.c | 46 |
1 files changed, 22 insertions, 24 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); |