From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:43157) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBoET-0005l6-KY for qemu-devel@nongnu.org; Mon, 18 Apr 2011 09:11:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QBoES-00040g-L3 for qemu-devel@nongnu.org; Mon, 18 Apr 2011 09:11:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:20877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QBoES-00040a-70 for qemu-devel@nongnu.org; Mon, 18 Apr 2011 09:11:12 -0400 Message-ID: <4DAC38FD.8000709@redhat.com> Date: Mon, 18 Apr 2011 15:13:33 +0200 From: Kevin Wolf MIME-Version: 1.0 References: <20110411083304.GB22987@stefanha-thinkpad.localdomain> <4DA6B246.4080302@redhat.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Question about total_sectors in block/vpc.c List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Lyu Mitnick Cc: Stefan Hajnoczi , qemu-devel@nongnu.org, Christoph Hellwig Am 15.04.2011 22:40, schrieb Lyu Mitnick: > Hello Kevin, > > 2011/4/14 Kevin Wolf > > > Am 13.04.2011 22:59, schrieb Lyu Mitnick: > > Hello Stefan, > > > > I have a question about get_option_parameter(). I am wondering whether > > get_option_parameter is suitable to use instead of doing the > search by > > myself > > in the case like following: > > > > /* Read out options */ > > while (options && options->name) { > > if (!strcmp(options->name, BLOCK_OPT_SIZE)) { > > // do something > > } else if (!strcmp(options->name, BLOCK_OPT_CLUSTER_SIZE)) { > > // do something > > } > > options++; > > } > > Yes, I think it is, though you need to check whether the option has been > set in order to allow use default values. > > Kevin > > > I have no idea about the mean of "check whether the option has been set in > order to allow use default values" , would you mind to give me an > example about > it?? > > So as the example above. I am wondering whether the code should be > rewritten > as: > > /* Read out options */ > if(get_option_parameter(options, BLOCK_OPT_SIZE)) { > // do something > } > > if (get_option_parameter(options, BLOCK_OPT_CLUSTER_SIZE)) { > // do something > } get_option_parameter would never return NULL in your example. Kevin