From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15602 invoked from network); 11 Aug 2005 20:03:25 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 11 Aug 2005 20:03:25 -0000 Received: (qmail 50375 invoked from network); 11 Aug 2005 20:03:17 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 11 Aug 2005 20:03:17 -0000 Received: (qmail 16612 invoked by alias); 11 Aug 2005 20:03:03 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21600 Received: (qmail 16592 invoked from network); 11 Aug 2005 20:03:02 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 11 Aug 2005 20:03:02 -0000 Received: (qmail 48049 invoked from network); 11 Aug 2005 20:03:02 -0000 Received: from dsl3-63-249-88-2.cruzio.com (HELO dot.blorf.net) (63.249.88.2) by a.mx.sunsite.dk with SMTP; 11 Aug 2005 20:02:53 -0000 Received: by dot.blorf.net (Postfix, from userid 1000) id A749938B7; Thu, 11 Aug 2005 13:02:52 -0700 (PDT) Date: Thu, 11 Aug 2005 13:02:52 -0700 From: Wayne Davison To: zsh-workers@sunsite.dk Subject: PATCH: silencing compiler warnings from gcc 4 Message-ID: <20050811200252.GA19497@blorf.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="WIyZ46R2i8wDzkSu" Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Gcc 4 outputs a bunch of compiler warnings about string pointers that differ in signedness. The warnings in a zsh build are limited to the zle string functions defined in zle.h. I came up with 2 solutions: (1) change the ZS_str* macros to cast their args to (char*), or (2) introduce some static inline functions to handle the casts. The advantage of the latter is that it doesn't hide pointer-conversion errors behind forced casts. For instance, after I compiled the inline version it showed several places in the code that were using ZWC() on strings instead of ZWS() (which I already fixed and checked in). As for the portability of "inline", there is an autoconf macro that I included, AC_C_INLINE, that redefines the word "inline" as appropriate. The rsync package used a static inline function in its rsync.h for many years (thought I eliminated it recently), so it would seem to be quite portable. Comments? ..wayne.. --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="signedness-inline.diff" --- configure.ac 1 Aug 2005 09:54:56 -0000 1.37 +++ configure.ac 11 Aug 2005 18:42:00 -0000 @@ -437,6 +437,7 @@ AC_SUBST(LIBLDFLAGS)dnl AC_PROG_CPP dnl Figure out how to run C preprocessor. AC_PROG_GCC_TRADITIONAL dnl Do we need -traditional flag for gcc. AC_C_CONST dnl Does compiler support `const'. +AC_C_INLINE dnl Default preprocessing on Mac OS X produces warnings case "$host_os" in --- Src/Zle/zle.h 10 Aug 2005 10:56:41 -0000 1.15 +++ Src/Zle/zle.h 11 Aug 2005 18:42:00 -0000 @@ -89,10 +89,20 @@ typedef int ZLE_INT_T; #define ZS_memmove memmove #define ZS_memset memset #define ZS_memcmp memcmp -#define ZS_strlen strlen -#define ZS_strcpy strcpy -#define ZS_strncpy strncpy -#define ZS_strncmp strncmp + +static inline size_t ZS_strlen(ZLE_STRING_T s); +static inline ZLE_STRING_T ZS_strcpy(ZLE_STRING_T t, ZLE_STRING_T f); +static inline ZLE_STRING_T ZS_strncpy(ZLE_STRING_T t, ZLE_STRING_T f, size_t l); +static inline int ZS_strncmp(ZLE_STRING_T s1, ZLE_STRING_T s2, size_t l); + +static inline size_t ZS_strlen(ZLE_STRING_T s) +{ return strlen((char*)s); } +static inline ZLE_STRING_T ZS_strcpy(ZLE_STRING_T t, ZLE_STRING_T f) +{ return (ZLE_STRING_T)strcpy((char*)t, (char*)f); } +static inline ZLE_STRING_T ZS_strncpy(ZLE_STRING_T t, ZLE_STRING_T f, size_t l) +{ return (ZLE_STRING_T)strncpy((char*)t, (char*)f, l); } +static inline int ZS_strncmp(ZLE_STRING_T s1, ZLE_STRING_T s2, size_t l) +{ return strncmp((char*)s1, (char*)s2, l); } #define ZC_iblank iblank #define ZC_icntrl icntrl --WIyZ46R2i8wDzkSu Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="signedness.diff" --- Src/Zle/zle.h 10 Aug 2005 10:56:41 -0000 1.15 +++ Src/Zle/zle.h 11 Aug 2005 18:20:16 -0000 @@ -89,10 +89,10 @@ typedef int ZLE_INT_T; #define ZS_memmove memmove #define ZS_memset memset #define ZS_memcmp memcmp -#define ZS_strlen strlen -#define ZS_strcpy strcpy -#define ZS_strncpy strncpy -#define ZS_strncmp strncmp +#define ZS_strlen(s) strlen((char*)(s)) +#define ZS_strcpy(t,f) strcpy((char*)(t),(char*)(f)) +#define ZS_strncpy(t,f,l) strncpy((char*)(t),(char*)(f),(l)) +#define ZS_strncmp(s1,s2,l) strncmp((char*)(s1),(char*)(s2),(l)) #define ZC_iblank iblank #define ZC_icntrl icntrl --WIyZ46R2i8wDzkSu--