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

[Xen-devel] [PATCH 2/3] xl/vsnd: use xcalloc to allocate memory for parser



... because it handles errors for us.

Reported-by: Coverity
Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/xl/xl_parse.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 3ebf6d9023..f9147f6a5c 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -820,8 +820,8 @@ int parse_vdispl_config(libxl_device_vdispl *vdispl, char 
*token)
         split_string_into_string_list(oparg, ";", &connectors);
 
         vdispl->num_connectors = libxl_string_list_length(&connectors);
-        vdispl->connectors = calloc(vdispl->num_connectors,
-                                    sizeof(*vdispl->connectors));
+        vdispl->connectors = xcalloc(vdispl->num_connectors,
+                                     sizeof(*vdispl->connectors));
 
         for(i = 0; i < vdispl->num_connectors; i++)
         {
@@ -863,8 +863,8 @@ static int parse_vsnd_params(libxl_vsnd_params *params, 
char *token)
         split_string_into_string_list(oparg, ";", &rates);
 
         params->num_sample_rates = libxl_string_list_length(&rates);
-        params->sample_rates = calloc(params->num_sample_rates,
-                                      sizeof(*params->sample_rates));
+        params->sample_rates = xcalloc(params->num_sample_rates,
+                                       sizeof(*params->sample_rates));
 
         for (i = 0; i < params->num_sample_rates; i++) {
             params->sample_rates[i] = strtoul(rates[i], NULL, 0);
@@ -877,8 +877,8 @@ static int parse_vsnd_params(libxl_vsnd_params *params, 
char *token)
         split_string_into_string_list(oparg, ";", &formats);
 
         params->num_sample_formats = libxl_string_list_length(&formats);
-        params->sample_formats = calloc(params->num_sample_formats,
-                                        sizeof(*params->sample_formats));
+        params->sample_formats = xcalloc(params->num_sample_formats,
+                                         sizeof(*params->sample_formats));
 
         for (i = 0; i < params->num_sample_formats; i++) {
             libxl_vsnd_pcm_format format;
-- 
2.11.0


_______________________________________________
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®.