Patch to remove useless casts from the ERTS emulator

Jesper Louis Andersen <>
Tue Feb 1 23:22:00 CET 2011


This patch,

git fetch git://github.com/jlouis/otp.git cocci-useless-cast

serves two purposes. First, it removes all useless casts from the C
code of the ERTS emulator. A useless cast is a cast of an expression
that already has the type casted into. Second, it is an attempt to use
Coccinelle, http://coccinelle.lip6.fr/ on the Erlang C source. While
this is a simple Coccinelle-patch it is highly useful for doing
transformations in-the-large on the code base as a whole. The semantic
patch used is a mere 7 lines, but the patch in the branch is 120
changes.

I have run the test suite for the emulator part only and it passes
that. The caveat, however, is that I can only run a single platform
here. Thus, I hope for an inclusion into 'pu' for some more cooking. I
am also aware you may refrain from taking this patch as it is too
invasive. On the other hand, useless casts are potentially dangerous
if the type of the value is changed later as the cast then masks the
type error that would have otherwise occurred.

-- 
J.


More information about the erlang-patches mailing list