Re: [PATCH 2/4] parallels: fix memory allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 120926 16:33:28, Daniel P. Berrange wrote:
> On Wed, Sep 26, 2012 at 04:30:00PM +0400, Dmitry Guryanov wrote:
> > size of videos array must be increased.
> > 
> > Signed-off-by: Dmitry Guryanov <dguryanov@xxxxxxxxxxxxx>
> > ---
> >  src/parallels/parallels_driver.c |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> > 
> > diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c
> > index 20ee361..87e8cf5 100644
> > --- a/src/parallels/parallels_driver.c
> > +++ b/src/parallels/parallels_driver.c
> > @@ -277,7 +277,7 @@ parallelsAddVideoInfo(virDomainDefPtr def, virJSONValuePtr value)
> >      if (VIR_ALLOC(accel) < 0)
> >          goto no_memory;
> >  
> > -    if (VIR_REALLOC_N(def->videos, def->nvideos) < 0)
> > +    if (VIR_REALLOC_N(def->videos, def->nvideos + 1) < 0)
> >          goto no_memory;
> >  
> >      def->videos[def->nvideos++] = video;
> 
> It is actually preferrable to use VIR_EXPAND_N here, eg
> 
>      if (VIR_EXPAND_N(def->videos, def->nvideos, 1) < 0)
>          goto no_memory;
> 
>      def->videos[def->nvideos - 1] = video;
> 
> NB VIR_EXPAND_N actually changes the 'nvideos' param for you
> 

VIR_EXPAND_N expects size_t, but fields storing numbers of devices in
virDomainDef have type int, so the error occur:

parallels/parallels_driver.c:280: error: passing argument 3 of 'virExpandN' from incompatible pointer type
../src/util/memory.h:55: note: expected 'size_t *' but argument is of type 'int *'



> Daniel
> -- 
> |: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org              -o-             http://virt-manager.org :|
> |: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
> |: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]