This follows up on a thread in February. The precedence of the ternary
operator is higher than that of the comma operator, so Ben’s code was (and is)
correct. With these changes I’m casting an explicit zero to void to quiet the
compiler about unused values, and doing similar things in a couple of other
places. There remains a warning about alloca being #defined to
__builtin_alloca in config.h, because clang #defines __GNUC__. It’s unclear to
me right now what to do about this, it may be best to have HAVE_ALLOCA_H take
priority, since GNU C implementations seem to provide it too.
APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1413665290 -3600
# Sat Oct 18 21:48:10 2014 +0100
# Node ID b3824b7f5627c37e193a69108848ccbd480d6817
# Parent ba0ff364bd94973aad604c1ebf39007c47aefef1
Some changes to eliminate warnings with Apple clang version 1.7.
src/ChangeLog addition:
2014-10-18 Aidan Kehoe <kehoea(a)parhasard.net>
Some changes to eliminate warnings with Apple clang version 1.7.
* cm.c (send_string_to_tty_console):
* doprnt.c (doprnt_2):
* doprnt.c (parse_off_posnum):
* event-stream.c (dribble_out_event):
Cast various calls to Lstream_putc() to void when the result isn't
being used, for the sake of clang.
* lisp.h:
Declare #'replace here too, it's used in event-stream.c.
* lisp.h (ALLOCA):
* lisp.h (MALLOC_OR_ALLOCA):
Cast a couple of zeros in the context of the ternary operator to
void to prevent unused value warnings with clang.
* sysdep.c (child_setup_tty):
* text.h (ASSERT_ASCTEXT_ASCII_LEN):
Use DO_NOTHING in these files to quieten the compiler.
lib-src/ChangeLog addition:
2014-10-18 Aidan Kehoe <kehoea(a)parhasard.net>
* ootags.c (substitute):
Cast the result of strlen to int before comparing it with a signed
value, for the sake of compiler warnings.
diff -r ba0ff364bd94 -r b3824b7f5627 lib-src/ChangeLog
--- a/lib-src/ChangeLog Sat Oct 18 23:21:30 2014 +0900
+++ b/lib-src/ChangeLog Sat Oct 18 21:48:10 2014 +0100
@@ -1,3 +1,9 @@
+2014-10-18 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * ootags.c (substitute):
+ Cast the result of strlen to int before comparing it with a signed
+ value, for the sake of compiler warnings.
+
2013-06-23 Stephen J. Turnbull <stephen(a)xemacs.org>
* XEmacs 21.5.34 "kale" is released.
diff -r ba0ff364bd94 -r b3824b7f5627 lib-src/ootags.c
--- a/lib-src/ootags.c Sat Oct 18 23:21:30 2014 +0900
+++ b/lib-src/ootags.c Sat Oct 18 21:48:10 2014 +0100
@@ -4869,7 +4869,7 @@
*t++ = *out;
*t = '\0';
- if (DEBUG && (t > result + size || t - result != strlen (result)))
+ if (DEBUG && (t > result + size || t - result != (int) (strlen (result))))
abort ();
return result;
diff -r ba0ff364bd94 -r b3824b7f5627 src/ChangeLog
--- a/src/ChangeLog Sat Oct 18 23:21:30 2014 +0900
+++ b/src/ChangeLog Sat Oct 18 21:48:10 2014 +0100
@@ -1,3 +1,22 @@
+2014-10-18 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ Some changes to eliminate warnings with Apple clang version 1.7.
+ * cm.c (send_string_to_tty_console):
+ * doprnt.c (doprnt_2):
+ * doprnt.c (parse_off_posnum):
+ * event-stream.c (dribble_out_event):
+ Cast various calls to Lstream_putc() to void when the result isn't
+ being used, for the sake of clang.
+ * lisp.h:
+ Declare #'replace here too, it's used in event-stream.c.
+ * lisp.h (ALLOCA):
+ * lisp.h (MALLOC_OR_ALLOCA):
+ Cast a couple of zeros in the context of the ternary operator to
+ void to prevent unused value warnings with clang.
+ * sysdep.c (child_setup_tty):
+ * text.h (ASSERT_ASCTEXT_ASCII_LEN):
+ Use DO_NOTHING in these files to quieten the compiler.
+
2014-10-18 Stephen J. Turnbull <stephen(a)xemacs.org>
* fontcolor-xlike-inc.c (xft_find_charset_font):
diff -r ba0ff364bd94 -r b3824b7f5627 src/cm.c
--- a/src/cm.c Sat Oct 18 23:21:30 2014 +0900
+++ b/src/cm.c Sat Oct 18 21:48:10 2014 +0100
@@ -66,7 +66,7 @@
}
if (len == 1)
- Lstream_putc (lstr, *str);
+ (void) Lstream_putc (lstr, *str);
else if (len > 0)
Lstream_write (lstr, str, len);
}
diff -r ba0ff364bd94 -r b3824b7f5627 src/doprnt.c
--- a/src/doprnt.c Sat Oct 18 23:21:30 2014 +0900
+++ b/src/doprnt.c Sat Oct 18 21:48:10 2014 +0100
@@ -122,7 +122,7 @@
/* Padding at beginning to right-justify ... */
if (!minus_flag)
while (to_add-- > 0)
- Lstream_putc (lstr, zero_flag ? '0' : ' ');
+ (void) Lstream_putc (lstr, zero_flag ? '0' : ' ');
if (0 <= maxlen && maxlen < cclen)
len = charcount_to_bytecount (string, maxlen);
@@ -131,7 +131,7 @@
/* Padding at end to left-justify ... */
if (minus_flag)
while (to_add-- > 0)
- Lstream_putc (lstr, zero_flag ? '0' : ' ');
+ (void) Lstream_putc (lstr, zero_flag ? '0' : ' ');
}
static const Ibyte *
diff -r ba0ff364bd94 -r b3824b7f5627 src/event-stream.c
--- a/src/event-stream.c Sat Oct 18 23:21:30 2014 +0900
+++ b/src/event-stream.c Sat Oct 18 21:48:10 2014 +0100
@@ -4826,9 +4826,9 @@
/* one-char key events are printed with just the key name */
Fprinc (keysym, Vdribble_file);
else if (EQ (keysym, Qreturn))
- Lstream_putc (XLSTREAM (Vdribble_file), '\n');
+ (void) Lstream_putc (XLSTREAM (Vdribble_file), '\n');
else if (EQ (keysym, Qspace))
- Lstream_putc (XLSTREAM (Vdribble_file), ' ');
+ (void) Lstream_putc (XLSTREAM (Vdribble_file), ' ');
else
Fprinc (event, Vdribble_file);
}
diff -r ba0ff364bd94 -r b3824b7f5627 src/lisp.h
--- a/src/lisp.h Sat Oct 18 23:21:30 2014 +0900
+++ b/src/lisp.h Sat Oct 18 21:48:10 2014 +0100
@@ -1363,12 +1363,12 @@
alternative is to force all callers to declare a local temporary if the
expression has side effects -- something easy to forget. */
-#define ALLOCA(size) \
- (REGEX_MALLOC_CHECK (), \
- __temp_alloca_size__ = (size), \
- __temp_alloca_size__ > MAX_ALLOCA_VS_C_ALLOCA ? \
- xemacs_c_alloca (__temp_alloca_size__) : \
- (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \
+#define ALLOCA(size) \
+ (REGEX_MALLOC_CHECK (), \
+ __temp_alloca_size__ = (size), \
+ __temp_alloca_size__ > MAX_ALLOCA_VS_C_ALLOCA ? \
+ xemacs_c_alloca (__temp_alloca_size__) : \
+ (need_to_check_c_alloca ? xemacs_c_alloca (0) : (void) 0, \
alloca (__temp_alloca_size__)))
/* Version of ALLOCA() that is guaranteed to work inside of function calls
@@ -1397,12 +1397,12 @@
/* WARNING: If you use this, you must unbind_to() at the end of your
function! */
-#define MALLOC_OR_ALLOCA(size) \
- (REGEX_MALLOC_CHECK (), \
- __temp_alloca_size__ = (size), \
- __temp_alloca_size__ > MAX_ALLOCA_VS_MALLOC ? \
- xmalloc_and_record_unwind (__temp_alloca_size__) : \
- (need_to_check_c_alloca ? xemacs_c_alloca (0) : 0, \
+#define MALLOC_OR_ALLOCA(size) \
+ (REGEX_MALLOC_CHECK (), \
+ __temp_alloca_size__ = (size), \
+ __temp_alloca_size__ > MAX_ALLOCA_VS_MALLOC ? \
+ xmalloc_and_record_unwind (__temp_alloca_size__) : \
+ (need_to_check_c_alloca ? xemacs_c_alloca (0) : (void) 0, \
alloca (__temp_alloca_size__)))
/* -------------- convenience functions for memory allocation ------------- */
@@ -5770,6 +5770,7 @@
/* Defined in sequence.c */
EXFUN (Ffill, MANY);
+EXFUN (Freplace, MANY);
/* Defined in signal.c */
void init_interrupts_late (void);
diff -r ba0ff364bd94 -r b3824b7f5627 src/sysdep.c
--- a/src/sysdep.c Sat Oct 18 23:21:30 2014 +0900
+++ b/src/sysdep.c Sat Oct 18 21:48:10 2014 +0100
@@ -495,9 +495,9 @@
/* <mdiers> What to do upon failure? Just ignoring rc is probably
not acceptable, is it? */
if (cfsetispeed (&s.main, B9600) == -1)
- ; /* ignore */
+ DO_NOTHING; /* ignore */
if (cfsetospeed (&s.main, B9600) == -1)
- ; /* ignore */
+ DO_NOTHING; /* ignore */
#endif /* defined (CBAUD) */
#else /* not HAVE_TERMIO */
diff -r ba0ff364bd94 -r b3824b7f5627 src/text.h
--- a/src/text.h Sat Oct 18 23:21:30 2014 +0900
+++ b/src/text.h Sat Oct 18 21:48:10 2014 +0100
@@ -642,8 +642,8 @@
ASSERT_ASCTEXT_ASCII_LEN (aiaz2, strlen (aiaz2)); \
} while (0)
#else
-#define ASSERT_ASCTEXT_ASCII_LEN(ptr, len)
-#define ASSERT_ASCTEXT_ASCII(ptr)
+#define ASSERT_ASCTEXT_ASCII_LEN(ptr, len) DO_NOTHING
+#define ASSERT_ASCTEXT_ASCII(ptr) DO_NOTHING
#endif
/* -------------------------------------------------------------- */
--
‘Tramadol is further fed to cattle […] when working them […] (as draft
animals) so that the animals do not get tired quickly. …’
— Angewandte Chemie, Sept 2014, describing the social context of
(synthetic) tramadol having been found in Cameroon tree roots.
_______________________________________________
XEmacs-Patches mailing list
XEmacs-Patches(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-patches