
On Fri, Mar 02, 2007 at 11:45:04AM +0000, Mark McLoughlin wrote:
On Fri, 2007-03-02 at 11:30 +0000, Richard W.M. Jones wrote:
I'm currently trying to get libvirt to compile with -Werror. One problem which came up early is the warning in $SUBJECT. The gcc info page (see -fstrict-aliasing) is pretty unclear about what exactly causes this problem, so the attached patch rewrites the code quite conservatively to avoid the problem.
Uggh, -fstrict-aliasing is the bane of all our lives. Whoever thought it was a good idea? Wonder how much this optimisation actually gives us? Is it enough to justify all this? Grr.
(Deep breath)
Does something like this work:
struct _virDriver { const char *name; };
struct _virDomainDriver { struct _virDriver base; int no; unsigned long ver; virDrvOpen open; };
struct _virNetworkDriver { struct _virDriver base; virDrvOpen open; };
This feels kind of sick - inventing a common shared struct between the two driver tables, when there isn't any common stuff to share :-( Looking at the code, IMHO, the whole approach of iterating over the driver table soo many times is just wrong, when we can simply have an integer count recording how many drivers are registered. This eliminates both for(;;) loops, and reduces the amount of code to the point where I don't think there's anything to be gained by having a generic _virDriverRegister with all the type-casting this entails. So how about the attached patch instead.... Regards, Dan. -- |=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|