From 1dae0f0aadd0e0fe51893aff89bb3220cba953db Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Sun, 10 Jul 2011 10:20:10 +0200 Subject: [PATCH] Protoize * src/buffer.c (mmap_init, mmap_find, mmap_free_1, mmap_enlarge) (mmap_set_vars, mmap_alloc, mmap_free, mmap_realloc): Protoize. * src/data.c (fmod): Likewise. * src/dispnew.c (swap_glyphs_in_rows): Likewise. * src/emacs.c (memory_warning_signal): Likewise. * src/floatfns.c (float_error): Likewise. * src/font.c (check_gstring, check_otf_features, otf_tag_symbol) (otf_open, font_otf_capability, generate_otf_features) (font_otf_DeviceTable, font_otf_ValueRecord, font_otf_Anchor): Likewise. * src/image.c (pbm_read_file): Likewise. * src/indent.c (string_display_width): Likewise. * src/intervals.c (check_for_interval, search_for_interval) (inc_interval_count, count_intervals, root_interval) (adjust_intervals_for_insertion, make_new_interval): Likewise. * src/lread.c (defalias): Likewise. * src/regex.c (set_image_of_range_1, set_image_of_range) (regex_grow_registers): Likewise. * src/sysdep.c (strerror): Likewise. * src/termcap.c (valid_filename_p, tprint, main): Likewise. * src/tparam.c (main): Likewise. * src/unexhp9k800.c (run_time_remap, save_data_space) (update_file_ptrs, read_header, write_header, calculate_checksum) (copy_file, copy_rest, display_header): Likewise. * src/widget.c (mark_shell_size_user_specified, create_frame_gcs): Likewise. * src/xdisp.c (check_it): Likewise. * src/xfaces.c (register_color, unregister_color, unregister_colors): Likewise. * src/xfns.c (print_fontset_result): Likewise. * src/xrdb.c (member, fatal, main): Likewise. --- src/ChangeLog | 34 +++++++++ src/buffer.c | 115 +++++++++++++------------------ src/data.c | 3 +- src/dispnew.c | 3 +- src/emacs.c | 3 +- src/floatfns.c | 3 +- src/font.c | 29 +++----- src/image.c | 4 +- src/indent.c | 3 +- src/intervals.c | 24 +++---- src/lread.c | 4 +- src/regex.c | 17 ++--- src/sysdep.c | 3 +- src/termcap.c | 50 +++++++------- src/tparam.c | 5 +- src/unexhp9k800.c | 172 +++++++++++++++++++++------------------------- src/widget.c | 6 +- src/xdisp.c | 3 +- src/xfaces.c | 10 +-- src/xfns.c | 7 +- src/xrdb.c | 23 +++---- 21 files changed, 238 insertions(+), 283 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 64ea0a5bcf..f8acc3b383 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,37 @@ +2011-07-10 Andreas Schwab + + * buffer.c (mmap_init, mmap_find, mmap_free_1, mmap_enlarge) + (mmap_set_vars, mmap_alloc, mmap_free, mmap_realloc): Protoize. + * data.c (fmod): Likewise. + * dispnew.c (swap_glyphs_in_rows): Likewise. + * emacs.c (memory_warning_signal): Likewise. + * floatfns.c (float_error): Likewise. + * font.c (check_gstring, check_otf_features, otf_tag_symbol) + (otf_open, font_otf_capability, generate_otf_features) + (font_otf_DeviceTable, font_otf_ValueRecord, font_otf_Anchor): + Likewise. + * image.c (pbm_read_file): Likewise. + * indent.c (string_display_width): Likewise. + * intervals.c (check_for_interval, search_for_interval) + (inc_interval_count, count_intervals, root_interval) + (adjust_intervals_for_insertion, make_new_interval): Likewise. + * lread.c (defalias): Likewise. + * regex.c (set_image_of_range_1, set_image_of_range) + (regex_grow_registers): Likewise. + * sysdep.c (strerror): Likewise. + * termcap.c (valid_filename_p, tprint, main): Likewise. + * tparam.c (main): Likewise. + * unexhp9k800.c (run_time_remap, save_data_space) + (update_file_ptrs, read_header, write_header, calculate_checksum) + (copy_file, copy_rest, display_header): Likewise. + * widget.c (mark_shell_size_user_specified, create_frame_gcs): + Likewise. + * xdisp.c (check_it): Likewise. + * xfaces.c (register_color, unregister_color, unregister_colors): + Likewise. + * xfns.c (print_fontset_result): Likewise. + * xrdb.c (member, fatal, main): Likewise. + 2011-07-10 Paul Eggert Fix minor problems found by static checking (Bug#9031). diff --git a/src/buffer.c b/src/buffer.c index e2f34d629e..1b8b111789 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -4466,24 +4466,40 @@ static int mmap_initialized_p; #define MMAP_ALLOCATED_P(start, end) 1 #endif -/* Function prototypes. */ +/* Perform necessary intializations for the use of mmap. */ -static int mmap_free_1 (struct mmap_region *); -static int mmap_enlarge (struct mmap_region *, int); -static struct mmap_region *mmap_find (POINTER_TYPE *, POINTER_TYPE *); -static POINTER_TYPE *mmap_alloc (POINTER_TYPE **, size_t); -static POINTER_TYPE *mmap_realloc (POINTER_TYPE **, size_t); -static void mmap_free (POINTER_TYPE **ptr); -static void mmap_init (void); +static void +mmap_init (void) +{ +#if MAP_ANON == 0 + /* The value of mmap_fd is initially 0 in temacs, and -1 + in a dumped Emacs. */ + if (mmap_fd <= 0) + { + /* No anonymous mmap -- we need the file descriptor. */ + mmap_fd = open ("/dev/zero", O_RDONLY); + if (mmap_fd == -1) + fatal ("Cannot open /dev/zero: %s", emacs_strerror (errno)); + } +#endif /* MAP_ANON == 0 */ + + if (mmap_initialized_p) + return; + mmap_initialized_p = 1; +#if MAP_ANON != 0 + mmap_fd = -1; +#endif + + mmap_page_size = getpagesize (); +} /* Return a region overlapping address range START...END, or null if none. END is not including, i.e. the last byte in the range is at END - 1. */ static struct mmap_region * -mmap_find (start, end) - POINTER_TYPE *start, *end; +mmap_find (POINTER_TYPE *start, POINTER_TYPE *end); { struct mmap_region *r; char *s = (char *) start, *e = (char *) end; @@ -4512,8 +4528,7 @@ mmap_find (start, end) the region. Value is non-zero if successful. */ static int -mmap_free_1 (r) - struct mmap_region *r; +mmap_free_1 (struct mmap_region *r) { if (r->next) r->next->prev = r->prev; @@ -4536,9 +4551,7 @@ mmap_free_1 (r) Value is non-zero if successful. */ static int -mmap_enlarge (r, npages) - struct mmap_region *r; - int npages; +mmap_enlarge (struct mmap_region *r, int npages) { char *region_end = (char *) r + r->nbytes_mapped; size_t nbytes; @@ -4602,8 +4615,7 @@ mmap_enlarge (r, npages) when Emacs starts. */ void -mmap_set_vars (restore_p) - int restore_p; +mmap_set_vars (int restore_p) { struct mmap_region *r; @@ -4636,9 +4648,7 @@ mmap_set_vars (restore_p) return null. */ static POINTER_TYPE * -mmap_alloc (var, nbytes) - POINTER_TYPE **var; - size_t nbytes; +mmap_alloc (POINTER_TYPE **var, size_t nbytes) { void *p; size_t map; @@ -4675,15 +4685,29 @@ mmap_alloc (var, nbytes) } +/* Free a block of relocatable storage whose data is pointed to by + PTR. Store 0 in *PTR to show there's no block allocated. */ + +static void +mmap_free (POINTER_TYPE **var) +{ + mmap_init (); + + if (*var) + { + mmap_free_1 (MMAP_REGION (*var)); + *var = NULL; + } +} + + /* Given a pointer at address VAR to data allocated with mmap_alloc, resize it to size NBYTES. Change *VAR to reflect the new block, and return this value. If more memory cannot be allocated, then leave *VAR unchanged, and return null. */ static POINTER_TYPE * -mmap_realloc (var, nbytes) - POINTER_TYPE **var; - size_t nbytes; +mmap_realloc (POINTER_TYPE **var, size_t nbytes) { POINTER_TYPE *result; @@ -4753,51 +4777,6 @@ mmap_realloc (var, nbytes) } -/* Free a block of relocatable storage whose data is pointed to by - PTR. Store 0 in *PTR to show there's no block allocated. */ - -static void -mmap_free (var) - POINTER_TYPE **var; -{ - mmap_init (); - - if (*var) - { - mmap_free_1 (MMAP_REGION (*var)); - *var = NULL; - } -} - - -/* Perform necessary intializations for the use of mmap. */ - -static void -mmap_init () -{ -#if MAP_ANON == 0 - /* The value of mmap_fd is initially 0 in temacs, and -1 - in a dumped Emacs. */ - if (mmap_fd <= 0) - { - /* No anonymous mmap -- we need the file descriptor. */ - mmap_fd = open ("/dev/zero", O_RDONLY); - if (mmap_fd == -1) - fatal ("Cannot open /dev/zero: %s", emacs_strerror (errno)); - } -#endif /* MAP_ANON == 0 */ - - if (mmap_initialized_p) - return; - mmap_initialized_p = 1; - -#if MAP_ANON != 0 - mmap_fd = -1; -#endif - - mmap_page_size = getpagesize (); -} - #endif /* USE_MMAP_FOR_BUFFERS */ diff --git a/src/data.c b/src/data.c index 6b4ea32ac9..7bc04592c5 100644 --- a/src/data.c +++ b/src/data.c @@ -2736,8 +2736,7 @@ Both must be integers or markers. */) #ifndef HAVE_FMOD double -fmod (f1, f2) - double f1, f2; +fmod (double f1, double f2) { double r = f1; diff --git a/src/dispnew.c b/src/dispnew.c index 8691c92185..0026aafafc 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -1062,8 +1062,7 @@ increment_row_positions (struct glyph_row *row, B without changing glyph pointers in A and B. */ static void -swap_glyphs_in_rows (a, b) - struct glyph_row *a, *b; +swap_glyphs_in_rows (struct glyph_row *a, struct glyph_row *b) { int area; diff --git a/src/emacs.c b/src/emacs.c index c1d517900c..bc62735ab8 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -354,8 +354,7 @@ fatal_error_signal (int sig) /* Handler for SIGDANGER. */ void -memory_warning_signal (sig) - int sig; +memory_warning_signal (int sig) { signal (sig, memory_warning_signal); SIGNAL_THREAD_CHECK (sig); diff --git a/src/floatfns.c b/src/floatfns.c index b5c8b4af5c..e003f492fe 100644 --- a/src/floatfns.c +++ b/src/floatfns.c @@ -961,8 +961,7 @@ Rounds the value toward zero. */) #ifdef FLOAT_CATCH_SIGILL static void -float_error (signo) - int signo; +float_error (int signo) { if (! in_float) fatal_error_signal (signo); diff --git a/src/font.c b/src/font.c index 5aff20b134..5f8d22157d 100644 --- a/src/font.c +++ b/src/font.c @@ -1738,8 +1738,7 @@ font_parse_family_registry (Lisp_Object family, Lisp_Object registry, Lisp_Objec #define LGSTRING_GLYPH_SIZE 8 static int -check_gstring (gstring) - Lisp_Object gstring; +check_gstring (Lisp_Object gstring) { Lisp_Object val; int i, j; @@ -1793,8 +1792,7 @@ check_gstring (gstring) } static void -check_otf_features (otf_features) - Lisp_Object otf_features; +check_otf_features (Lisp_Object otf_features) { Lisp_Object val; @@ -1827,8 +1825,7 @@ check_otf_features (otf_features) Lisp_Object otf_list; static Lisp_Object -otf_tag_symbol (tag) - OTF_Tag tag; +otf_tag_symbol (OTF_Tag tag) { char name[5]; @@ -1837,8 +1834,7 @@ otf_tag_symbol (tag) } static OTF * -otf_open (file) - Lisp_Object file; +otf_open (Lisp_Object file) { Lisp_Object val = Fassoc (file, otf_list); OTF *otf; @@ -1860,8 +1856,7 @@ otf_open (file) (struct font_driver).otf_capability. */ Lisp_Object -font_otf_capability (font) - struct font *font; +font_otf_capability (struct font *font) { OTF *otf; Lisp_Object capability = Fcons (Qnil, Qnil); @@ -1935,9 +1930,7 @@ font_otf_capability (font) FEATURES. */ static void -generate_otf_features (spec, features) - Lisp_Object spec; - char *features; +generate_otf_features (Lisp_Object spec, char *features) { Lisp_Object val; char *p; @@ -1972,8 +1965,7 @@ generate_otf_features (spec, features) } Lisp_Object -font_otf_DeviceTable (device_table) - OTF_DeviceTable *device_table; +font_otf_DeviceTable (OTF_DeviceTable *device_table) { int len = device_table->StartSize - device_table->EndSize + 1; @@ -1982,9 +1974,7 @@ font_otf_DeviceTable (device_table) } Lisp_Object -font_otf_ValueRecord (value_format, value_record) - int value_format; - OTF_ValueRecord *value_record; +font_otf_ValueRecord (int value_format, OTF_ValueRecord *value_record) { Lisp_Object val = Fmake_vector (make_number (8), Qnil); @@ -2008,8 +1998,7 @@ font_otf_ValueRecord (value_format, value_record) } Lisp_Object -font_otf_Anchor (anchor) - OTF_Anchor *anchor; +font_otf_Anchor (OTF_Anchor *anchor) { Lisp_Object val; diff --git a/src/image.c b/src/image.c index 6e8440fb43..fa39ff1268 100644 --- a/src/image.c +++ b/src/image.c @@ -5007,9 +5007,7 @@ pbm_scan_number (unsigned char **s, unsigned char *end) occurred. *SIZE is set to the size of the file. */ static char * -pbm_read_file (file, size) - Lisp_Object file; - int *size; +pbm_read_file (Lisp_Object file, int *size) { FILE *fp = NULL; char *buf = NULL; diff --git a/src/indent.c b/src/indent.c index 02d99d14de..5c5966175a 100644 --- a/src/indent.c +++ b/src/indent.c @@ -725,8 +725,7 @@ current_column_1 (void) If END is nil, that stands for the end of STRING. */ static double -string_display_width (string, beg, end) - Lisp_Object string, beg, end; +string_display_width (Lisp_Object string, Lisp_Object beg, Lisp_Object end) { register int col; register unsigned char *ptr, *stop; diff --git a/src/intervals.c b/src/intervals.c index 4de001f2ff..2063655cdb 100644 --- a/src/intervals.c +++ b/src/intervals.c @@ -247,8 +247,7 @@ static int zero_length; INTERVAL search_interval, found_interval; void -check_for_interval (i) - register INTERVAL i; +check_for_interval (INTERVAL i) { if (i == search_interval) { @@ -258,8 +257,7 @@ check_for_interval (i) } INTERVAL -search_for_interval (i, tree) - register INTERVAL i, tree; +search_for_interval (INTERVAL i, INTERVAL tree) { icount = 0; search_interval = i; @@ -269,8 +267,7 @@ search_for_interval (i, tree) } static void -inc_interval_count (i) - INTERVAL i; +inc_interval_count (INTERVAL i) { icount++; if (LENGTH (i) == 0) @@ -280,8 +277,7 @@ inc_interval_count (i) } int -count_intervals (i) - register INTERVAL i; +count_intervals (INTERVAL i) { icount = 0; idepth = 0; @@ -292,8 +288,7 @@ count_intervals (i) } static INTERVAL -root_interval (interval) - INTERVAL interval; +root_interval (INTERVAL interval) { register INTERVAL i = interval; @@ -804,9 +799,8 @@ update_interval (register INTERVAL i, EMACS_INT pos) to the root. */ static INTERVAL -adjust_intervals_for_insertion (tree, position, length) - INTERVAL tree; - EMACS_INT position, length; +adjust_intervals_for_insertion (INTERVAL tree, EMACS_INT position, + EMACS_INT length) { register EMACS_INT relative_position; register INTERVAL this; @@ -1615,9 +1609,7 @@ reproduce_tree_obj (INTERVAL source, Lisp_Object parent) interval. */ static INTERVAL -make_new_interval (intervals, start, length) - INTERVAL intervals; - EMACS_INT start, length; +make_new_interval (INTERVAL intervals, EMACS_INT start, EMACS_INT length) { INTERVAL slot; diff --git a/src/lread.c b/src/lread.c index a9b69a1977..6cb217a21c 100644 --- a/src/lread.c +++ b/src/lread.c @@ -4000,9 +4000,7 @@ defsubr (struct Lisp_Subr *sname) #ifdef NOTDEF /* use fset in subr.el now */ void -defalias (sname, string) - struct Lisp_Subr *sname; - char *string; +defalias (struct Lisp_Subr *sname, char *string) { Lisp_Object sym; sym = intern (string); diff --git a/src/regex.c b/src/regex.c index 479239897b..625c59ccf0 100644 --- a/src/regex.c +++ b/src/regex.c @@ -2202,10 +2202,9 @@ extend_range_table_work_area (struct range_table_work_area *work_area) Returns -1 if successful, REG_ESPACE if ran out of space. */ static int -set_image_of_range_1 (work_area, start, end, translate) - RE_TRANSLATE_TYPE translate; - struct range_table_work_area *work_area; - re_wchar_t start, end; +set_image_of_range_1 (struct range_table_work_area *work_area, + re_wchar_t start, re_wchar_t end, + RE_TRANSLATE_TYPE translate) { /* `one_case' indicates a character, or a run of characters, each of which is an isolate (no case-equivalents). @@ -2355,10 +2354,9 @@ set_image_of_range_1 (work_area, start, end, translate) Returns -1 if successful, REG_ESPACE if ran out of space. */ static int -set_image_of_range (work_area, start, end, translate) - RE_TRANSLATE_TYPE translate; - struct range_table_work_area *work_area; - re_wchar_t start, end; +set_image_of_range (struct range_table_work_area *work_area, + re_wchar_t start, re_wchar_t end, + RE_TRANSLATE_TYPE translate) { re_wchar_t cmin, cmax; @@ -2445,8 +2443,7 @@ static re_char **best_regstart, **best_regend; but don't make them smaller. */ static -regex_grow_registers (num_regs) - int num_regs; +regex_grow_registers (int num_regs) { if (num_regs > regs_allocated_size) { diff --git a/src/sysdep.c b/src/sysdep.c index 46667cf292..fc2f846b0d 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1802,8 +1802,7 @@ get_random (void) #ifndef HAVE_STRERROR #ifndef WINDOWSNT char * -strerror (errnum) - int errnum; +strerror (int errnum) { extern char *sys_errlist[]; extern int sys_nerr; diff --git a/src/termcap.c b/src/termcap.c index e191f6b3af..96b9303d62 100644 --- a/src/termcap.c +++ b/src/termcap.c @@ -338,8 +338,7 @@ static int name_match (char *line, char *name); #ifdef MSDOS /* MW, May 1993 */ static int -valid_filename_p (fn) - char *fn; +valid_filename_p (char *fn) { return *fn == '/' || fn[1] == ':'; } @@ -669,9 +668,29 @@ gobble_line (int fd, register struct termcap_buffer *bufp, char *append_end) #include -main (argc, argv) - int argc; - char **argv; +static void +tprint (char *cap) +{ + char *x = tgetstr (cap, 0); + register char *y; + + printf ("%s: ", cap); + if (x) + { + for (y = x; *y; y++) + if (*y <= ' ' || *y == 0177) + printf ("\\%0o", *y); + else + putchar (*y); + free (x); + } + else + printf ("none"); + putchar ('\n'); +} + +int +main (int argc, char **argv) { char *term; char *buf; @@ -693,27 +712,8 @@ main (argc, argv) printf ("co: %d\n", tgetnum ("co")); printf ("am: %d\n", tgetflag ("am")); -} - -tprint (cap) - char *cap; -{ - char *x = tgetstr (cap, 0); - register char *y; - printf ("%s: ", cap); - if (x) - { - for (y = x; *y; y++) - if (*y <= ' ' || *y == 0177) - printf ("\\%0o", *y); - else - putchar (*y); - free (x); - } - else - printf ("none"); - putchar ('\n'); + return 0; } #endif /* TEST */ diff --git a/src/tparam.c b/src/tparam.c index 6aae0b97db..ed28cd7397 100644 --- a/src/tparam.c +++ b/src/tparam.c @@ -265,9 +265,8 @@ tparam1 (const char *string, char *outstring, int len, #ifdef DEBUG -main (argc, argv) - int argc; - char **argv; +int +main (int argc, char **argv) { char buf[50]; int args[3]; diff --git a/src/unexhp9k800.c b/src/unexhp9k800.c index f27415a252..ce65faffd4 100644 --- a/src/unexhp9k800.c +++ b/src/unexhp9k800.c @@ -64,8 +64,7 @@ static long brk_on_dump = 0; /* Called from main, if we use shared libraries. */ int -run_time_remap (ignored) - char *ignored; +run_time_remap (char *ignored) { brk ((char *) brk_on_dump); } @@ -74,74 +73,11 @@ run_time_remap (ignored) #define roundup(x,n) (((x) + ((n) - 1)) & ~((n) - 1)) /* n is power of 2 */ #define min(x,y) (((x) < (y)) ? (x) : (y)) - -/* Create a new a.out file, same as old but with current data space */ -void -unexec (const char *new_name, /* name of the new a.out file to be created */ - const char *old_name) /* name of the old a.out file */ -{ - int old, new; - int old_size, new_size; - struct header hdr; - struct som_exec_auxhdr auxhdr; - long i; - - /* For the greatest flexibility, should create a temporary file in - the same directory as the new file. When everything is complete, - rename the temp file to the new name. - This way, a program could update its own a.out file even while - it is still executing. If problems occur, everything is still - intact. NOT implemented. */ - - /* Open the input and output a.out files */ - old = open (old_name, O_RDONLY); - if (old < 0) - { perror (old_name); exit (1); } - new = open (new_name, O_CREAT|O_RDWR|O_TRUNC, 0777); - if (new < 0) - { perror (new_name); exit (1); } - - /* Read the old headers */ - read_header (old, &hdr, &auxhdr); - - brk_on_dump = (long) sbrk (0); - - /* Decide how large the new and old data areas are */ - old_size = auxhdr.exec_dsize; - /* I suspect these two statements are separate - to avoid a compiler bug in hpux version 8. */ - i = (long) sbrk (0); - new_size = i - auxhdr.exec_dmem; - - /* Copy the old file to the new, up to the data space */ - lseek (old, 0, 0); - copy_file (old, new, auxhdr.exec_dfile); - - /* Skip the old data segment and write a new one */ - lseek (old, old_size, 1); - save_data_space (new, &hdr, &auxhdr, new_size); - - /* Copy the rest of the file */ - copy_rest (old, new); - - /* Update file pointers since we probably changed size of data area */ - update_file_ptrs (new, &hdr, &auxhdr, auxhdr.exec_dfile, new_size-old_size); - - /* Save the modified header */ - write_header (new, &hdr, &auxhdr); - - /* Close the binary file */ - close (old); - close (new); -} - /* Save current data space in the file, update header. */ -save_data_space (file, hdr, auxhdr, size) - int file; - struct header *hdr; - struct som_exec_auxhdr *auxhdr; - int size; +static void +save_data_space (int file, struct header *hdr, struct som_exec_auxhdr *auxhdr, + int size) { /* Write the entire data space out to the file */ if (write (file, auxhdr->exec_dmem, size) != size) @@ -154,12 +90,9 @@ save_data_space (file, hdr, auxhdr, size) /* Update the values of file pointers when something is inserted. */ -update_file_ptrs (file, hdr, auxhdr, location, offset) - int file; - struct header *hdr; - struct som_exec_auxhdr *auxhdr; - unsigned int location; - int offset; +static void +update_file_ptrs (int file, struct header *hdr, struct som_exec_auxhdr *auxhdr, + unsigned int location, int offset) { struct subspace_dictionary_record subspace; int i; @@ -205,10 +138,8 @@ update_file_ptrs (file, hdr, auxhdr, location, offset) /* Read in the header records from an a.out file. */ -read_header (file, hdr, auxhdr) - int file; - struct header *hdr; - struct som_exec_auxhdr *auxhdr; +static void +read_header (int file, struct header *hdr, struct som_exec_auxhdr *auxhdr) { /* Read the header in */ @@ -233,10 +164,8 @@ read_header (file, hdr, auxhdr) /* Write out the header records into an a.out file. */ -write_header (file, hdr, auxhdr) - int file; - struct header *hdr; - struct som_exec_auxhdr *auxhdr; +static void +write_header (int file, struct header *hdr, struct som_exec_auxhdr *auxhdr) { /* Update the checksum */ hdr->checksum = calculate_checksum (hdr); @@ -252,8 +181,8 @@ write_header (file, hdr, auxhdr) /* Calculate the checksum of a SOM header record. */ -calculate_checksum (hdr) - struct header *hdr; +static int +calculate_checksum (struct header *hdr) { int checksum, i, *ptr; @@ -267,9 +196,8 @@ calculate_checksum (hdr) /* Copy size bytes from the old file to the new one. */ -copy_file (old, new, size) - int new, old; - int size; +static void +copy_file (int old, int new, int size) { int len; int buffer[8192]; /* word aligned will be faster */ @@ -286,8 +214,8 @@ copy_file (old, new, size) /* Copy the rest of the file, up to EOF. */ -copy_rest (old, new) - int new, old; +static void +copy_rest (int old, int new) { int buffer[4096]; int len; @@ -301,9 +229,8 @@ copy_rest (old, new) } #ifdef DEBUG -display_header (hdr, auxhdr) - struct header *hdr; - struct som_exec_auxhdr *auxhdr; +static void +display_header (struct header *hdr, struct som_exec_auxhdr *auxhdr) { /* Display the header information (debug) */ printf ("\n\nFILE HEADER\n"); @@ -320,3 +247,64 @@ display_header (hdr, auxhdr) hdr->unloadable_sp_location, hdr->unloadable_sp_size); } #endif /* DEBUG */ + + +/* Create a new a.out file, same as old but with current data space */ +void +unexec (const char *new_name, /* name of the new a.out file to be created */ + const char *old_name) /* name of the old a.out file */ +{ + int old, new; + int old_size, new_size; + struct header hdr; + struct som_exec_auxhdr auxhdr; + long i; + + /* For the greatest flexibility, should create a temporary file in + the same directory as the new file. When everything is complete, + rename the temp file to the new name. + This way, a program could update its own a.out file even while + it is still executing. If problems occur, everything is still + intact. NOT implemented. */ + + /* Open the input and output a.out files */ + old = open (old_name, O_RDONLY); + if (old < 0) + { perror (old_name); exit (1); } + new = open (new_name, O_CREAT|O_RDWR|O_TRUNC, 0777); + if (new < 0) + { perror (new_name); exit (1); } + + /* Read the old headers */ + read_header (old, &hdr, &auxhdr); + + brk_on_dump = (long) sbrk (0); + + /* Decide how large the new and old data areas are */ + old_size = auxhdr.exec_dsize; + /* I suspect these two statements are separate + to avoid a compiler bug in hpux version 8. */ + i = (long) sbrk (0); + new_size = i - auxhdr.exec_dmem; + + /* Copy the old file to the new, up to the data space */ + lseek (old, 0, 0); + copy_file (old, new, auxhdr.exec_dfile); + + /* Skip the old data segment and write a new one */ + lseek (old, old_size, 1); + save_data_space (new, &hdr, &auxhdr, new_size); + + /* Copy the rest of the file */ + copy_rest (old, new); + + /* Update file pointers since we probably changed size of data area */ + update_file_ptrs (new, &hdr, &auxhdr, auxhdr.exec_dfile, new_size-old_size); + + /* Save the modified header */ + write_header (new, &hdr, &auxhdr); + + /* Close the binary file */ + close (old); + close (new); +} diff --git a/src/widget.c b/src/widget.c index 6d871ad7cb..a09ec2631a 100644 --- a/src/widget.c +++ b/src/widget.c @@ -224,8 +224,7 @@ get_wm_shell (Widget w) #if 0 /* Currently not used. */ static void -mark_shell_size_user_specified (wmshell) - Widget wmshell; +mark_shell_size_user_specified (Widget wmshell) { if (! XtIsWMShell (wmshell)) abort (); /* This is kind of sleazy, but I can't see how else to tell it to make it @@ -510,8 +509,7 @@ update_wm_hints (EmacsFrame ew) #if 0 static void -create_frame_gcs (ew) - EmacsFrame ew; +create_frame_gcs (EmacsFrame ew) { struct frame *s = ew->emacs_frame.frame; diff --git a/src/xdisp.c b/src/xdisp.c index 774bc22699..871317d86b 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -2209,8 +2209,7 @@ safe_call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2) This is for debugging. It is too slow to do unconditionally. */ static void -check_it (it) - struct it *it; +check_it (struct it *it) { if (it->method == GET_FROM_STRING) { diff --git a/src/xfaces.c b/src/xfaces.c index 91f4b13346..c1e75ab3e5 100644 --- a/src/xfaces.c +++ b/src/xfaces.c @@ -536,8 +536,7 @@ int color_count[256]; /* Register color PIXEL as allocated. */ void -register_color (pixel) - unsigned long pixel; +register_color (unsigned long pixel) { xassert (pixel < 256); ++color_count[pixel]; @@ -547,8 +546,7 @@ register_color (pixel) /* Register color PIXEL as deallocated. */ void -unregister_color (pixel) - unsigned long pixel; +unregister_color (unsigned long pixel) { xassert (pixel < 256); if (color_count[pixel] > 0) @@ -561,9 +559,7 @@ unregister_color (pixel) /* Register N colors from PIXELS as deallocated. */ void -unregister_colors (pixels, n) - unsigned long *pixels; - int n; +unregister_colors (unsigned long *pixels, int n) { int i; for (i = 0; i < n; ++i) diff --git a/src/xfns.c b/src/xfns.c index c70f4bb9a8..0d1e4a1bb5 100644 --- a/src/xfns.c +++ b/src/xfns.c @@ -2001,11 +2001,8 @@ xic_create_fontsetname (const char *base_fontname, int motif) #ifdef DEBUG_XIC_FONTSET static void -print_fontset_result (xfs, name, missing_list, missing_count) - XFontSet xfs; - char *name; - char **missing_list; - int missing_count; +print_fontset_result (XFontSet xfs, char *name, char **missing_list, + int missing_count) { if (xfs) fprintf (stderr, "XIC Fontset created: %s\n", name); diff --git a/src/xrdb.c b/src/xrdb.c index e18ff65f79..6a16e3260b 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -651,9 +651,7 @@ typedef char **List; #define free_arglist(list) static List -member (elt, list) - char *elt; - List list; +member (char *elt, List list) { List p; @@ -665,20 +663,17 @@ member (elt, list) } static void -fatal (msg, prog, x1, x2, x3, x4, x5) - char *msg, *prog; - int x1, x2, x3, x4, x5; +fatal (char *msg, char *prog) { - if (errno) - perror (prog); + if (errno) + perror (prog); - (void) fprintf (stderr, msg, prog, x1, x2, x3, x4, x5); - exit (1); + (void) fprintf (stderr, msg, prog); + exit (1); } -main (argc, argv) - int argc; - char **argv; +int +main (int argc, char **argv) { Display *display; char *displayname, *resource_string, *class, *name; @@ -749,5 +744,7 @@ main (argc, argv) printf ("\tExit.\n\n"); XCloseDisplay (display); + + return 0; } #endif /* TESTRM */ -- 2.20.1