Discussion:
[review request] Remove "old-style" flexible array usage in ZFS.
Matthew Ahrens via illumos-zfs
2014-07-26 18:11:59 UTC
Permalink
https://reviews.csiden.org/r/63/

In dnode\_children\_t, use C99's "\[\]" idiom for declaring the
variable sized array dnc\_children at the end of the structure.
This prevents the compiler from mistakenly optimizing away
accesses beyond the array's defined size.

--matt



-------------------------------------------
illumos-zfs
Archives: https://www.listbox.com/member/archive/182191/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182191/23047029-187a0c8d
Modify Your Subscription: https://www.listbox.com/member/?member_id=23047029&id_secret=23047029-2e85923f
Powered by Listbox: http://www.listbox.com
Matthew Ahrens via illumos-zfs
2014-07-26 19:57:26 UTC
Permalink
Makes sense. I'd never heard of unnamed structs and unions before now --
must be a GCC-ism. I think we want to stick with c99 in illumos (and I'm
sure FreeBSD also wants to avoid GCC-specific language extensions since
they compile the kernel with clang). But we could accomplish the same
thing in c99 with a more verbose change. Patches welcome :-)

--matt
On a similar note, you may want to take a look at this patch we landed
https://github.com/zfsonlinux/zfs/commit/aca19e0
--
Cheers, Prakash
[1]https://reviews.csiden.org/r/63/
In dnode\_children\_t, use C99's "\[\]" idiom for declaring the
variable sized array dnc\_children at the end of the structure.
This prevents the compiler from mistakenly optimizing away
accesses beyond the array's defined size.
--matt
References
1. https://reviews.csiden.org/r/63/
_______________________________________________
developer mailing list
http://lists.open-zfs.org/mailman/listinfo/developer
-------------------------------------------
illumos-zfs
Archives: https://www.listbox.com/member/archive/182191/=now
RSS Feed: https://www.listbox.com/member/archive/rss/182191/23047029-187a0c8d
Modify Your Subscription: https://www.listbox.com/member/?member_id=23047029&id_secret=23047029-2e85923f
Powered by Listbox: http://www.listbox.com
Carson Gaspar via illumos-zfs
2014-07-26 23:47:32 UTC
Permalink
Post by Matthew Ahrens via illumos-zfs
Makes sense. I'd never heard of unnamed structs and unions before now
-- must be a GCC-ism. I think we want to stick with c99 in illumos (and
I'm sure FreeBSD also wants to avoid GCC-specific language extensions
since they compile the kernel with clang). But we could accomplish the
same thing in c99 with a more verbose change. Patches welcome :-)
They are C11, FYI. Solaris Studio has support in 12.4 beta, but still
won't handle some nested constructs that gcc does. I have no idea where
clang is...

I agree that sticking to C99 is the sensible approach.
--
Carson
Prakash Surya via illumos-zfs
2014-07-26 19:05:16 UTC
Permalink
On a similar note, you may want to take a look at this patch we landed
on the Linux port. It also deals with compiler array optimizations:

https://github.com/zfsonlinux/zfs/commit/aca19e0
--
Cheers, Prakash
[1]https://reviews.csiden.org/r/63/
In dnode\_children\_t, use C99's "\[\]" idiom for declaring the
variable sized array dnc\_children at the end of the structure.
This prevents the compiler from mistakenly optimizing away
accesses beyond the array's defined size.
--matt
References
1. https://reviews.csiden.org/r/63/
_______________________________________________
developer mailing list
http://lists.open-zfs.org/mailman/listinfo/developer
Loading...