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

Re: [Xen-devel] [PATCH 1/3] tools/libxc: Drop xc_cpuid_to_str()



On Mon, Jul 02, 2018 at 03:36:42PM +0200, Roger Pau Monné wrote:
> On Mon, Jul 02, 2018 at 01:15:10PM +0100, Andrew Cooper wrote:
> > On 02/07/18 11:41, Roger Pau Monné wrote:
> > > On Mon, Jul 02, 2018 at 10:57:25AM +0100, Andrew Cooper wrote:
> > >> This helper appears to have been introduced 10 years ago by c/s 
> > >> 5f14a87ceb
> > >> "x86, hvm: Guest CPUID configuration" and never had any users at all.
> > >>
> > >> alloc_str() is actually an opencoded calloc(), and now only has a single
> > >> caller.  Use calloc() directly and drop alloc_str().
> > >>
> > >> Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> > > Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> > 
> > Thanks,
> > 
> > >
> > >> @@ -832,7 +809,7 @@ int xc_cpuid_set(
> > >>              continue;
> > >>          }
> > >>          
> > >> -        config_transformed[i] = alloc_str();
> > >> +        config_transformed[i] = calloc(33, 1); /* 32 bits, NUL 
> > >> terminator. */
> > > I would rather do sizeof(*config_transformed[i]), but I'm not going to
> > > insist.
> > 
> > Without a structure of the form:
> > 
> > struct {
> >     char cfg[33];
> > };
> > 
> > not amount of sizeof trickery will work here.  Your example reduces to
> > sizeof(char), rather than 32/33.
> 
> I was thinking about using:
> 
> config_transformed[i] = calloc(33, *config_transformed[i]);

Er, rather:

config_transformed[i] = calloc(33, sizeof(*config_transformed[i]));

Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.