From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wei Liu Subject: Re: [PATCH] tools: Refactor code in libxl/xl_cmdimpl.c Date: Mon, 20 Oct 2014 14:45:26 +0100 Message-ID: <20141020134526.GD19994@zion.uk.xensource.com> References: <1413763288-4650-1-git-send-email-alecsandra.sandulescu@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XgDHb-000799-My for xen-devel@lists.xenproject.org; Mon, 20 Oct 2014 13:45:59 +0000 Content-Disposition: inline In-Reply-To: <1413763288-4650-1-git-send-email-alecsandra.sandulescu@gmail.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Alexandra Sandulescu Cc: xen-devel@lists.xenproject.org, wei.liu2@citrix.com, ian.campbell@citrix.com List-Id: xen-devel@lists.xenproject.org On Mon, Oct 20, 2014 at 03:01:28AM +0300, Alexandra Sandulescu wrote: > This patch removes duplicate code in /tools/libxl/xl_cmdimpl.c by > adding set_device_data function. This function parses configuration > data and adds the information into libxl_device_nic struct. It is > called in both main_networkattach and parse_config_data functions > to replace duplicate code. > --- > tools/libxl/xl_cmdimpl.c | 160 +++++++++++++++++------------------------------ > 1 file changed, 57 insertions(+), 103 deletions(-) > > diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c > index 988ee28..449aa91 100644 > --- a/tools/libxl/xl_cmdimpl.c > +++ b/tools/libxl/xl_cmdimpl.c > @@ -823,6 +823,8 @@ static void parse_vcpu_affinity(libxl_domain_build_info *b_info, > } > } > > +static int set_device_data(libxl_device_nic *nic, XLU_Config **config, char *token); > + Since this function operates on libxl_device_nic, it should be named accordingly. > static void parse_config_data(const char *config_source, > const char *config_data, > int config_len, > @@ -1389,61 +1391,7 @@ static void parse_config_data(const char *config_source, > if ((p2 = strchr(p, '=')) == NULL) > break; > *p2 = '\0'; You can get rid of p2, can't you? [...] > - fprintf(stderr, "unrecognized argument `%s'\n", *argv); > - return 1; > - } > + if (set_device_data(&nic, &config, *argv)) { return 1;} Coding style. > } > > if (dryrun_only) { > -- > 1.9.1 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel