xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Wei Liu <wei.liu2@citrix.com>,
	al1img@gmail.com, Ian Jackson <Ian.Jackson@eu.citrix.com>
Subject: [PATCH 2/3] xl/vsnd: use xcalloc to allocate memory for parser
Date: Tue, 10 Jul 2018 14:46:06 +0100	[thread overview]
Message-ID: <20180710134607.20302-3-wei.liu2@citrix.com> (raw)
In-Reply-To: <20180710134607.20302-1-wei.liu2@citrix.com>

... because it handles errors for us.

Reported-by: Coverity
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
 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@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2018-07-10 13:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-10 13:46 [PATCH 0/3] xl/libxl: fixes for vsnd Wei Liu
2018-07-10 13:46 ` [PATCH 1/3] libxl/vsnd: add missing error checks Wei Liu
2018-07-10 13:46 ` Wei Liu [this message]
2018-07-10 13:46 ` [PATCH 3/3] xl/vsnd: initialise rc in dryrun path Wei Liu
2018-07-10 13:52 ` [PATCH 0/3] xl/libxl: fixes for vsnd Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180710134607.20302-3-wei.liu2@citrix.com \
    --to=wei.liu2@citrix.com \
    --cc=Ian.Jackson@eu.citrix.com \
    --cc=al1img@gmail.com \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).