Commit 1dae0f0a authored by Andreas Schwab's avatar Andreas Schwab

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.
parent 99033785
2011-07-10 Andreas Schwab <schwab@linux-m68k.org>
* 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 <eggert@cs.ucla.edu>
Fix minor problems found by static checking (Bug#9031).
......
......@@ -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 */
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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)
{
......
......@@ -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;
......
......@@ -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 <stdio.h>
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 */
......@@ -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];
......
......@@ -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;