[compiler-rt] r197665 - Fix -Werror compilation.

dblaikie at gmail.com dblaikie at gmail.com
Fri Dec 20 10:46:58 PST 2013


Something like that, except you can do it with templates to make it more
type safe. LLVM has "array_lengthof" in STLExtras.h for this (it can be
further improved to provide a compile-time constant with some other magic &
an outer macro).

Perhaps it would make sense for this function to take an int (&)[2] then,
to ensure type safety? (& then the lengthof would work correctly too)
On Fri Dec 20 2013 at 1:28:41 AM, Evgeniy Stepanov <
eugeni.stepanov at gmail.com> wrote:

> What's arraysize?
> If you mean a macro like sizeof(a)/sizeof(*a) - that won't work
> because sizeof(sv) in this case is the size of (int*), not the array
> itself.
>
>
> On Thu, Dec 19, 2013 at 11:39 PM, David Blaikie <dblaikie at gmail.com>
> wrote:
> >
> >
> >
> > On Thu, Dec 19, 2013 at 12:57 AM, Evgeniy Stepanov
> > <eugeni.stepanov at gmail.com> wrote:
> >>
> >> Author: eugenis
> >> Date: Thu Dec 19 02:57:24 2013
> >> New Revision: 197665
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=197665&view=rev
> >> Log:
> >> Fix -Werror compilation.
> >>
> >> It was broken in r197601.
> >>
> >> Modified:
> >>     compiler-rt/trunk/lib/dfsan/dfsan_custom.cc
> >>
> >> Modified: compiler-rt/trunk/lib/dfsan/dfsan_custom.cc
> >> URL:
> >> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/
> dfsan/dfsan_custom.cc?rev=197665&r1=197664&r2=197665&view=diff
> >>
> >> ============================================================
> ==================
> >> --- compiler-rt/trunk/lib/dfsan/dfsan_custom.cc (original)
> >> +++ compiler-rt/trunk/lib/dfsan/dfsan_custom.cc Thu Dec 19 02:57:24
> 2013
> >> @@ -796,7 +796,7 @@ __dfsw_socketpair(int domain, int type,
> >>    int ret = socketpair(domain, type, protocol, sv);
> >>    *ret_label = 0;
> >>    if (ret == 0) {
> >> -    dfsan_set_label(0, sv, sizeof(sv));
> >> +    dfsan_set_label(0, sv, sizeof(*sv) * 2);
> >
> >
> > Should you use arraysize here rather than hardcoding 2?
> >
> >>
> >>    }
> >>    return ret;
> >>  }
> >>
> >>
> >> _______________________________________________
> >> llvm-commits mailing list
> >> llvm-commits at cs.uiuc.edu
> >> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131220/a5e30663/attachment.html>


More information about the llvm-commits mailing list