From patchwork Thu Jan 14 20:13:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Cooper X-Patchwork-Id: 8035321 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0A4EC9F1C0 for ; Thu, 14 Jan 2016 20:16:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 217D1204E2 for ; Thu, 14 Jan 2016 20:16:32 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 426DD204DE for ; Thu, 14 Jan 2016 20:16:31 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJoHM-0002WF-6Z; Thu, 14 Jan 2016 20:13:56 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aJoHK-0002W7-DP for xen-devel@lists.xen.org; Thu, 14 Jan 2016 20:13:54 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id B1/17-10715-18108965; Thu, 14 Jan 2016 20:13:53 +0000 X-Env-Sender: prvs=8143030eb=Andrew.Cooper3@citrix.com X-Msg-Ref: server-14.tower-27.messagelabs.com!1452802431!16904872!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 57013 invoked from network); 14 Jan 2016 20:13:53 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-14.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 14 Jan 2016 20:13:53 -0000 X-IronPort-AV: E=Sophos;i="5.22,296,1449532800"; d="scan'208";a="331510296" From: Andrew Cooper To: Xen-devel Date: Thu, 14 Jan 2016 20:13:45 +0000 Message-ID: <1452802425-32603-1-git-send-email-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.1.4 MIME-Version: 1.0 X-DLP: MIA2 Cc: Andrew Cooper , Ian Jackson , Ian Campbell , Wei Liu Subject: [Xen-devel] [PATCH] tools/toollog: Drop XTL_NEW_LOGGER() X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP XTL_NEW_LOGGER() makes a number of unreasonable assumptions about the symbols visible in its scope, and as such is only usable by its sole caller. Remove it. Signed-off-by: Andrew Cooper Acked-by: Wei Liu --- CC: Ian Campbell CC: Ian Jackson CC: Wei Liu --- tools/libs/toollog/include/xentoollog.h | 21 --------------------- tools/libs/toollog/xtl_logger_stdio.c | 30 ++++++++++++++++++------------ 2 files changed, 18 insertions(+), 33 deletions(-) diff --git a/tools/libs/toollog/include/xentoollog.h b/tools/libs/toollog/include/xentoollog.h index 853e9c7..2b5bfcb 100644 --- a/tools/libs/toollog/include/xentoollog.h +++ b/tools/libs/toollog/include/xentoollog.h @@ -112,25 +112,4 @@ void xtl_progress(struct xentoollog_logger *logger, const char *xtl_level_to_string(xentoollog_level); /* never fails */ - -#define XTL_NEW_LOGGER(LOGGER,buffer) ({ \ - xentoollog_logger_##LOGGER *new_consumer; \ - \ - (buffer).vtable.vmessage = LOGGER##_vmessage; \ - (buffer).vtable.progress = LOGGER##_progress; \ - (buffer).vtable.destroy = LOGGER##_destroy; \ - \ - new_consumer = malloc(sizeof(*new_consumer)); \ - if (!new_consumer) { \ - xtl_log((xentoollog_logger*)&buffer, \ - XTL_CRITICAL, errno, "xtl", \ - "failed to allocate memory for new message logger"); \ - } else { \ - *new_consumer = buffer; \ - } \ - \ - new_consumer; \ -}); - - #endif /* XENTOOLLOG_H */ diff --git a/tools/libs/toollog/xtl_logger_stdio.c b/tools/libs/toollog/xtl_logger_stdio.c index 0cd9206..8bce1a7 100644 --- a/tools/libs/toollog/xtl_logger_stdio.c +++ b/tools/libs/toollog/xtl_logger_stdio.c @@ -165,28 +165,34 @@ void xtl_stdiostream_adjust_flags(xentoollog_logger_stdiostream *lg, xentoollog_logger_stdiostream *xtl_createlogger_stdiostream (FILE *f, xentoollog_level min_level, unsigned flags) { - xentoollog_logger_stdiostream newlogger; - newlogger.f = f; - newlogger.min_level = min_level; - newlogger.flags = flags; + xentoollog_logger_stdiostream *nl = + calloc(sizeof(xentoollog_logger_stdiostream), 1); + + if (!nl) + return NULL; + + nl->vtable.vmessage = stdiostream_vmessage; + nl->vtable.progress = stdiostream_progress; + nl->vtable.destroy = stdiostream_destroy; + + nl->f = f; + nl->min_level = min_level; + nl->flags = flags; switch (flags & (XTL_STDIOSTREAM_PROGRESS_USE_CR | XTL_STDIOSTREAM_PROGRESS_NO_CR)) { - case XTL_STDIOSTREAM_PROGRESS_USE_CR: newlogger.progress_use_cr = 1; break; - case XTL_STDIOSTREAM_PROGRESS_NO_CR: newlogger.progress_use_cr = 0; break; + case XTL_STDIOSTREAM_PROGRESS_USE_CR: nl->progress_use_cr = 1; break; + case XTL_STDIOSTREAM_PROGRESS_NO_CR: nl->progress_use_cr = 0; break; case 0: - newlogger.progress_use_cr = isatty(fileno(newlogger.f)) > 0; + nl->progress_use_cr = isatty(fileno(nl->f)) > 0; break; default: errno = EINVAL; return 0; } - if (newlogger.flags & XTL_STDIOSTREAM_SHOW_DATE) tzset(); - - newlogger.progress_erase_len = 0; - newlogger.progress_last_percent = 0; + if (nl->flags & XTL_STDIOSTREAM_SHOW_DATE) tzset(); - return XTL_NEW_LOGGER(stdiostream, newlogger); + return nl; }