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

[Xen-changelog] [xen staging] xl/vsnd: use xcalloc to allocate memory for parser



commit 06fb99498decd36983a66acda81b56d75f3db66e
Author:     Wei Liu <wei.liu2@xxxxxxxxxx>
AuthorDate: Tue Jul 10 14:41:16 2018 +0100
Commit:     Wei Liu <wei.liu2@xxxxxxxxxx>
CommitDate: Tue Jul 10 15:17:43 2018 +0100

    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>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 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;
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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