From 07a0d613fceaf12fd7bf2f900223ac925908c76e Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Thu, 6 Jan 2022 20:03:25 -0800 Subject: 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. --- linenoise/linenoise.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'linenoise') diff --git a/linenoise/linenoise.c b/linenoise/linenoise.c index d3d6640b..badf0ae5 100644 --- a/linenoise/linenoise.c +++ b/linenoise/linenoise.c @@ -446,8 +446,10 @@ static void free_undo_stack(lino_t *l) static void record_undo(lino_t *l) { - struct lino_undo *rec = (struct lino_undo *) lino_os.alloc_fn(sizeof *rec), *iter; - wchar_t *data = (wchar_t *) lino_os.wstrdup_fn(l->data); + struct lino_undo *rec = coerce(struct lino_undo *, + lino_os.alloc_fn(sizeof *rec)); + struct lino_undo *iter; + wchar_t *data = lino_os.wstrdup_fn(l->data); int count; if (rec == 0 || data == 0) { @@ -1523,7 +1525,7 @@ static void flash(lino_t *l, int ch) wchar_t on[2] = { ch }; const wchar_t *off = L"\b \b"; - if (l->dlen >= (int) nelem (l->data) - 1) + if (l->dlen >= convert(int, nelem (l->data)) - 1) return; for (i = 0; i < 2 && !cancel; i++) { @@ -1612,7 +1614,7 @@ static void delete_sel(lino_t *l) * * On error writing to the terminal -1 is returned, otherwise 0. */ static int edit_insert(lino_t *l, wchar_t c) { - if (l->dlen < (int) nelem(l->data) - 1) { + if (l->dlen < convert(int, nelem(l->data)) - 1) { record_triv_undo(l); delete_sel(l); if (l->dpos == l->dlen) { @@ -1671,7 +1673,7 @@ static int edit_insert(lino_t *l, wchar_t c) { static int edit_insert_str(lino_t *l, const wchar_t *s, int nchar) { - if (l->dlen < (int) nelem (l->data) - nchar) { + if (l->dlen < convert(int, nelem (l->data)) - nchar) { record_undo(l); delete_sel(l); -- cgit v1.2.3