Changeset 194

Show
Ignore:
Timestamp:
12/05/07 16:26:52 (1 year ago)
Author:
conrad
Message:

Set CFLAGS to error on warnings when using GCC, and set to gnu99 standard.
However, disable strict-aliasing to allow type-punning on XGetWindowProperty.
Add some casts (unsigned char <-> char) to handle warnings, as suggested by
Axel Liljencrantz (original patch lost, recreated).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • xsel/trunk/configure.ac

    r189 r194  
    2121#AC_CHECK_LIB([X11], [XOpenDisplay]) 
    2222 
     23# Error out on compile warnings 
     24dnl Add some useful warnings if we have gcc. 
     25dnl changequote(,)dnl 
     26if test "x$ac_cv_prog_gcc" = xyes ; then 
     27  CFLAGS="$CFLAGS -fno-strict-aliasing -Wall -Werror -g -std=gnu99 -Wdeclaration-after-statement -Wno-unused" 
     28fi 
     29dnl changequote([,])dnl 
     30 
    2331# Checks for header files. 
    2432AC_HEADER_STDC 
  • xsel/trunk/xsel.c

    r192 r194  
    217217 * Returns a string with a printable name for the Atom 'atom'. 
    218218 */ 
    219 static unsigned char * 
     219static char * 
    220220get_atom_name (Atom atom) 
    221221{ 
     
    268268 
    269269/* 
     270 * xs_strdup (s) 
     271 * 
     272 * strdup wrapper for unsigned char * 
     273 */ 
     274#define xs_strdup(s) ((unsigned char *) strdup ((const char *)s)) 
     275 
     276/* 
     277 * xs_strlen (s) 
     278 * 
     279 * strlen wrapper for unsigned char * 
     280 */ 
     281#define xs_strlen(s) (strlen ((const char *) s)) 
     282 
     283/* 
     284 * xs_strncpy (s) 
     285 * 
     286 * strncpy wrapper for unsigned char * 
     287 */ 
     288#define xs_strncpy(dest,src,n) (strncpy ((char *)dest, (const char *)src, n)) 
     289 
     290/* 
    270291 * get_homedir () 
    271292 * 
     
    488509    return False; 
    489510  } else if (format == 8) { 
    490     if (*offset + length > *alloc) { 
     511    if ((unsigned long)*offset + length > (unsigned long)*alloc) { 
    491512      *alloc = *offset + length; 
    492513      if ((*buffer = realloc (*buffer, *alloc)) == NULL) { 
     
    495516    } 
    496517    ptr = *buffer + *offset; 
    497     strncpy (ptr, value, length); 
     518    xs_strncpy (ptr, value, length); 
    498519    *offset += length; 
    499520    print_debug (D_TRACE, "Appended %d bytes to buffer\n", length); 
     
    612633          keep_waiting = False; 
    613634        } else { 
    614           retval = strdup (value); 
     635          retval = xs_strdup (value); 
    615636          XFree (value); 
    616637          keep_waiting = False; 
     
    700721  unsigned char * new_sel = NULL; 
    701722 
    702   new_sel = strdup (s); 
    703   current_alloc = total_input = strlen (s); 
     723  new_sel = xs_strdup (s); 
     724  current_alloc = total_input = xs_strlen (s); 
    704725 
    705726  return new_sel; 
     
    12671288  return 
    12681289    change_property (display, requestor, property, XA_STRING, 8, 
    1269                      PropModeReplace, sel, strlen(sel), 
     1290                     PropModeReplace, sel, xs_strlen(sel), 
    12701291                     selection, time, mparent); 
    12711292} 
     
    12831304  return 
    12841305    change_property (display, requestor, property, utf8_atom, 8, 
    1285                      PropModeReplace, sel, strlen(sel), 
     1306                     PropModeReplace, sel, xs_strlen(sel), 
    12861307                     selection, time, mparent); 
    12871308}