summaryrefslogtreecommitdiffstats
path: root/lib.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-01-06 20:03:25 -0800
committerKaz Kylheku <kaz@kylheku.com>2022-01-06 20:03:25 -0800
commit07a0d613fceaf12fd7bf2f900223ac925908c76e (patch)
tree7d8ded9098d1e715af35b5cc8b6e7ea97097f543 /lib.c
parent5983e14cf97bd1302151ffc3dbc53451acdc87e9 (diff)
downloadtxr-07a0d613fceaf12fd7bf2f900223ac925908c76e.tar.gz
txr-07a0d613fceaf12fd7bf2f900223ac925908c76e.tar.bz2
txr-07a0d613fceaf12fd7bf2f900223ac925908c76e.zip
Casts have crept into the code not wrapped by macros.
It is against TXR coding conventions to use the C cast notation. The usage creeps into the code. To find instances of this, we must compile using GNU g++, and add -Wold-style-cast via EXTRA_FLAGS. * eval.c (prof_call): Use macro instead of cast. * ffi.c (pad_retval, ffi_varray_alloc, make_ffi_type_union, carray_dup, carray_replace, uint_carray, int_carray, put_carray, fill_carray): Likewise. * itypes.c (c_i64, c_u64): Likewise. * lib.c (cyr, chk_xalloc, spilt_str_keep, vector, cobj_register): Likewise. * linenoise.c (record_undo): Likewise. Also, drop one superfluous cast: wstrdup_fn returns wchar_t *. (flash, edit_insert, edit_insert_str): Use macro instead of cast. * mpi/mpi.c (s_mp_ispow2d): Likewise. * parser.c (lino_getch): Likewise. * rand.c (make_random_state, random_buf): Likewise. * stream.c (generic_get_line, do_parse_mode): Likewise. * struct.c (get_duplicate_supers, call_initfun_chain, call_postinitfun_chain): Likewise. * sysif.c (c_time): Likewise. * tree.c (tr_insert): Likewise.
Diffstat (limited to 'lib.c')
-rw-r--r--lib.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib.c b/lib.c
index 9cfcd286..6d75532d 100644
--- a/lib.c
+++ b/lib.c
@@ -1724,7 +1724,7 @@ val cyr(val addr, val obj)
mp_int *a = mp(addr);
if (!mp_isneg(a)) {
mp_size i, n = mp_count_bits(a);
- for (i = n - 2; i != (mp_size) -1; i--)
+ for (i = n - 2; i != convert(mp_size, -1); i--)
obj = if3(mp_bit(a, i) == MP_YES, car(obj), cdr(obj));
return obj;
}
@@ -4408,7 +4408,7 @@ mem_t *chk_xalloc(ucnum m, ucnum n, val self)
ucnum mn = m * n;
size_t size = mn;
- if ((m > 0 && mn / m != n) || (ucnum) size != mn)
+ if ((m > 0 && mn / m != n) || convert(ucnum, size) != mn)
uw_throwf(error_s, lit("~a: memory allocation size overflow"),
self, nao);
@@ -5764,7 +5764,7 @@ val split_str_keep(val str, val sep, val keep_sep)
for (;;) {
const wchar_t *psep = wcsstr(cstr, csep);
- size_t span = (psep != 0) ? (size_t) (psep - cstr) : wcslen(cstr);
+ size_t span = (psep != 0) ? convert(size_t, psep - cstr) : wcslen(cstr);
val piece = mkustring(num(span));
init_str(piece, cstr, self);
iter = list_collect(iter, piece);
@@ -8906,7 +8906,7 @@ val vector(val length, val initval)
unsigned i;
ucnum len = c_unum(length, self);
ucnum alloc_plus = len + 2;
- ucnum size = if3(alloc_plus > len, alloc_plus, (ucnum) -1);
+ ucnum size = if3(alloc_plus > len, alloc_plus, convert(ucnum, -1));
val *v = coerce(val *, chk_xalloc(size, sizeof *v, self));
val vec = make_obj();
vec->v.type = VEC;
@@ -9683,7 +9683,7 @@ val lazy_str_get_trailing_list(val lstr, val index)
struct cobj_class *cobj_register(val cls_sym)
{
- if ((size_t) (cobj_ptr - cobj_class) >= nelem(cobj_class))
+ if (convert(size_t, cobj_ptr - cobj_class) >= nelem(cobj_class))
internal_error("cobj array too small");
cobj_ptr->cls_sym = cls_sym;
return cobj_ptr++;