This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use saturated arithmetic for overflow detection.


On Wed, Oct 30, 2013 at 11:44:18AM -0700, Paul Eggert wrote:
> 
> All in all it's not clear that this approach is an improvement
> overall, as the performance penalty may not be worth the increase in
> clarity, and both approaches seem about equally error-prone.

This approach is less error prone as conversion can be carried out
automatically. I attached script simple that uses coccinelle to rewrite
expressions inside malloc to saturating ones which is valid
transformation.

One can run this and then sieve through modifications that are
uninteresting like
malloc (strlen (x) + 1) -> malloc (ADD_S (strlen (x), 1))

Also I do not know how in coccinelle make following transformation
working.

- i = e1 + e2
+ i = ADD_S(e1, e2)
...
ADD_S (i, x)

Attachment: satmalloc
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]