summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog127
-rw-r--r--src/atimer.c47
-rw-r--r--src/callproc.c20
-rw-r--r--src/character.h68
-rw-r--r--src/cm.c10
-rw-r--r--src/cm.h2
-rw-r--r--src/coding.c3
-rw-r--r--src/composite.c34
-rw-r--r--src/deps.mk4
-rw-r--r--src/emacs.c17
-rw-r--r--src/fileio.c7
-rw-r--r--src/frame.c5
-rw-r--r--src/ftfont.c49
-rw-r--r--src/intervals.c3
-rw-r--r--src/intervals.h10
-rw-r--r--src/lisp.h10
-rw-r--r--src/process.c75
-rw-r--r--src/region-cache.c25
-rw-r--r--src/region-cache.h2
-rw-r--r--src/scroll.c4
-rw-r--r--src/sound.c10
-rw-r--r--src/sysdep.c6
-rw-r--r--src/terminfo.c23
-rw-r--r--src/textprop.c32
-rw-r--r--src/tparam.h4
-rw-r--r--src/xdisp.c22
-rw-r--r--src/xfont.c2
-rw-r--r--src/xftfont.c16
-rw-r--r--src/xmenu.c2
-rw-r--r--src/xml.c3
30 files changed, 378 insertions, 264 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index f489a233683..a4312efceb9 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,130 @@
+2011-03-23 Paul Eggert <eggert@cs.ucla.edu>
+
+ Fix more problems found by GCC 4.5.2's static checks.
+
+ * coding.c (encode_coding_raw_text): Avoid unnecessary test
+ the first time through the loop, since we know p0 < p1 then.
+ This also avoids a gcc -Wstrict-overflow warning.
+
+ * lisp.h (SAFE_ALLOCA, SAFE_ALLOCA_LISP): Avoid 'int' overflow
+ leading to a memory leak, possible in functions like
+ load_charset_map_from_file that can allocate an unbounded number
+ of objects (Bug#8318).
+
+ * xmenu.c (set_frame_menubar): Use EMACS_UINT, not int, for indexes
+ that could (at least in theory) be that large.
+
+ * xdisp.c (message_log_check_duplicate): Return unsigned long, not int.
+ This is less likely to overflow, and avoids undefined behavior if
+ overflow does occur. All callers changed. Use strtoul to scan
+ for the unsigned long integer.
+ (pint2hrstr): Simplify and tune code slightly.
+ This also avoids a (bogus) GCC warning with gcc -Wstrict-overflow.
+
+ * scroll.c (do_scrolling): Work around GCC bug 48228.
+ See <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48228>.
+
+ * frame.c (Fmodify_frame_parameters): Simplify loop counter.
+ This also avoids a warning with gcc -Wstrict-overflow.
+ (validate_x_resource_name): Simplify count usage.
+ This also avoids a warning with gcc -Wstrict-overflow.
+
+ * fileio.c (Fcopy_file): Report error if fchown or fchmod
+ fail (Bug#8306).
+
+ * emacs.c (Fdaemon_initialized): Do not ignore I/O errors (Bug#8303).
+
+ * process.c (Fmake_network_process): Use socklen_t, not int,
+ where POSIX says socklen_t is required in portable programs.
+ This fixes a porting bug on hosts like 64-bit HP-UX, where
+ socklen_t is wider than int (Bug#8277).
+ (Fmake_network_process, server_accept_connection):
+ (wait_reading_process_output, read_process_output):
+ Likewise.
+
+ * process.c: Rename or move locals to avoid shadowing.
+ (list_processes_1, Fmake_network_process):
+ (read_process_output_error_handler, exec_sentinel_error_handler):
+ Rename or move locals.
+ (Fmake_network_process): Define label "retry_connect" only if needed.
+ (Fnetwork_interface_info): Fix pointer signedness.
+ (process_send_signal): Add cast to avoid pointer signedness problem.
+ (FIRST_PROC_DESC, IF_NON_BLOCKING_CONNECT): Remove unused macros.
+ (create_process): Use 'volatile' to avoid vfork clobbering (Bug#8298).
+
+ Make tparam.h and terminfo.c consistent.
+ * cm.c (tputs, tgoto, BC, UP): Remove extern decls. Include
+ tparam.h instead, since it declares them.
+ * cm.h (PC): Remove extern decl; tparam.h now does this.
+ * deps.mk (cm.o, terminfo.o): Depend on tparam.h.
+ * terminfo.c: Include tparam.h, to check interfaces.
+ (tparm): Make 1st arg a const pointer in decl. Put it at top level.
+ (tparam): Adjust signature to match interface in tparam.h;
+ this removes some undefined behavior. Check that outstring and len
+ are zero, which they always are with Emacs.
+ * tparam.h (PC, BC, UP): New extern decls.
+
+ * xftfont.c (xftfont_shape): Now static, and defined only if needed.
+ (xftfont_open): Rename locals to avoid shadowing.
+
+ * ftfont.c (ftfont_resolve_generic_family): Fix pointer signedness.
+ (ftfont_otf_capability, ftfont_shape): Omit decls if not needed.
+ (OTF_TAG_SYM): Omit macro if not needed.
+ (ftfont_list): Remove unused local.
+ (get_adstyle_property, ftfont_pattern_entity):
+ (ftfont_lookup_cache, ftfont_open, ftfont_anchor_point):
+ Rename locals to avoid shadowing.
+
+ * xfont.c (xfont_list_family): Mark var as initialized.
+
+ * xml.c (make_dom): Now static.
+
+ * composite.c (composition_compute_stop_pos): Rename local to
+ avoid shadowing.
+ (composition_reseat_it): Remove unused locals.
+ (find_automatic_composition, composition_adjust_point): Likewise.
+ (composition_update_it): Mark var as initialized.
+ (find_automatic_composition): Mark vars as initialized,
+ with a FIXME (Bug#8290).
+
+ character.h: Rename locals to avoid shadowing.
+ * character.h (PREV_CHAR_BOUNDARY, FETCH_STRING_CHAR_ADVANCE):
+ (FETCH_STRING_CHAR_AS_MULTIBYTE_ADVANCE, FETCH_CHAR_ADVANCE):
+ (FETCH_CHAR_ADVANCE_NO_CHECK, INC_POS, DEC_POS, BUF_INC_POS):
+ (BUF_DEC_POS): Be more systematic about renaming local temporaries
+ to avoid shadowing.
+
+ * textprop.c (property_change_between_p): Remove; unused.
+
+ * intervals.c (interval_start_pos): Now static.
+
+ * intervals.h (CHECK_TOTAL_LENGTH): Avoid empty "else".
+
+ * atimer.c (start_atimer, append_atimer_lists, set_alarm): Rename
+ locals to avoid shadowing.
+
+ * sound.c (wav_play, au_play, Fplay_sound_internal):
+ Fix pointer signedness.
+ (alsa_choose_format): Remove unused local var.
+ (wav_play): Initialize a variable to 0, to prevent undefined
+ behavior (Bug#8278).
+
+ * region-cache.c (insert_cache_boundary): Redo var to avoid shadowing.
+
+ * region-cache.h (pp_cache): New decl, for gcc -Wmissing-prototypes.
+
+ * callproc.c (Fcall_process): Use 'volatile' to avoid vfork
+ clobbering (Bug#8298).
+ * sysdep.c (sys_subshell): Likewise.
+ Previously, the sys_subshell 'volatile' was incorrectly IF_LINTted out.
+
+ * lisp.h (child_setup): Now NO_RETURN unless DOS_NT.
+ This should get cleaned up, so that child_setup has the
+ same signature on all platforms.
+
+ * callproc.c (call_process_cleanup): Now static.
+ (relocate_fd): Rename locals to avoid shadowing.
+
2011-03-22 Chong Yidong <cyd@stupidchicken.com>
* xterm.c (x_clear_frame): Remove XClearWindow call. This appears
diff --git a/src/atimer.c b/src/atimer.c
index 309a4eaee4f..e10add961eb 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -86,7 +86,7 @@ SIGTYPE alarm_signal_handler (int signo);
to cancel_atimer; don't free it yourself. */
struct atimer *
-start_atimer (enum atimer_type type, EMACS_TIME time, atimer_callback fn,
+start_atimer (enum atimer_type type, EMACS_TIME timestamp, atimer_callback fn,
void *client_data)
{
struct atimer *t;
@@ -94,10 +94,10 @@ start_atimer (enum atimer_type type, EMACS_TIME time, atimer_callback fn,
/* Round TIME up to the next full second if we don't have
itimers. */
#ifndef HAVE_SETITIMER
- if (EMACS_USECS (time) != 0)
+ if (EMACS_USECS (timestamp) != 0)
{
- EMACS_SET_USECS (time, 0);
- EMACS_SET_SECS (time, EMACS_SECS (time) + 1);
+ EMACS_SET_USECS (timestamp, 0);
+ EMACS_SET_SECS (timestamp, EMACS_SECS (timestamp) + 1);
}
#endif /* not HAVE_SETITIMER */
@@ -123,18 +123,18 @@ start_atimer (enum atimer_type type, EMACS_TIME time, atimer_callback fn,
switch (type)
{
case ATIMER_ABSOLUTE:
- t->expiration = time;
+ t->expiration = timestamp;
break;
case ATIMER_RELATIVE:
EMACS_GET_TIME (t->expiration);
- EMACS_ADD_TIME (t->expiration, t->expiration, time);
+ EMACS_ADD_TIME (t->expiration, t->expiration, timestamp);
break;
case ATIMER_CONTINUOUS:
EMACS_GET_TIME (t->expiration);
- EMACS_ADD_TIME (t->expiration, t->expiration, time);
- t->interval = time;
+ EMACS_ADD_TIME (t->expiration, t->expiration, timestamp);
+ t->interval = timestamp;
break;
}
@@ -187,24 +187,24 @@ cancel_atimer (struct atimer *timer)
}
-/* Append two lists of atimers LIST1 and LIST2 and return the
+/* Append two lists of atimers LIST_1 and LIST_2 and return the
result list. */
static struct atimer *
-append_atimer_lists (struct atimer *list1, struct atimer *list2)
+append_atimer_lists (struct atimer *list_1, struct atimer *list_2)
{
- if (list1 == NULL)
- return list2;
- else if (list2 == NULL)
- return list1;
+ if (list_1 == NULL)
+ return list_2;
+ else if (list_2 == NULL)
+ return list_1;
else
{
struct atimer *p;
- for (p = list1; p->next; p = p->next)
+ for (p = list_1; p->next; p = p->next)
;
- p->next = list2;
- return list1;
+ p->next = list_2;
+ return list_1;
}
}
@@ -287,28 +287,28 @@ set_alarm (void)
{
if (atimers)
{
- EMACS_TIME now, time;
+ EMACS_TIME now, timestamp;
#ifdef HAVE_SETITIMER
struct itimerval it;
#endif
/* Determine s/us till the next timer is ripe. */
EMACS_GET_TIME (now);
- EMACS_SUB_TIME (time, atimers->expiration, now);
+ EMACS_SUB_TIME (timestamp, atimers->expiration, now);
#ifdef HAVE_SETITIMER
/* Don't set the interval to 0; this disables the timer. */
if (EMACS_TIME_LE (atimers->expiration, now))
{
- EMACS_SET_SECS (time, 0);
- EMACS_SET_USECS (time, 1000);
+ EMACS_SET_SECS (timestamp, 0);
+ EMACS_SET_USECS (timestamp, 1000);
}
memset (&it, 0, sizeof it);
- it.it_value = time;
+ it.it_value = timestamp;
setitimer (ITIMER_REAL, &it, 0);
#else /* not HAVE_SETITIMER */
- alarm (max (EMACS_SECS (time), 1));
+ alarm (max (EMACS_SECS (timestamp), 1));
#endif /* not HAVE_SETITIMER */
}
}
@@ -442,4 +442,3 @@ init_atimer (void)
/* pending_signals is initialized in init_keyboard.*/
signal (SIGALRM, alarm_signal_handler);
}
-
diff --git a/src/callproc.c b/src/callproc.c
index c53a92bbaf8..75f239d1be2 100644
--- a/src/callproc.c
+++ b/src/callproc.c
@@ -107,7 +107,7 @@ call_process_kill (Lisp_Object fdpid)
return Qnil;
}
-Lisp_Object
+static Lisp_Object
call_process_cleanup (Lisp_Object arg)
{
Lisp_Object fdpid = Fcdr (arg);
@@ -180,7 +180,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
(int nargs, register Lisp_Object *args)
{
Lisp_Object infile, buffer, current_dir, path;
- int display_p;
+ volatile int display_p_volatile;
int fd[2];
int filefd;
register int pid;
@@ -190,6 +190,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
int bufsize = CALLPROC_BUFFER_SIZE_MIN;
int count = SPECPDL_INDEX ();
+ const unsigned char **volatile new_argv_volatile;
register const unsigned char **new_argv;
/* File to use for stderr in the child.
t means use same as standard output. */
@@ -343,7 +344,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
UNGCPRO;
}
- display_p = INTERACTIVE && nargs >= 4 && !NILP (args[3]);
+ display_p_volatile = INTERACTIVE && nargs >= 4 && !NILP (args[3]);
filefd = emacs_open (SSDATA (infile), O_RDONLY, 0);
if (filefd < 0)
@@ -371,7 +372,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
&& SREF (path, 1) == ':')
path = Fsubstring (path, make_number (2), Qnil);
- new_argv = (const unsigned char **)
+ new_argv_volatile = new_argv = (const unsigned char **)
alloca (max (2, nargs - 2) * sizeof (char *));
if (nargs > 4)
{
@@ -542,6 +543,8 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
pid = vfork ();
+ new_argv = new_argv_volatile;
+
if (pid == 0)
{
if (fd[0] >= 0)
@@ -673,6 +676,7 @@ usage: (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS) */)
int first = 1;
EMACS_INT total_read = 0;
int carryover = 0;
+ int display_p = display_p_volatile;
int display_on_the_fly = display_p;
struct coding_system saved_coding;
@@ -1272,12 +1276,12 @@ relocate_fd (int fd, int minfd)
#endif
if (new == -1)
{
- const char *message1 = "Error while setting up child: ";
+ const char *message_1 = "Error while setting up child: ";
const char *errmessage = strerror (errno);
- const char *message2 = "\n";
- emacs_write (2, message1, strlen (message1));
+ const char *message_2 = "\n";
+ emacs_write (2, message_1, strlen (message_1));
emacs_write (2, errmessage, strlen (errmessage));
- emacs_write (2, message2, strlen (message2));
+ emacs_write (2, message_2, strlen (message_2));
_exit (1);
}
emacs_close (fd);
diff --git a/src/character.h b/src/character.h
index 4c468e14d2c..91020cadedc 100644
--- a/src/character.h
+++ b/src/character.h
@@ -278,11 +278,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
do { \
if ((p) > (limit)) \
{ \
- const unsigned char *pcb = (p); \
+ const unsigned char *chp = (p); \
do { \
- pcb--; \
- } while (pcb >= limit && ! CHAR_HEAD_P (*pcb)); \
- (p) = (BYTES_BY_CHAR_HEAD (*pcb) == (p) - pcb) ? pcb : (p) - 1; \
+ chp--; \
+ } while (chp >= limit && ! CHAR_HEAD_P (*chp)); \
+ (p) = (BYTES_BY_CHAR_HEAD (*chp) == (p) - chp) ? chp : (p) - 1; \
} \
} while (0)
@@ -353,11 +353,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
CHARIDX++; \
if (STRING_MULTIBYTE (STRING)) \
{ \
- unsigned char *string_ptr = &SDATA (STRING)[BYTEIDX]; \
- int string_len; \
+ unsigned char *chp = &SDATA (STRING)[BYTEIDX]; \
+ int chlen; \
\
- OUTPUT = STRING_CHAR_AND_LENGTH (string_ptr, string_len); \
- BYTEIDX += string_len; \
+ OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \
+ BYTEIDX += chlen; \
} \
else \
{ \
@@ -376,11 +376,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
CHARIDX++; \
if (STRING_MULTIBYTE (STRING)) \
{ \
- unsigned char *ptr = &SDATA (STRING)[BYTEIDX]; \
- int ptrlen; \
+ unsigned char *chp = &SDATA (STRING)[BYTEIDX]; \
+ int chlen; \
\
- OUTPUT = STRING_CHAR_AND_LENGTH (ptr, ptrlen); \
- BYTEIDX += ptrlen; \
+ OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \
+ BYTEIDX += chlen; \
} \
else \
{ \
@@ -416,11 +416,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
CHARIDX++; \
if (!NILP (BVAR (current_buffer, enable_multibyte_characters))) \
{ \
- unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
- int string_len; \
+ unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \
+ int chlen; \
\
- OUTPUT= STRING_CHAR_AND_LENGTH (ptr, string_len); \
- BYTEIDX += string_len; \
+ OUTPUT= STRING_CHAR_AND_LENGTH (chp, chlen); \
+ BYTEIDX += chlen; \
} \
else \
{ \
@@ -436,11 +436,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define FETCH_CHAR_ADVANCE_NO_CHECK(OUTPUT, CHARIDX, BYTEIDX) \
do \
{ \
- unsigned char *ptr = BYTE_POS_ADDR (BYTEIDX); \
- int len; \
+ unsigned char *chp = BYTE_POS_ADDR (BYTEIDX); \
+ int chlen; \
\
- OUTPUT = STRING_CHAR_AND_LENGTH (ptr, len); \
- BYTEIDX += len; \
+ OUTPUT = STRING_CHAR_AND_LENGTH (chp, chlen); \
+ BYTEIDX += chlen; \
CHARIDX++; \
} \
while (0)
@@ -451,8 +451,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define INC_POS(pos_byte) \
do { \
- unsigned char *ptr = BYTE_POS_ADDR (pos_byte); \
- pos_byte += BYTES_BY_CHAR_HEAD (*ptr); \
+ unsigned char *chp = BYTE_POS_ADDR (pos_byte); \
+ pos_byte += BYTES_BY_CHAR_HEAD (*chp); \
} while (0)
@@ -461,16 +461,16 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define DEC_POS(pos_byte) \
do { \
- unsigned char *ptr; \
+ unsigned char *chp; \
\
pos_byte--; \
if (pos_byte < GPT_BYTE) \
- ptr = BEG_ADDR + pos_byte - BEG_BYTE; \
+ chp = BEG_ADDR + pos_byte - BEG_BYTE; \
else \
- ptr = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE; \
- while (!CHAR_HEAD_P (*ptr)) \
+ chp = BEG_ADDR + GAP_SIZE + pos_byte - BEG_BYTE; \
+ while (!CHAR_HEAD_P (*chp)) \
{ \
- ptr--; \
+ chp--; \
pos_byte--; \
} \
} while (0)
@@ -510,8 +510,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define BUF_INC_POS(buf, pos_byte) \
do { \
- unsigned char *bbp = BUF_BYTE_ADDRESS (buf, pos_byte); \
- pos_byte += BYTES_BY_CHAR_HEAD (*bbp); \
+ unsigned char *chp = BUF_BYTE_ADDRESS (buf, pos_byte); \
+ pos_byte += BYTES_BY_CHAR_HEAD (*chp); \
} while (0)
@@ -520,15 +520,15 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#define BUF_DEC_POS(buf, pos_byte) \
do { \
- unsigned char *p; \
+ unsigned char *chp; \
pos_byte--; \
if (pos_byte < BUF_GPT_BYTE (buf)) \
- p = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE; \
+ chp = BUF_BEG_ADDR (buf) + pos_byte - BEG_BYTE; \
else \
- p = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\
- while (!CHAR_HEAD_P (*p)) \
+ chp = BUF_BEG_ADDR (buf) + BUF_GAP_SIZE (buf) + pos_byte - BEG_BYTE;\
+ while (!CHAR_HEAD_P (*chp)) \
{ \
- p--; \
+ chp--; \
pos_byte--; \
} \
} while (0)
diff --git a/src/cm.c b/src/cm.c
index 108ee5720f3..6379955b48c 100644
--- a/src/cm.c
+++ b/src/cm.c
@@ -27,19 +27,11 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "cm.h"
#include "termhooks.h"
#include "termchar.h"
-
-
-/* For now, don't try to include termcap.h. On some systems,
- configure finds a non-standard termcap.h that the main build
- won't find. */
-extern void tputs (const char *, int, int (*)(int));
-extern char *tgoto (const char *, int, int);
+#include "tparam.h"
#define BIG 9999 /* 9999 good on VAXen. For 16 bit machines
use about 2000.... */
-extern char *BC, *UP;
-
int cost; /* sums up costs */
/* ARGSUSED */
diff --git a/src/cm.h b/src/cm.h
index 5d430598f0c..8f23990ce55 100644
--- a/src/cm.h
+++ b/src/cm.h
@@ -96,8 +96,6 @@ struct cm
int cc_vabs;
};
-extern char PC; /* Pad character */
-
/* Shorthand */
#ifndef NoCMShortHand
#define curY(tty) (tty)->Wcm->cm_curY
diff --git a/src/coding.c b/src/coding.c
index 0c2836c19f6..0596d16bf46 100644
--- a/src/coding.c
+++ b/src/coding.c
@@ -5266,11 +5266,12 @@ encode_coding_raw_text (struct coding_system *coding)
unsigned char str[MAX_MULTIBYTE_LENGTH], *p0 = str, *p1 = str;
CHAR_STRING_ADVANCE (c, p1);
- while (p0 < p1)
+ do
{
EMIT_ONE_BYTE (*p0);
p0++;
}
+ while (p0 < p1);
}
}
else
diff --git a/src/composite.c b/src/composite.c
index 0b0602bf283..bc5644a4612 100644
--- a/src/composite.c
+++ b/src/composite.c
@@ -1115,7 +1115,7 @@ composition_compute_stop_pos (struct composition_it *cmp_it, EMACS_INT charpos,
if (! NILP (val))
{
Lisp_Object elt;
- int ridx, back, len;
+ int ridx, back, blen;
for (ridx = 0; CONSP (val); val = XCDR (val), ridx++)
{
@@ -1132,17 +1132,17 @@ composition_compute_stop_pos (struct composition_it *cmp_it, EMACS_INT charpos,
bpos = (NILP (string) ? CHAR_TO_BYTE (cpos)
: string_char_to_byte (string, cpos));
if (STRINGP (AREF (elt, 0)))
- len = fast_looking_at (AREF (elt, 0), cpos, bpos,
- start + 1, limit, string);
+ blen = fast_looking_at (AREF (elt, 0), cpos, bpos,
+ start + 1, limit, string);
else
- len = 1;
- if (len > 0)
+ blen = 1;
+ if (blen > 0)
{
/* Make CPOS point to the last character of
- match. Note that LEN is byte-length. */
- if (len > 1)
+ match. Note that BLEN is byte-length. */
+ if (blen > 1)
{
- bpos += len;
+ bpos += blen;
if (NILP (string))
cpos = BYTE_TO_CHAR (bpos) - 1;
else
@@ -1248,8 +1248,8 @@ composition_reseat_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_I
else if (w)
{
Lisp_Object lgstring = Qnil;
- Lisp_Object val, elt, re;
- int len, i;
+ Lisp_Object val, elt;
+ int i;
val = CHAR_TABLE_REF (Vcomposition_function_table, cmp_it->ch);
for (i = 0; i < cmp_it->rule_idx; i++, val = XCDR (val));
@@ -1364,7 +1364,7 @@ composition_reseat_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_I
int
composition_update_it (struct composition_it *cmp_it, EMACS_INT charpos, EMACS_INT bytepos, Lisp_Object string)
{
- int i, c;
+ int i, c IF_LINT (= 0);
if (cmp_it->ch < 0)
{
@@ -1489,9 +1489,14 @@ find_automatic_composition (EMACS_INT pos, EMACS_INT limit, EMACS_INT *start, EM
EMACS_INT head, tail, stop;
/* Limit to check a composition after POS. */
EMACS_INT fore_check_limit;
- struct position_record orig, cur, check, prev;
+ struct position_record orig, cur;
+
+ /* FIXME: It's not obvious whether these two variables need initialization.
+ If they do, please supply initial values.
+ If not, please remove this comment. */
+ struct position_record check IF_LINT (= {0}), prev IF_LINT (= {0});
+
Lisp_Object check_val, val, elt;
- int check_lookback;
int c;
Lisp_Object window;
struct window *w;
@@ -1657,7 +1662,7 @@ find_automatic_composition (EMACS_INT pos, EMACS_INT limit, EMACS_INT *start, EM
EMACS_INT
composition_adjust_point (EMACS_INT last_pt, EMACS_INT new_pt)
{
- EMACS_INT charpos, bytepos, startpos, beg, end, pos;
+ EMACS_INT beg, end;
Lisp_Object val;
int i;
@@ -2032,4 +2037,3 @@ See also the documentation of `auto-composition-mode'. */);
defsubr (&Sfind_composition_internal);
defsubr (&Scomposition_get_gstring);
}
-
diff --git a/src/deps.mk b/src/deps.mk
index 35754dfa7de..d84e80dca44 100644
--- a/src/deps.mk
+++ b/src/deps.mk
@@ -65,7 +65,7 @@ coding.o: coding.c coding.h ccl.h buffer.h character.h charset.h composite.h \
window.h dispextern.h msdos.h frame.h termhooks.h \
lisp.h globals.h $(config_h)
cm.o: cm.c frame.h cm.h termhooks.h termchar.h dispextern.h msdos.h \
- lisp.h globals.h $(config_h)
+ tparam.h lisp.h globals.h $(config_h)
cmds.o: cmds.c syntax.h buffer.h character.h commands.h window.h lisp.h \
globals.h $(config_h) msdos.h dispextern.h keyboard.h keymap.h systime.h \
coding.h frame.h composite.h
@@ -196,7 +196,7 @@ termcap.o: termcap.c lisp.h tparam.h msdos.h $(config_h)
terminal.o: terminal.c frame.h termchar.h termhooks.h charset.h coding.h \
keyboard.h lisp.h globals.h $(config_h) dispextern.h composite.h systime.h \
msdos.h
-terminfo.o: terminfo.c lisp.h globals.h $(config_h)
+terminfo.o: terminfo.c tparam.h lisp.h globals.h $(config_h)
tparam.o: tparam.c tparam.h lisp.h $(config_h)
undo.o: undo.c buffer.h commands.h window.h dispextern.h msdos.h \
lisp.h globals.h $(config_h)
diff --git a/src/emacs.c b/src/emacs.c
index 052f22ea622..bc7c07a9326 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -2312,6 +2312,7 @@ from the parent process and its tty file descriptors. */)
(void)
{
int nfd;
+ int err = 0;
if (!IS_DAEMON)
error ("This function can only be called if emacs is run as a daemon");
@@ -2324,10 +2325,11 @@ from the parent process and its tty file descriptors. */)
/* Get rid of stdin, stdout and stderr. */
nfd = open ("/dev/null", O_RDWR);
- dup2 (nfd, 0);
- dup2 (nfd, 1);
- dup2 (nfd, 2);
- close (nfd);
+ err |= nfd < 0;
+ err |= dup2 (nfd, 0) < 0;
+ err |= dup2 (nfd, 1) < 0;
+ err |= dup2 (nfd, 2) < 0;
+ err |= close (nfd) != 0;
/* Closing the pipe will notify the parent that it can exit.
FIXME: In case some other process inherited the pipe, closing it here
@@ -2336,10 +2338,13 @@ from the parent process and its tty file descriptors. */)
Instead, we should probably close the pipe in start-process and
call-process to make sure the pipe is never inherited by
subprocesses. */
- write (daemon_pipe[1], "\n", 1);
- close (daemon_pipe[1]);
+ err |= write (daemon_pipe[1], "\n", 1) < 0;
+ err |= close (daemon_pipe[1]) != 0;
/* Set it to an invalid value so we know we've already run this function. */
daemon_pipe[1] = -1;
+
+ if (err)
+ error ("I/O error during daemon initialization");
return Qt;
}
diff --git a/src/fileio.c b/src/fileio.c
index 5d33fb93878..7d2f10d517c 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -1951,9 +1951,10 @@ on the system, we copy the SELinux context of FILE to NEWNAME. */)
owner and group. */
if (input_file_statable_p)
{
- if (! NILP (preserve_uid_gid))
- fchown (ofd, st.st_uid, st.st_gid);
- fchmod (ofd, st.st_mode & 07777);
+ if (!NILP (preserve_uid_gid) && fchown (ofd, st.st_uid, st.st_gid) != 0)
+ report_file_error ("Doing chown", Fcons (newname, Qnil));
+ if (fchmod (ofd, st.st_mode & 07777) != 0)
+ report_file_error ("Doing chmod", Fcons (newname, Qnil));
}
#endif /* not MSDOS */
diff --git a/src/frame.c b/src/frame.c
index 05938f3e1f0..3e00e1bf107 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -2529,7 +2529,7 @@ use is not recommended. Explicitly check for a frame-parameter instead. */)
}
/* Now process them in reverse of specified order. */
- for (i--; i >= 0; i--)
+ while (--i >= 0)
{
prop = parms[i];
val = values[i];
@@ -3713,8 +3713,7 @@ validate_x_resource_name (void)
return;
/* If name is entirely invalid, or nearly so, use `emacs'. */
- if (good_count == 0
- || (good_count == 1 && bad_count > 0))
+ if (good_count < 2)
{
Vx_resource_name = build_string ("emacs");
return;
diff --git a/src/ftfont.c b/src/ftfont.c
index db6b29421dc..ad01149106e 100644
--- a/src/ftfont.c
+++ b/src/ftfont.c
@@ -168,11 +168,11 @@ get_adstyle_property (FcPattern *p)
for (end = str; *end && *end != ' '; end++);
if (*end)
{
- char *p = alloca (end - str + 1);
- memcpy (p, str, end - str);
- p[end - str] = '\0';
- end = p + (end - str);
- str = p;
+ char *newstr = alloca (end - str + 1);
+ memcpy (newstr, str, end - str);
+ newstr[end - str] = '\0';
+ end = newstr + (end - str);
+ str = newstr;
}
if (xstrcasecmp (str, "Regular") == 0
|| xstrcasecmp (str, "Bold") == 0
@@ -190,18 +190,18 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra)
{
Lisp_Object key, cache, entity;
char *file, *str;
- int index;
+ int idx;
int numeric;
double dbl;
FcBool b;
if (FcPatternGetString (p, FC_FILE, 0, (FcChar8 **) &file) != FcResultMatch)
return Qnil;
- if (FcPatternGetInteger (p, FC_INDEX, 0, &index) != FcResultMatch)
+ if (FcPatternGetInteger (p, FC_INDEX, 0, &idx) != FcResultMatch)
return Qnil;
key = Fcons (make_unibyte_string ((char *) file, strlen ((char *) file)),
- make_number (index));
+ make_number (idx));
cache = ftfont_lookup_cache (key, FTFONT_CACHE_FOR_ENTITY);
entity = XCAR (cache);
if (! NILP (entity))
@@ -265,7 +265,7 @@ ftfont_pattern_entity (FcPattern *p, Lisp_Object extra)
ASET (entity, FONT_ADSTYLE_INDEX, get_adstyle_property (p));
if ((ft_library || FT_Init_FreeType (&ft_library) == 0)
- && FT_New_Face (ft_library, file, index, &ft_face) == 0)
+ && FT_New_Face (ft_library, file, idx, &ft_face) == 0)
{
BDF_PropertyRec rec;
@@ -311,8 +311,9 @@ ftfont_resolve_generic_family (Lisp_Object family, FcPattern *pattern)
if (FcPatternGetLangSet (pattern, FC_LANG, 0, &langset) != FcResultMatch)
{
/* This is to avoid the effect of locale. */
+ static const FcChar8 lang[] = "en";
langset = FcLangSetCreate ();
- FcLangSetAdd (langset, "en");
+ FcLangSetAdd (langset, lang);
FcPatternAddLangSet (pattern, FC_LANG, langset);
FcLangSetDestroy (langset);
}
@@ -393,14 +394,14 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for)
? ! cache_data->ft_face : ! cache_data->fc_charset)
{
char *filename = SSDATA (XCAR (key));
- int index = XINT (XCDR (key));
+ int idx = XINT (XCDR (key));
if (cache_for == FTFONT_CACHE_FOR_FACE)
{
if (! ft_library
&& FT_Init_FreeType (&ft_library) != 0)
return Qnil;
- if (FT_New_Face (ft_library, filename, index, &cache_data->ft_face)
+ if (FT_New_Face (ft_library, filename, idx, &cache_data->ft_face)
!= 0)
return Qnil;
}
@@ -412,7 +413,7 @@ ftfont_lookup_cache (Lisp_Object key, enum ftfont_cache_for cache_for)
FcCharSet *charset = NULL;
pat = FcPatternBuild (0, FC_FILE, FcTypeString, (FcChar8 *) filename,
- FC_INDEX, FcTypeInteger, index, NULL);
+ FC_INDEX, FcTypeInteger, idx, NULL);
if (! pat)
goto finish;
objset = FcObjectSetBuild (FC_CHARSET, FC_STYLE, NULL);
@@ -490,8 +491,12 @@ static int ftfont_get_bitmap (struct font *, unsigned,
struct font_bitmap *, int);
static int ftfont_anchor_point (struct font *, unsigned, int,
int *, int *);
+#ifdef HAVE_LIBOTF
static Lisp_Object ftfont_otf_capability (struct font *);
+# ifdef HAVE_M17N_FLT
static Lisp_Object ftfont_shape (Lisp_Object);
+# endif
+#endif
#ifdef HAVE_OTF_GET_VARIATION_GLYPHS
static int ftfont_variation_glyphs (struct font *, int c,
@@ -618,6 +623,7 @@ struct OpenTypeSpec
(P)[4] = '\0'; \
} while (0)
+#ifdef HAVE_LIBOTF
#define OTF_TAG_SYM(SYM, TAG) \
do { \
char str[5]; \
@@ -625,6 +631,7 @@ struct OpenTypeSpec
OTF_TAG_STR (TAG, str); \
(SYM) = font_intern_prop (str, 4, 1); \
} while (0)
+#endif
static struct OpenTypeSpec *
@@ -864,7 +871,6 @@ ftfont_list (Lisp_Object frame, Lisp_Object spec)
FcObjectSet *objset = NULL;
FcCharSet *charset;
Lisp_Object chars = Qnil;
- FcResult result;
char otlayout[15]; /* For "otlayout:XXXX" */
struct OpenTypeSpec *otspec = NULL;
int spacing = -1;
@@ -1153,7 +1159,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
FT_Face ft_face;
FT_Size ft_size;
FT_UInt size;
- Lisp_Object val, filename, index, cache, font_object;
+ Lisp_Object val, filename, idx, cache, font_object;
int scalable;
int spacing;
char name[256];
@@ -1168,7 +1174,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
if (NILP (cache))
return Qnil;
filename = XCAR (val);
- index = XCDR (val);
+ idx = XCDR (val);
val = XCDR (cache);
cache_data = XSAVE_VALUE (XCDR (cache))->pointer;
ft_face = cache_data->ft_face;
@@ -1210,7 +1216,7 @@ ftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
font = XFONT_OBJECT (font_object);
ftfont_info = (struct ftfont_info *) font;
ftfont_info->ft_size = ft_face->size;
- ftfont_info->index = XINT (index);
+ ftfont_info->index = XINT (idx);
#ifdef HAVE_LIBOTF
ftfont_info->maybe_otf = ft_face->face_flags & FT_FACE_FLAG_SFNT;
ftfont_info->otf = NULL;
@@ -1455,7 +1461,8 @@ ftfont_get_bitmap (struct font *font, unsigned int code, struct font_bitmap *bit
}
static int
-ftfont_anchor_point (struct font *font, unsigned int code, int index, int *x, int *y)
+ftfont_anchor_point (struct font *font, unsigned int code, int idx,
+ int *x, int *y)
{
struct ftfont_info *ftfont_info = (struct ftfont_info *) font;
FT_Face ft_face = ftfont_info->ft_size->face;
@@ -1466,10 +1473,10 @@ ftfont_anchor_point (struct font *font, unsigned int code, int index, int *x, in
return -1;
if (ft_face->glyph->format != FT_GLYPH_FORMAT_OUTLINE)
return -1;
- if (index >= ft_face->glyph->outline.n_points)
+ if (idx >= ft_face->glyph->outline.n_points)
return -1;
- *x = ft_face->glyph->outline.points[index].x;
- *y = ft_face->glyph->outline.points[index].y;
+ *x = ft_face->glyph->outline.points[idx].x;
+ *y = ft_face->glyph->outline.points[idx].y;
return 0;
}
diff --git a/src/intervals.c b/src/intervals.c
index 12b2789cc77..351677ad27e 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -586,7 +586,7 @@ split_interval_left (INTERVAL interval, EMACS_INT offset)
Don't use this function on an interval which is the child
of another interval! */
-int
+static int
interval_start_pos (INTERVAL source)
{
Lisp_Object parent;
@@ -2559,4 +2559,3 @@ set_intervals_multibyte (int multi_flag)
set_intervals_multibyte_1 (BUF_INTERVALS (current_buffer), multi_flag,
BEG, BEG_BYTE, Z, Z_BYTE);
}
-
diff --git a/src/intervals.h b/src/intervals.h
index f6c1c002ce0..d7c34012e1f 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -161,8 +161,13 @@ struct interval
(INTERVAL_HAS_PARENT (i) ? INTERVAL_PARENT (i) : 0)
/* Abort if interval I's size is negative. */
-#define CHECK_TOTAL_LENGTH(i) \
- if ((int) (i)->total_length < 0) abort (); else
+#define CHECK_TOTAL_LENGTH(i) \
+ do \
+ { \
+ if ((int) (i)->total_length < 0) \
+ abort (); \
+ } \
+ while (0)
/* Reset this interval to its vanilla, or no-property state. */
#define RESET_INTERVAL(i) \
@@ -339,4 +344,3 @@ extern Lisp_Object get_pos_property (Lisp_Object pos, Lisp_Object prop,
extern void syms_of_textprop (void);
#include "composite.h"
-
diff --git a/src/lisp.h b/src/lisp.h
index 283b0989c1d..e98172ec104 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3233,7 +3233,11 @@ extern void syms_of_process (void);
extern void setup_process_coding_systems (Lisp_Object);
EXFUN (Fcall_process, MANY);
-extern int child_setup (int, int, int, char **, int, Lisp_Object);
+extern int child_setup (int, int, int, char **, int, Lisp_Object)
+#ifndef DOS_NT
+ NO_RETURN
+#endif
+ ;
extern void init_callproc_1 (void);
extern void init_callproc (void);
extern void set_initial_environment (void);
@@ -3598,7 +3602,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
else \
{ \
buf = (type) xmalloc (size); \
- sa_must_free++; \
+ sa_must_free = 1; \
record_unwind_protect (safe_alloca_unwind, \
make_save_value (buf, 0)); \
} \
@@ -3628,7 +3632,7 @@ extern Lisp_Object safe_alloca_unwind (Lisp_Object);
buf = (Lisp_Object *) xmalloc (size_); \
arg_ = make_save_value (buf, nelt); \
XSAVE_VALUE (arg_)->dogc = 1; \
- sa_must_free++; \
+ sa_must_free = 1; \
record_unwind_protect (safe_alloca_unwind, arg_); \
} \
} while (0)
diff --git a/src/process.c b/src/process.c
index c9b420ab2ae..4a7202388bf 100644
--- a/src/process.c
+++ b/src/process.c
@@ -159,9 +159,6 @@ extern Lisp_Object QCfilter;
#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial))
#define SERIALCONN1_P(p) (EQ ((p)->type, Qserial))
-/* Define first descriptor number available for subprocesses. */
-#define FIRST_PROC_DESC 3
-
#ifndef HAVE_H_ERRNO
extern int h_errno;
#endif
@@ -278,10 +275,6 @@ static SELECT_TYPE connect_wait_mask;
/* Number of bits set in connect_wait_mask. */
static int num_pending_connects;
-
-#define IF_NON_BLOCKING_CONNECT(s) s
-#else /* NON_BLOCKING_CONNECT */
-#define IF_NON_BLOCKING_CONNECT(s)
#endif /* NON_BLOCKING_CONNECT */
/* The largest descriptor currently in use for a process object. */
@@ -1250,8 +1243,8 @@ Returns nil if format of ADDRESS is invalid. */)
static Lisp_Object
list_processes_1 (Lisp_Object query_only)
{
- register Lisp_Object tail, tem;
- Lisp_Object proc, minspace, tem1;
+ register Lisp_Object tail;
+ Lisp_Object proc, minspace;
register struct Lisp_Process *p;
char tembuf[300];
int w_proc, w_buffer, w_tty;
@@ -1453,10 +1446,10 @@ list_processes_1 (Lisp_Object query_only)
}
else
{
- tem = p->command;
+ Lisp_Object tem = p->command;
while (1)
{
- tem1 = Fcar (tem);
+ Lisp_Object tem1 = Fcar (tem);
if (NILP (tem1))
break;
Finsert (1, &tem1);
@@ -1919,8 +1912,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
/* child_setup must clobber environ on systems with true vfork.
Protect it from permanent change. */
char **save_environ = environ;
-
- current_dir = ENCODE_FILE (current_dir);
+ volatile Lisp_Object encoded_current_dir = ENCODE_FILE (current_dir);
#ifndef WINDOWSNT
pid = vfork ();
@@ -2061,13 +2053,13 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
child_setup_tty (xforkout);
#ifdef WINDOWSNT
pid = child_setup (xforkin, xforkout, xforkout,
- new_argv, 1, current_dir);
+ new_argv, 1, encoded_current_dir);
#else /* not WINDOWSNT */
#ifdef FD_CLOEXEC
emacs_close (wait_child_setup[0]);
#endif
child_setup (xforkin, xforkout, xforkout,
- new_argv, 1, current_dir);
+ new_argv, 1, encoded_current_dir);
#endif /* not WINDOWSNT */
}
environ = save_environ;
@@ -3403,7 +3395,9 @@ usage: (make-network-process &rest ARGS) */)
{
int optn, optbits;
+#ifdef WINDOWSNT
retry_connect:
+#endif
s = socket (lres->ai_family, lres->ai_socktype, lres->ai_protocol);
if (s < 0)
@@ -3467,7 +3461,7 @@ usage: (make-network-process &rest ARGS) */)
if (EQ (service, Qt))
{
struct sockaddr_in sa1;
- int len1 = sizeof (sa1);
+ socklen_t len1 = sizeof (sa1);
if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
{
((struct sockaddr_in *)(lres->ai_addr))->sin_port = sa1.sin_port;
@@ -3514,7 +3508,8 @@ usage: (make-network-process &rest ARGS) */)
/* Unlike most other syscalls connect() cannot be called
again. (That would return EALREADY.) The proper way to
wait for completion is select(). */
- int sc, len;
+ int sc;
+ socklen_t len;
SELECT_TYPE fdset;
retry_select:
FD_ZERO (&fdset);
@@ -3587,7 +3582,7 @@ usage: (make-network-process &rest ARGS) */)
if (!is_server)
{
struct sockaddr_in sa1;
- int len1 = sizeof (sa1);
+ socklen_t len1 = sizeof (sa1);
if (getsockname (s, (struct sockaddr *)&sa1, &len1) == 0)
contact = Fplist_put (contact, QClocal,
conv_sockaddr_to_lisp ((struct sockaddr *)&sa1, len1));
@@ -3705,10 +3700,10 @@ usage: (make-network-process &rest ARGS) */)
{
/* Setup coding systems for communicating with the network stream. */
- struct gcpro gcpro1;
+ struct gcpro inner_gcpro1;
/* Qt denotes we have not yet called Ffind_operation_coding_system. */
Lisp_Object coding_systems = Qt;
- Lisp_Object args[5], val;
+ Lisp_Object fargs[5], val;
if (!NILP (tem))
{
@@ -3731,11 +3726,11 @@ usage: (make-network-process &rest ARGS) */)
coding_systems = Qnil;
else
{
- args[0] = Qopen_network_stream, args[1] = name,
- args[2] = buffer, args[3] = host, args[4] = service;
- GCPRO1 (proc);
- coding_systems = Ffind_operation_coding_system (5, args);
- UNGCPRO;
+ fargs[0] = Qopen_network_stream, fargs[1] = name,
+ fargs[2] = buffer, fargs[3] = host, fargs[4] = service;
+ GCPRO1_VAR (proc, inner_gcpro);
+ coding_systems = Ffind_operation_coding_system (5, fargs);
+ UNGCPRO_VAR (inner_gcpro);
}
if (CONSP (coding_systems))
val = XCAR (coding_systems);
@@ -3764,11 +3759,11 @@ usage: (make-network-process &rest ARGS) */)
coding_systems = Qnil;
else
{
- args[0] = Qopen_network_stream, args[1] = name,
- args[2] = buffer, args[3] = host, args[4] = service;
- GCPRO1 (proc);
- coding_systems = Ffind_operation_coding_system (5, args);
- UNGCPRO;
+ fargs[0] = Qopen_network_stream, fargs[1] = name,
+ fargs[2] = buffer, fargs[3] = host, fargs[4] = service;
+ GCPRO1_VAR (proc, inner_gcpro);
+ coding_systems = Ffind_operation_coding_system (5, fargs);
+ UNGCPRO_VAR (inner_gcpro);
}
}
if (CONSP (coding_systems))
@@ -3948,7 +3943,7 @@ FLAGS is the current flags of the interface. */)
CHECK_STRING (ifname);
memset (rq.ifr_name, 0, sizeof rq.ifr_name);
- strncpy (rq.ifr_name, SDATA (ifname), sizeof (rq.ifr_name));
+ strncpy (rq.ifr_name, SSDATA (ifname), sizeof (rq.ifr_name));
s = socket (AF_INET, SOCK_STREAM, 0);
if (s < 0)
@@ -4192,7 +4187,7 @@ server_accept_connection (Lisp_Object server, int channel)
struct sockaddr_un un;
#endif
} saddr;
- int len = sizeof saddr;
+ socklen_t len = sizeof saddr;
s = accept (channel, &saddr.sa, &len);
@@ -4928,8 +4923,6 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
d->func (channel, d->data, 0);
}
- /* Really FIRST_PROC_DESC should be 0 on Unix,
- but this is safer in the short run. */
for (channel = 0; channel <= max_process_desc; channel++)
{
if (FD_ISSET (channel, &Available)
@@ -5059,7 +5052,7 @@ wait_reading_process_output (int time_limit, int microsecs, int read_kbd,
/* getsockopt(,,SO_ERROR,,) is said to hang on some systems.
So only use it on systems where it is known to work. */
{
- int xlen = sizeof (xerrno);
+ socklen_t xlen = sizeof (xerrno);
if (getsockopt (channel, SOL_SOCKET, SO_ERROR, &xerrno, &xlen))
xerrno = errno;
}
@@ -5128,9 +5121,9 @@ read_process_output_call (Lisp_Object fun_and_args)
}
static Lisp_Object
-read_process_output_error_handler (Lisp_Object error)
+read_process_output_error_handler (Lisp_Object error_val)
{
- cmd_error_internal (error, "error in process filter: ");
+ cmd_error_internal (error_val, "error in process filter: ");
Vinhibit_quit = Qt;
update_echo_area ();
Fsleep_for (make_number (2), Qnil);
@@ -5171,7 +5164,7 @@ read_process_output (Lisp_Object proc, register int channel)
/* We have a working select, so proc_buffered_char is always -1. */
if (DATAGRAM_CHAN_P (channel))
{
- int len = datagram_address[channel].len;
+ socklen_t len = datagram_address[channel].len;
nbytes = recvfrom (channel, chars + carryover, readmax,
0, datagram_address[channel].sa, &len);
}
@@ -5925,7 +5918,7 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
if (sig_char && *sig_char != CDISABLE)
{
- send_process (proc, sig_char, 1, Qnil);
+ send_process (proc, (char *) sig_char, 1, Qnil);
return;
}
/* If we can't send the signal with a character,
@@ -6534,9 +6527,9 @@ exec_sentinel_unwind (Lisp_Object data)
}
static Lisp_Object
-exec_sentinel_error_handler (Lisp_Object error)
+exec_sentinel_error_handler (Lisp_Object error_val)
{
- cmd_error_internal (error, "error in process sentinel: ");
+ cmd_error_internal (error_val, "error in process sentinel: ");
Vinhibit_quit = Qt;
update_echo_area ();
Fsleep_for (make_number (2), Qnil);
diff --git a/src/region-cache.c b/src/region-cache.c
index 1f9b62da9fa..53ce0e9d802 100644
--- a/src/region-cache.c
+++ b/src/region-cache.c
@@ -290,37 +290,37 @@ move_cache_gap (struct region_cache *c, EMACS_INT pos, EMACS_INT min_size)
}
-/* Insert a new boundary in cache C; it will have cache index INDEX,
+/* Insert a new boundary in cache C; it will have cache index I,
and have the specified POS and VALUE. */
static void
-insert_cache_boundary (struct region_cache *c, EMACS_INT index, EMACS_INT pos,
+insert_cache_boundary (struct region_cache *c, EMACS_INT i, EMACS_INT pos,
int value)
{
- /* index must be a valid cache index. */
- if (index < 0 || index > c->cache_len)
+ /* i must be a valid cache index. */
+ if (i < 0 || i > c->cache_len)
abort ();
/* We must never want to insert something before the dummy first
boundary. */
- if (index == 0)
+ if (i == 0)
abort ();
/* We must only be inserting things in order. */
- if (! (BOUNDARY_POS (c, index-1) < pos
- && (index == c->cache_len
- || pos < BOUNDARY_POS (c, index))))
+ if (! (BOUNDARY_POS (c, i - 1) < pos
+ && (i == c->cache_len
+ || pos < BOUNDARY_POS (c, i))))
abort ();
/* The value must be different from the ones around it. However, we
temporarily create boundaries that establish the same value as
the subsequent boundary, so we're not going to flag that case. */
- if (BOUNDARY_VALUE (c, index-1) == value)
+ if (BOUNDARY_VALUE (c, i - 1) == value)
abort ();
- move_cache_gap (c, index, 1);
+ move_cache_gap (c, i, 1);
- c->boundaries[index].pos = pos - c->buffer_beg;
- c->boundaries[index].value = value;
+ c->boundaries[i].pos = pos - c->buffer_beg;
+ c->boundaries[i].value = value;
c->gap_start++;
c->gap_len--;
c->cache_len++;
@@ -808,4 +808,3 @@ pp_cache (struct region_cache *c)
fprintf (stderr, "%ld : %d\n", (long)pos, BOUNDARY_VALUE (c, i));
}
}
-
diff --git a/src/region-cache.h b/src/region-cache.h
index 0da159285e4..8e4336c2885 100644
--- a/src/region-cache.h
+++ b/src/region-cache.h
@@ -111,3 +111,5 @@ extern int region_cache_backward (struct buffer *BUF,
EMACS_INT POS,
EMACS_INT *NEXT);
+/* For debugging. */
+void pp_cache (struct region_cache *);
diff --git a/src/scroll.c b/src/scroll.c
index 33af18d2090..f013ebbee0e 100644
--- a/src/scroll.c
+++ b/src/scroll.c
@@ -245,8 +245,8 @@ do_scrolling (struct frame *frame, struct glyph_matrix *current_matrix, struct m
int i, j, k;
/* Set to 1 if we have set a terminal window with
- set_terminal_window. */
- int terminal_window_p = 0;
+ set_terminal_window. It's unsigned to work around GCC bug 48228. */
+ unsigned int terminal_window_p = 0;
/* A queue for line insertions to be done. */
struct queue { int count, pos; };
diff --git a/src/sound.c b/src/sound.c
index 3a1668e4903..a2fe7ccc8ce 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -595,12 +595,12 @@ wav_play (struct sound *s, struct sound_device *sd)
files I found so far. If someone feels inclined to implement the
whole RIFF-WAVE spec, please do. */
if (STRINGP (s->data))
- sd->write (sd, SDATA (s->data) + sizeof *header,
+ sd->write (sd, SSDATA (s->data) + sizeof *header,
SBYTES (s->data) - sizeof *header);
else
{
char *buffer;
- int nbytes;
+ int nbytes = 0;
int blksize = sd->period_size ? sd->period_size (sd) : 2048;
int data_left = header->data_length;
@@ -686,7 +686,7 @@ au_play (struct sound *s, struct sound_device *sd)
sd->configure (sd);
if (STRINGP (s->data))
- sd->write (sd, SDATA (s->data) + header->data_offset,
+ sd->write (sd, SSDATA (s->data) + header->data_offset,
SBYTES (s->data) - header->data_offset);
else
{
@@ -1104,7 +1104,6 @@ alsa_close (struct sound_device *sd)
static void
alsa_choose_format (struct sound_device *sd, struct sound *s)
{
- struct alsa_params *p = (struct alsa_params *) sd->data;
if (s->type == RIFF)
{
struct wav_header *h = (struct wav_header *) s->header;
@@ -1410,7 +1409,7 @@ Internal use only, use `play-sound' instead. */)
{
int len = SCHARS (attrs[SOUND_DEVICE]);
current_sound_device->file = (char *) alloca (len + 1);
- strcpy (current_sound_device->file, SDATA (attrs[SOUND_DEVICE]));
+ strcpy (current_sound_device->file, SSDATA (attrs[SOUND_DEVICE]));
}
if (INTEGERP (attrs[SOUND_VOLUME]))
@@ -1498,4 +1497,3 @@ init_sound (void)
}
#endif /* HAVE_SOUND */
-
diff --git a/src/sysdep.c b/src/sysdep.c
index 6ef3d88c5c8..14db0fd26d0 100644
--- a/src/sysdep.c
+++ b/src/sysdep.c
@@ -488,7 +488,8 @@ sys_subshell (void)
int pid;
struct save_signal saved_handlers[5];
Lisp_Object dir;
- unsigned char * IF_LINT (volatile) str = 0;
+ unsigned char *volatile str_volatile = 0;
+ unsigned char *str;
int len;
saved_handlers[0].code = SIGINT;
@@ -512,7 +513,7 @@ sys_subshell (void)
goto xyzzy;
dir = expand_and_dir_to_file (Funhandled_file_name_directory (dir), Qnil);
- str = (unsigned char *) alloca (SCHARS (dir) + 2);
+ str_volatile = str = (unsigned char *) alloca (SCHARS (dir) + 2);
len = SCHARS (dir);
memcpy (str, SDATA (dir), len);
if (str[len - 1] != '/') str[len++] = '/';
@@ -544,6 +545,7 @@ sys_subshell (void)
sh = "sh";
/* Use our buffer's default directory for the subshell. */
+ str = str_volatile;
if (str && chdir ((char *) str) != 0)
{
#ifndef DOS_NT
diff --git a/src/terminfo.c b/src/terminfo.c
index 905a8edacc7..c0418984efa 100644
--- a/src/terminfo.c
+++ b/src/terminfo.c
@@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License
along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
+#include "tparam.h"
+
#include <setjmp.h>
#include "lisp.h"
@@ -33,18 +35,19 @@ char *UP, *BC, PC;
format is different too.
*/
+extern char *tparm (const char *str, ...);
+
+
char *
-tparam (char *string, char *outstring,
- int len, int arg1, int arg2, int arg3, int arg4,
- int arg5, int arg6, int arg7, int arg8, int arg9)
+tparam (const char *string, char *outstring, int len,
+ int arg1, int arg2, int arg3, int arg4)
{
char *temp;
- extern char *tparm (char *str, ...);
- temp = tparm (string, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
- if (outstring == 0)
- outstring = ((char *) (xmalloc ((strlen (temp)) + 1)));
- strcpy (outstring, temp);
- return outstring;
-}
+ /* Emacs always should pass a null OUTSTRING and zero LEN. */
+ if (outstring || len)
+ abort ();
+ temp = tparm (string, arg1, arg2, arg3, arg4);
+ return xstrdup (temp);
+}
diff --git a/src/textprop.c b/src/textprop.c
index 5db6033670b..cd89efeb38d 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -974,37 +974,6 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
return make_number (next->position);
}
-/* Return 1 if there's a change in some property between BEG and END. */
-
-int
-property_change_between_p (EMACS_INT beg, EMACS_INT end)
-{
- register INTERVAL i, next;
- Lisp_Object object, pos;
-
- XSETBUFFER (object, current_buffer);
- XSETFASTINT (pos, beg);
-
- i = validate_interval_range (object, &pos, &pos, soft);
- if (NULL_INTERVAL_P (i))
- return 0;
-
- next = next_interval (i);
- while (! NULL_INTERVAL_P (next) && intervals_equal (i, next))
- {
- next = next_interval (next);
- if (NULL_INTERVAL_P (next))
- return 0;
- if (next->position >= end)
- return 0;
- }
-
- if (NULL_INTERVAL_P (next))
- return 0;
-
- return 1;
-}
-
DEFUN ("next-single-property-change", Fnext_single_property_change,
Snext_single_property_change, 2, 4, 0,
doc: /* Return the position of next property change for a specific property.
@@ -2331,4 +2300,3 @@ inherits it if NONSTICKINESS is nil. The `front-sticky' and
/* defsubr (&Serase_text_properties); */
/* defsubr (&Scopy_text_properties); */
}
-
diff --git a/src/tparam.h b/src/tparam.h
index 3cd3e6053cc..dc4cdfaa28c 100644
--- a/src/tparam.h
+++ b/src/tparam.h
@@ -29,3 +29,7 @@ char *tgetstr (const char *, char **);
char *tgoto (const char *, int, int);
char *tparam (const char *, char *, int, int, int, int, int);
+
+extern char PC;
+extern char *BC;
+extern char *UP;
diff --git a/src/xdisp.c b/src/xdisp.c
index a7955f41e0c..457a5e3e11b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -802,8 +802,8 @@ static int cursor_row_fully_visible_p (struct window *, int, int);
static int try_scrolling (Lisp_Object, int, EMACS_INT, EMACS_INT, int, int);
static int try_cursor_movement (Lisp_Object, struct text_pos, int *);
static int trailing_whitespace_p (EMACS_INT);
-static int message_log_check_duplicate (EMACS_INT, EMACS_INT,
- EMACS_INT, EMACS_INT);
+static unsigned long int message_log_check_duplicate (EMACS_INT, EMACS_INT,
+ EMACS_INT, EMACS_INT);
static void push_it (struct it *);
static void pop_it (struct it *);
static void sync_frame_with_window_matrix_rows (struct window *);
@@ -7973,7 +7973,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
if (nlflag)
{
EMACS_INT this_bol, this_bol_byte, prev_bol, prev_bol_byte;
- int dups;
+ unsigned long int dups;
insert_1 ("\n", 1, 1, 0, 0);
scan_newline (Z, Z_BYTE, BEG, BEG_BYTE, -2, 0);
@@ -8001,7 +8001,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
/* If you change this format, don't forget to also
change message_log_check_duplicate. */
- sprintf (dupstr, " [%d times]", dups);
+ sprintf (dupstr, " [%lu times]", dups);
duplen = strlen (dupstr);
TEMP_SET_PT_BOTH (Z - 1, Z_BYTE - 1);
insert_1 (dupstr, duplen, 1, 0, 1);
@@ -8063,7 +8063,7 @@ message_dolog (const char *m, EMACS_INT nbytes, int nlflag, int multibyte)
Return 0 if different, 1 if the new one should just replace it, or a
value N > 1 if we should also append " [N times]". */
-static int
+static unsigned long int
message_log_check_duplicate (EMACS_INT prev_bol, EMACS_INT prev_bol_byte,
EMACS_INT this_bol, EMACS_INT this_bol_byte)
{
@@ -8085,10 +8085,9 @@ message_log_check_duplicate (EMACS_INT prev_bol, EMACS_INT prev_bol_byte,
return 2;
if (*p1++ == ' ' && *p1++ == '[')
{
- int n = 0;
- while (*p1 >= '0' && *p1 <= '9')
- n = n * 10 + *p1++ - '0';
- if (strncmp ((char *) p1, " times]\n", 8) == 0)
+ char *pend;
+ unsigned long int n = strtoul ((char *) p1, &pend, 10);
+ if (strncmp (pend, " times]\n", 8) == 0)
return n+1;
}
return 0;
@@ -19007,7 +19006,7 @@ pint2str (register char *buf, register int width, register EMACS_INT d)
static const char power_letter[] =
{
- 0, /* not used */
+ 0, /* no letter */
'k', /* kilo */
'M', /* mega */
'G', /* giga */
@@ -19089,8 +19088,7 @@ pint2hrstr (char *buf, int width, int d)
p = psuffix = buf + max (width, length);
/* Print EXPONENT. */
- if (exponent)
- *psuffix++ = power_letter[exponent];
+ *psuffix++ = power_letter[exponent];
*psuffix = '\0';
/* Print TENTHS. */
diff --git a/src/xfont.c b/src/xfont.c
index f8aace3663c..3e0fcd2cd75 100644
--- a/src/xfont.c
+++ b/src/xfont.c
@@ -629,7 +629,7 @@ xfont_list_family (Lisp_Object frame)
char **names;
int num_fonts, i;
Lisp_Object list;
- char *last_family;
+ char *last_family IF_LINT (= 0);
int last_len;
BLOCK_INPUT;
diff --git a/src/xftfont.c b/src/xftfont.c
index 695527c4236..c27a4fcf91a 100644
--- a/src/xftfont.c
+++ b/src/xftfont.c
@@ -280,7 +280,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
{
FcResult result;
Display *display = FRAME_X_DISPLAY (f);
- Lisp_Object val, filename, index, font_object;
+ Lisp_Object val, filename, idx, font_object;
FcPattern *pat = NULL, *match;
struct xftfont_info *xftfont_info = NULL;
struct font *font;
@@ -298,7 +298,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
return Qnil;
val = XCDR (val);
filename = XCAR (val);
- index = XCDR (val);
+ idx = XCDR (val);
size = XINT (AREF (entity, FONT_SIZE_INDEX));
if (size == 0)
size = pixel_size;
@@ -335,7 +335,7 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
xftfont_add_rendering_parameters (pat, entity);
FcPatternAddString (pat, FC_FILE, (FcChar8 *) SDATA (filename));
- FcPatternAddInteger (pat, FC_INDEX, XINT (index));
+ FcPatternAddInteger (pat, FC_INDEX, XINT (idx));
BLOCK_INPUT;
@@ -409,9 +409,9 @@ xftfont_open (FRAME_PTR f, Lisp_Object entity, int pixel_size)
spacing = FC_PROPORTIONAL;
if (! ascii_printable[0])
{
- int i;
- for (i = 0; i < 95; i++)
- ascii_printable[i] = ' ' + i;
+ int ch;
+ for (ch = 0; ch < 95; ch++)
+ ascii_printable[ch] = ' ' + ch;
}
BLOCK_INPUT;
if (spacing != FC_PROPORTIONAL
@@ -672,7 +672,8 @@ xftfont_draw (struct glyph_string *s, int from, int to, int x, int y, int with_b
return len;
}
-Lisp_Object
+#if defined HAVE_M17N_FLT && defined HAVE_LIBOTF
+static Lisp_Object
xftfont_shape (Lisp_Object lgstring)
{
struct font *font;
@@ -688,6 +689,7 @@ xftfont_shape (Lisp_Object lgstring)
XftUnlockFace (xftfont_info->xftfont);
return val;
}
+#endif
static int
xftfont_end_for_frame (FRAME_PTR f)
diff --git a/src/xmenu.c b/src/xmenu.c
index eab7bb03f20..60ac27a5b8f 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -922,7 +922,7 @@ set_frame_menubar (FRAME_PTR f, int first_time, int deep_p)
#endif
Lisp_Object items;
widget_value *wv, *first_wv, *prev_wv = 0;
- int i, last_i = 0;
+ EMACS_UINT i, last_i = 0;
int *submenu_start, *submenu_end;
int *submenu_top_level_items, *submenu_n_panes;
diff --git a/src/xml.c b/src/xml.c
index 12ef14e6b9f..d8e6f8c3faa 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -28,7 +28,8 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
#include "lisp.h"
#include "buffer.h"
-Lisp_Object make_dom (xmlNode *node)
+static Lisp_Object
+make_dom (xmlNode *node)
{
if (node->type == XML_ELEMENT_NODE)
{