[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [Libvir] [PATCH] libvirt.c: warning: dereferencing type-punned pointer will break strict-aliasing rules
- From: Mark McLoughlin <markmc redhat com>
- To: "Daniel P. Berrange" <berrange redhat com>
- Cc: libvir-list <libvir-list redhat com>
- Subject: Re: [Libvir] [PATCH] libvirt.c: warning: dereferencing type-punned pointer will break strict-aliasing rules
- Date: Wed, 07 Mar 2007 07:25:59 +0000
On Tue, 2007-03-06 at 22:52 +0000, Daniel P. Berrange wrote:
> This feels kind of sick - inventing a common shared struct between the
> two driver tables, when there isn't any common stuff to share :-(
Yeah. Although, as a way to share more code between domains and
networks (especially in qemud), it might make sense.
> 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.
That sounds fine.
> @@ -203,7 +166,21 @@ _virRegisterDriver(void *driver, int isN
> int
> virRegisterNetworkDriver(virNetworkDriverPtr driver)
> {
> - return _virRegisterDriver(driver, 1);
> + if (virInitialize() < 0)
> + return -1;
> +
> + if (driver == NULL) {
> + virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
> + return(-1);
> + }
> +
> + if (virNetworkDriverTabCount >= (sizeof(virNetworkDriverTab)/sizeof(virNetworkDriverPtr))) {
Just use MAX_DRIVERS?
Cheers,
Mark.
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]