diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-01-06 20:03:25 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-01-06 20:03:25 -0800 |
commit | 07a0d613fceaf12fd7bf2f900223ac925908c76e (patch) | |
tree | 7d8ded9098d1e715af35b5cc8b6e7ea97097f543 /ffi.c | |
parent | 5983e14cf97bd1302151ffc3dbc53451acdc87e9 (diff) | |
download | txr-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 'ffi.c')
-rw-r--r-- | ffi.c | 20 |
1 files changed, 10 insertions, 10 deletions
@@ -80,7 +80,7 @@ #define alignof(type) offsetof(struct {char x; type y;}, y) #define pad_retval(size) (!(size) || convert(size_t, size) > sizeof (ffi_arg) \ - ? (size_t) (size) \ + ? convert(size_t, size) \ : sizeof (ffi_arg)) #define min(a, b) ((a) < (b) ? (a) : (b)) @@ -470,7 +470,7 @@ static mem_t *ffi_varray_alloc(struct txr_ffi_type *tft, val obj, val self) { cnum dynsize = ffi_varray_dynsize(tft, obj, self); size_t size = dynsize; - if ((cnum) size != dynsize) + if (convert(cnum, size) != dynsize) uw_throwf(error_s, lit("~a: array too large"), self, nao); return chk_calloc(size, 1); } @@ -3580,9 +3580,9 @@ static val make_ffi_type_union(val syntax, val use_existing, val self) if (biggest_size < size) biggest_size = size; } else { - if (most_align < (ucnum) mtft->align) + if (most_align < convert(ucnum, mtft->align)) most_align = mtft->align; - if (biggest_size < (ucnum) mtft->size) + if (biggest_size < convert(ucnum, mtft->size)) biggest_size = mtft->size; } } @@ -5408,7 +5408,7 @@ val carray_dup(val carray) self, carray, nao); } else { cnum elsize = scry->eltft->size; - cnum size = (ucnum) scry->nelem * (ucnum) elsize; + cnum size = convert(ucnum, scry->nelem) * convert(ucnum, elsize); mem_t *dup = chk_copy_obj(scry->data, scry->nelem * scry->eltft->size); if (size < 0 || (elsize > 0 && size / elsize != scry->nelem)) @@ -5828,7 +5828,7 @@ val carray_replace(val carray, val values, val from, val to) cnum tn = c_num(to, self); struct txr_ffi_type *eltft = scry->eltft; cnum elsize = eltft->size; - cnum size = (ucnum) ln * (ucnum) elsize; + cnum size = convert(ucnum, ln) * convert(ucnum, elsize); cnum vn = c_num(vlen, self); cnum sn; mem_t *ptr; @@ -6074,7 +6074,7 @@ val uint_carray(val carray) val self = lit("uint-carray"); struct carray *scry = carray_struct_checked(self, carray); struct txr_ffi_type *etft = scry->eltft; - ucnum size = (ucnum) etft->size * (ucnum) scry->nelem; + ucnum size = convert(ucnum, etft->size) * convert(ucnum, scry->nelem); val ubn = make_bignum(); mp_err mpe = mp_read_unsigned_bin(mp(ubn), scry->data, size); if (mpe != MP_OKAY) @@ -6087,7 +6087,7 @@ val int_carray(val carray) val self = lit("int-carray"); struct carray *scry = carray_struct_checked(self, carray); struct txr_ffi_type *etft = scry->eltft; - ucnum size = (ucnum) etft->size * (ucnum) scry->nelem; + ucnum size = convert(ucnum, etft->size) * convert(ucnum, scry->nelem); ucnum bits = size * 8; val ubn = make_bignum(); mp_err mpe = mp_read_unsigned_bin(mp(ubn), scry->data, size); @@ -6101,7 +6101,7 @@ val put_carray(val carray, val offs, val stream) val self = lit("put-carray"); struct carray *scry = carray_struct_checked(self, carray); struct txr_ffi_type *etft = scry->eltft; - ucnum size = (ucnum) etft->size * (ucnum) scry->nelem; + ucnum size = convert(ucnum, etft->size) * convert(ucnum, scry->nelem); val buf = make_borrowed_buf(unum(size), scry->data); val pos = default_arg(offs, zero); val ret = put_buf(buf, pos, stream); @@ -6114,7 +6114,7 @@ val fill_carray(val carray, val offs, val stream) val self = lit("fill-carray"); struct carray *scry = carray_struct_checked(self, carray); struct txr_ffi_type *etft = scry->eltft; - ucnum size = (ucnum) etft->size * (ucnum) scry->nelem; + ucnum size = convert(ucnum, etft->size) * convert(ucnum, scry->nelem); val buf = make_borrowed_buf(unum(size), scry->data); val pos = default_arg(offs, zero); val ret = fill_buf(buf, pos, stream); |