From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH for-4.6] xenstored: log tdb message via xenstored's logging mechanisms Date: Thu, 8 Jan 2015 13:10:38 +0000 Message-ID: <1420722638.19787.72.camel@citrix.com> References: <1418649503-31440-1-git-send-email-ian.campbell@citrix.com> <1420720409.19787.66.camel@citrix.com> <20150108125732.GS28680@zion.uk.xensource.com> <1420722266.19787.70.camel@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1420722266.19787.70.camel@citrix.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: Wei Liu Cc: xen-devel@lists.xen.org, ian.jackson@eu.citrix.com, Philipp Hahn List-Id: xen-devel@lists.xenproject.org On Thu, 2015-01-08 at 13:04 +0000, Ian Campbell wrote: > On Thu, 2015-01-08 at 12:57 +0000, Wei Liu wrote: > > On Thu, Jan 08, 2015 at 12:33:29PM +0000, Ian Campbell wrote: > > > ping. > > > > > > On Mon, 2014-12-15 at 13:18 +0000, Ian Campbell wrote: > > > > TDB provides us with a callback for this purpose. Use it in both > > > > xenstored and xs_tdb_dump. > > > > > > > > While at it make the existing log() macro tollerate memory failures. > > > > > > > > Signed-off-by: Ian Campbell > > > > --- > > > > tools/xenstore/xenstored_core.c | 39 +++++++++++++++++++++++++++++++++------ > > > > tools/xenstore/xs_tdb_dump.c | 12 +++++++++++- > > > > 2 files changed, 44 insertions(+), 7 deletions(-) > > > > > > > > diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c > > > > index 4eaff57..3fd9a20 100644 > > > > --- a/tools/xenstore/xenstored_core.c > > > > +++ b/tools/xenstore/xenstored_core.c > > > > @@ -89,9 +89,14 @@ static void check_store(void); > > > > #define log(...) \ > > > > do { \ > > > > char *s = talloc_asprintf(NULL, __VA_ARGS__); \ > > > > - trace("%s\n", s); \ > > > > - syslog(LOG_ERR, "%s", s); \ > > > > - talloc_free(s); \ > > > > + if (s) { \ > > > > + trace("%s\n", s); \ > > > > + syslog(LOG_ERR, "%s", s); \ > > > > + talloc_free(s); \ > > > > + } else { \ > > > > + trace("talloc failure during logging\n"); \ > > > > + syslog(LOG_ERR, "talloc failure during logging\n"); \ > > > > + } \ > > > > talloc_free can tolerate NULL pointer. > > Good point, I'll fix. Hrm, it tolerates but it does return failure (-1) instead of success in that case. Literally nowhere in our code base actually checks the return value from talloc_free, but nonetheless given that I think it would prefer to keep the talloc_free where it is and therefore only pass a valid pointer to it. Ian.