From: Wei Liu Subject: Re: [PATCH V6 2/7] libxl_read_file_contents: add new entry to read sysfs file Date: Thu, 13 Aug 2015 10:11:07 +0100 Message-ID: <20150813091106.GJ7460@zion.uk.xensource.com> References: <1439202928-24813-1-git-send-email-cyliu@suse.com> <1439202928-24813-3-git-send-email-cyliu@suse.com> <20150811112655.GE7460@zion.uk.xensource.com> <55CB21D50200006600057EB7@relay2.provo.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <55CB21D50200006600057EB7@relay2.provo.novell.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: Chun Yan Liu Cc: Juergen Gross , wei.liu2@citrix.com, ian.campbell@citrix.com, george.dunlap@eu.citrix.com, Ian.Jackson@eu.citrix.com, xen-devel@lists.xen.org, Jim Fehlig List-Id: xen-devel@lists.xenproject.org On Tue, Aug 11, 2015 at 08:37:09PM -0600, Chun Yan Liu wrote: [...] > > > + > > > + if (rs < datalen) { > > > + if (ferror(f)) { > > > LOGE(ERROR, "failed to read %s", filename); > > > - else if (feof(f)) > > > - LOG(ERROR, "%s changed size while we were reading it", > > > - filename); > > > - else > > > + goto xe; > > > + } else if (feof(f)) { > > > + if (tolerate_shrinking_file) { > > > + datalen = rs; > > > + } else { > > > + LOG(ERROR, "%s shrunk size while we were reading it", > > > + filename); > > > + goto xe; > > > + } > > > + } else { > > > abort(); > > > - goto xe; > > > + } > > > > This is a bit bikeshedding, but you can leave "goto xe" out of two `if' > > to reduce patch size. > > I guess you mean if (ferror(f)) and if (feof(f)) ? We can't leave 'goto xe' outside, > since in if (feof(f)) && if (tolerate_shrinking_file), it's not error but an expected > result in sysfs case. > Oh, right. I missed that tolerate_shrinking_file check. Sorry for the noise. Wei.