emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fix some compilation warnings


From: Dan Nicolaescu
Subject: Fix some compilation warnings
Date: Tue, 27 Sep 2005 12:42:31 -0700

While trying to build emacs using the gcc-4.1 -fwhole-program flag I
fixed some warnings/errors.  

I am not sure which of these fixes are appropriate to check in because
some might cause portability problem. 

Can somebody please look over and say what parts are OK? 

The type for old_*_hook and emacs_blocked_* did not match the type of
__free_hook, __malloc_hook in glibc. 

Index: src/alloc.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/alloc.c,v
retrieving revision 1.374
diff -c -3 -p -r1.374 alloc.c
*** src/alloc.c 23 Jul 2005 19:08:06 -0000      1.374
--- src/alloc.c 27 Sep 2005 19:11:04 -0000
*************** extern void * (*__realloc_hook) P_ ((voi
*** 1166,1180 ****
  extern void (*__free_hook) P_ ((void *));
  /* Else declared in malloc.h, perhaps with an extra arg.  */
  #endif /* DOUG_LEA_MALLOC */
! static void * (*old_malloc_hook) ();
! static void * (*old_realloc_hook) ();
! static void (*old_free_hook) ();
  
  /* This function is used as the hook for free to call.  */
  
  static void
! emacs_blocked_free (ptr)
       void *ptr;
  {
    BLOCK_INPUT_ALLOC;
  
--- 1166,1181 ----
  extern void (*__free_hook) P_ ((void *));
  /* Else declared in malloc.h, perhaps with an extra arg.  */
  #endif /* DOUG_LEA_MALLOC */
! static void * (*old_malloc_hook) P_ ((size_t, const void *));
! static void * (*old_realloc_hook) P_ ((void *,  size_t, const void*));
! static void (*old_free_hook) P_ ((void*, const void*));
  
  /* This function is used as the hook for free to call.  */
  
  static void
! emacs_blocked_free (ptr, ptr2)
       void *ptr;
+      const void *ptr2;
  {
    BLOCK_INPUT_ALLOC;
  
*************** emacs_blocked_free (ptr)
*** 1221,1228 ****
  /* This function is the malloc hook that Emacs uses.  */
  
  static void *
! emacs_blocked_malloc (size)
       size_t size;
  {
    void *value;
  
--- 1222,1230 ----
  /* This function is the malloc hook that Emacs uses.  */
  
  static void *
! emacs_blocked_malloc (size, ptr)
       size_t size;
+      const void *ptr;
  {
    void *value;
  
*************** emacs_blocked_malloc (size)
*** 1268,1276 ****
  /* This function is the realloc hook that Emacs uses.  */
  
  static void *
! emacs_blocked_realloc (ptr, size)
       void *ptr;
       size_t size;
  {
    void *value;
  
--- 1270,1279 ----
  /* This function is the realloc hook that Emacs uses.  */
  
  static void *
! emacs_blocked_realloc (ptr, size, ptr2)
       void *ptr;
       size_t size;
+      const void *ptr2;
  {
    void *value;


On my GNU/Linux machine tputs returns int 
  
Index: src/cm.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/cm.c,v
retrieving revision 1.20
diff -c -3 -p -r1.20 cm.c
*** src/cm.c    7 Aug 2005 12:33:16 -0000       1.20
--- src/cm.c    27 Sep 2005 19:11:04 -0000
*************** Boston, MA 02110-1301, USA.  */
*** 33,39 ****
  #if defined HAVE_TERMCAP_H && 0
  #include <termcap.h>
  #else
! extern void tputs P_ ((const char *, int, int (*)(int)));
  extern char *tgoto P_ ((const char *, int, int));
  #endif
  
--- 33,39 ----
  #if defined HAVE_TERMCAP_H && 0
  #include <termcap.h>
  #else
! extern int tputs P_ ((const char *, int, int (*)(int)));
  extern char *tgoto P_ ((const char *, int, int));
  #endif


Move the make_time declaration to systime.h as that header deals with
time_t.  But because of that in a few .c files lisp.h needs to be
included before systime.h.


*** systime.h   27 Sep 2005 11:34:53 -0700      1.42
--- systime.h   27 Sep 2005 12:32:45 -0700      
***************
*** 157,162 ****
--- 157,165 ----
  /* defined in keyboard.c */
  extern void set_waiting_for_input __P ((EMACS_TIME *));
  
+ /* defined in dired.c */
+ extern Lisp_Object make_time __P ((time_t));
+ 
  /* Compare times T1 and T2.  Value is 0 if T1 and T2 are the same.
     Value is < 0 if T1 is less than T2.  Value is > 0 otherwise.  */
  

Index: src/dired.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dired.c,v
retrieving revision 1.118
diff -c -3 -p -r1.118 dired.c
*** src/dired.c 2 Sep 2005 18:42:54 -0000       1.118
--- src/dired.c 27 Sep 2005 19:11:06 -0000
*************** Boston, MA 02110-1301, USA.  */
*** 33,39 ****
  #include <grp.h>
  #endif
  
- #include "systime.h"
  #include <errno.h>
  
  #ifdef VMS
--- 33,38 ----
*************** extern struct direct *readdir ();
*** 93,98 ****
--- 92,98 ----
  #endif
  
  #include "lisp.h"
+ #include "systime.h"
  #include "buffer.h"
  #include "commands.h"
  #include "charset.h"
Index: src/dispextern.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/dispextern.h,v
retrieving revision 1.208
diff -c -3 -p -r1.208 dispextern.h
*** src/dispextern.h    7 Aug 2005 12:33:16 -0000       1.208
--- src/dispextern.h    27 Sep 2005 19:11:06 -0000
*************** extern void calculate_costs P_ ((struct 
*** 2940,2946 ****
  extern void set_tty_color_mode P_ ((struct frame *, Lisp_Object));
  extern void tty_setup_colors P_ ((int));
  extern void term_init P_ ((char *));
- extern void fatal P_ ((/* char *, ... */));
  void cursor_to P_ ((int, int));
  extern int tty_capable_p P_ ((struct frame *, unsigned, unsigned long, 
unsigned long));
  
--- 2940,2945 ----
Index: src/editfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/editfns.c,v
retrieving revision 1.399
diff -c -3 -p -r1.399 editfns.c
*** src/editfns.c       23 Sep 2005 18:22:46 -0000      1.399
--- src/editfns.c       27 Sep 2005 19:11:07 -0000
*************** Boston, MA 02110-1301, USA.  */
*** 37,42 ****
--- 37,44 ----
  #include <sys/utsname.h>
  #endif
  
+ #include "lisp.h"
+ 
  /* systime.h includes <sys/time.h> which, on some systems, is required
     for <sys/resource.h>; thus systime.h must be included before
     <sys/resource.h> */
*************** Boston, MA 02110-1301, USA.  */
*** 48,54 ****
  
  #include <ctype.h>
  
- #include "lisp.h"
  #include "intervals.h"
  #include "buffer.h"
  #include "charset.h"
--- 50,55 ----
*************** Boston, MA 02110-1301, USA.  */
*** 71,77 ****
  extern char **environ;
  #endif
  
- extern Lisp_Object make_time P_ ((time_t));
  extern size_t emacs_strftimeu P_ ((char *, size_t, const char *,
                                   const struct tm *, int));
  static int tm_diff P_ ((struct tm *, struct tm *));
--- 72,77 ----
Index: src/xsmfns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/xsmfns.c,v
retrieving revision 1.17
diff -c -3 -p -r1.17 xsmfns.c
*** src/xsmfns.c        10 Sep 2005 14:03:36 -0000      1.17
--- src/xsmfns.c        27 Sep 2005 19:11:07 -0000
*************** Boston, MA 02110-1301, USA.  */
*** 45,53 ****
  #include <sys/param.h>
  #include <stdio.h>
  
  #include "systime.h"
  #include "sysselect.h"
- #include "lisp.h"
  #include "termhooks.h"
  #include "termopts.h"
  #include "xterm.h"
--- 45,53 ----
  #include <sys/param.h>
  #include <stdio.h>
  
+ #include "lisp.h"
  #include "systime.h"
  #include "sysselect.h"
  #include "termhooks.h"
  #include "termopts.h"
  #include "xterm.h"



Fix the types for malloc_set_state and re_max_failures.

Index: src/emacs.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/emacs.c,v
retrieving revision 1.375
diff -c -3 -p -r1.375 emacs.c
*** src/emacs.c 15 Sep 2005 13:12:48 -0000      1.375
--- src/emacs.c 27 Sep 2005 19:11:07 -0000
*************** void *malloc_state_ptr;
*** 148,154 ****
  /* From glibc, a routine that returns a copy of the malloc internal state.  */
  extern void *malloc_get_state ();
  /* From glibc, a routine that overwrites the malloc internal state.  */
! extern void malloc_set_state ();
  /* Non-zero if the MALLOC_CHECK_ enviroment variable was set while
     dumping.  Used to work around a bug in glibc's malloc.  */
  int malloc_using_checking;
--- 148,154 ----
  /* From glibc, a routine that returns a copy of the malloc internal state.  */
  extern void *malloc_get_state ();
  /* From glibc, a routine that overwrites the malloc internal state.  */
! extern int malloc_set_state ();
  /* Non-zero if the MALLOC_CHECK_ enviroment variable was set while
     dumping.  Used to work around a bug in glibc's malloc.  */
  int malloc_using_checking;
*************** main (argc, argv
*** 1001,1007 ****
        && !getrlimit (RLIMIT_STACK, &rlim))
      {
        long newlim;
!       extern int re_max_failures;
        /* Approximate the amount regex.c needs per unit of re_max_failures.  */
        int ratio = 20 * sizeof (char *);
        /* Then add 33% to cover the size of the smaller stacks that regex.c
--- 1001,1007 ----
        && !getrlimit (RLIMIT_STACK, &rlim))
      {
        long newlim;
!       extern size_t re_max_failures;
        /* Approximate the amount regex.c needs per unit of re_max_failures.  */
        int ratio = 20 * sizeof (char *);
        /* Then add 33% to cover the size of the smaller stacks that regex.c

Fix the type for fatal.

Index: src/lisp.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/lisp.h,v
retrieving revision 1.540
diff -c -3 -p -r1.540 lisp.h
*** src/lisp.h  10 Sep 2005 14:12:35 -0000      1.540
--- src/lisp.h  27 Sep 2005 19:11:07 -0000
*************** extern void syms_of_dired P_ ((void));
*** 3158,3164 ****
  
  /* Defined in term.c */
  extern void syms_of_term P_ ((void));
! extern void fatal () NO_RETURN;
  
  #ifdef HAVE_X_WINDOWS
  /* Defined in fontset.c */
--- 3158,3164 ----
  
  /* Defined in term.c */
  extern void syms_of_term P_ ((void));
! extern void fatal P_ ((const char *msgid, ...)) NO_RETURN;
  
  #ifdef HAVE_X_WINDOWS
  /* Defined in fontset.c */

Fix the type for start_of_data.

Index: src/mem-limits.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/mem-limits.h,v
retrieving revision 1.37
diff -c -3 -p -r1.37 mem-limits.h
*** src/mem-limits.h    7 Aug 2005 12:33:17 -0000       1.37
--- src/mem-limits.h    27 Sep 2005 19:11:07 -0000
*************** typedef unsigned long SIZE;
*** 81,87 ****
  #endif
  #define NULL ((POINTER) 0)
  
! extern POINTER start_of_data ();
  #if defined USE_LSB_TAG
  #define EXCEEDS_LISP_PTR(ptr) 0
  #elif defined DATA_SEG_BITS
--- 81,87 ----
  #endif
  #define NULL ((POINTER) 0)
  
! extern char*  start_of_data ();
  #if defined USE_LSB_TAG
  #define EXCEEDS_LISP_PTR(ptr) 0
  #elif defined DATA_SEG_BITS

Move a typedef to the regex.h file and add a few prototypes. 

Index: src/regex.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/regex.c,v
retrieving revision 1.202
diff -c -3 -p -r1.202 regex.c
*** src/regex.c 7 Aug 2005 12:33:17 -0000       1.202
--- src/regex.c 27 Sep 2005 19:11:07 -0000
*************** init_syntax_once ()
*** 524,532 ****
  #define MAX(a, b) ((a) > (b) ? (a) : (b))
  #define MIN(a, b) ((a) < (b) ? (a) : (b))
  
- /* Type of source-pattern and string chars.  */
- typedef const unsigned char re_char;
- 
  typedef char boolean;
  #define false 0
  #define true 1
--- 524,529 ----
Index: src/regex.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/regex.h,v
retrieving revision 1.36
diff -c -3 -p -r1.36 regex.h
*** src/regex.h 7 Aug 2005 12:33:17 -0000       1.36
--- src/regex.h 27 Sep 2005 19:11:07 -0000
*************** typedef enum { RECC_ERROR = 0,
*** 603,609 ****
--- 603,617 ----
               RECC_ASCII, RECC_UNIBYTE
  } re_wctype_t;
  
+ extern char re_iswctype (int ch,    re_wctype_t cc);
+ extern re_wctype_t re_wctype (const unsigned char* str);
+ 
  typedef int re_wchar_t;
+ 
+ /* Type of source-pattern and string chars.  */
+ typedef const unsigned char re_char;
+ 
+ extern void re_set_whitespace_regexp (re_char *regexp);
  
  #endif /* not WIDE_CHAR_SUPPORT */
  


Same tputs issue as above.
Use stdarg.h to implement fatal.

Index: src/term.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/term.c,v
retrieving revision 1.167
diff -c -3 -p -r1.167 term.c
*** src/term.c  22 Aug 2005 20:47:49 -0000      1.167
--- src/term.c  27 Sep 2005 19:11:07 -0000
*************** Boston, MA 02110-1301, USA.  */
*** 25,30 ****
--- 25,31 ----
  #include <stdio.h>
  #include <ctype.h>
  #include <string.h>
+ #include <stdarg.h>
  
  #include "termchar.h"
  #include "termopts.h"
*************** Boston, MA 02110-1301, USA.  */
*** 46,52 ****
  #if defined HAVE_TERMCAP_H && 0
  #include <termcap.h>
  #else
! extern void tputs P_ ((const char *, int, int (*)(int)));
  extern int tgetent P_ ((char *, const char *));
  extern int tgetflag P_ ((char *id));
  extern int tgetnum P_ ((char *id));
--- 47,53 ----
  #if defined HAVE_TERMCAP_H && 0
  #include <termcap.h>
  #else
! extern int tputs P_ ((const char *, int, int (*)(int)));
  extern int tgetent P_ ((char *, const char *));
  extern int tgetflag P_ ((char *id));
  extern int tgetnum P_ ((char *id));
*************** to do `unset TERMCAP' (C-shell: `unseten
*** 2689,2700 ****
  
  /* VARARGS 1 */
  void
! fatal (str, arg1, arg2)
!      char *str, *arg1, *arg2;
  {
    fprintf (stderr, "emacs: ");
!   fprintf (stderr, str, arg1, arg2);
!   fprintf (stderr, "\n");
    fflush (stderr);
    exit (1);
  }
--- 2690,2702 ----
  
  /* VARARGS 1 */
  void
! fatal (const char *str, ...)
  {
+   va_list ap;
+   va_start (ap, str);
    fprintf (stderr, "emacs: ");
!   vfprintf (stderr, str, ap);
!   va_end (ap);
    fflush (stderr);
    exit (1);
  }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]