From patchwork Mon Jan 25 15:29:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Campbell X-Patchwork-Id: 8109571 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7008DBEEED for ; Mon, 25 Jan 2016 15:31:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 45FF720328 for ; Mon, 25 Jan 2016 15:31:58 +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 05B0F202E9 for ; Mon, 25 Jan 2016 15:31:57 +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 1aNj57-0007br-TV; Mon, 25 Jan 2016 15:29:29 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aNj56-0007bU-OX for xen-devel@lists.xen.org; Mon, 25 Jan 2016 15:29:28 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 9D/DC-12072-75F36A65; Mon, 25 Jan 2016 15:29:27 +0000 X-Env-Sender: prvs=825142af3=Ian.Campbell@citrix.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1453735763!17974840!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21418 invoked from network); 25 Jan 2016 15:29:24 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-14.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 25 Jan 2016 15:29:24 -0000 X-IronPort-AV: E=Sophos;i="5.22,345,1449532800"; d="scan'208";a="327471528" From: Ian Campbell To: , , Date: Mon, 25 Jan 2016 15:29:21 +0000 Message-ID: <1453735761-10823-1-git-send-email-ian.campbell@citrix.com> X-Mailer: git-send-email 2.6.1 MIME-Version: 1.0 X-DLP: MIA1 Cc: Daniel De Graaf , Ian Campbell Subject: [Xen-devel] [PATCH] tools: avoid redefinition of typedefs 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 When splitting out various functionality from libxc into tools/libs/* I attempted to make it possible to avoid callers being unnecessarily exposed to the xentoollog interface by providing a typedef of the xentoollog_logger handle in each of the headers. However such typedefs are not allowed in C, instead it is necessary to forward declare the struct and then use the struct xentoollog_logger variant in the prototypes. It appears that older gcc (e.g. 4.4) complains about this issue while newer ones (e.g. 4.9) are more tolerant unless -pedantic-errors is used, this was a deliberate change https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=ce3765bf44e49ef0568a1ad4a0b7f807591d6412 As well as tools/libs/* it is also now necessary to give libvchan the same treatment, since it previously inhereted the typedef via one of tools/libs/*. Reported-by: Boris Ostrovsky Signed-off-by: Ian Campbell Cc: Daniel De Graaf Acked-by: Ian Jackson --- tools/libs/call/include/xencall.h | 5 +++-- tools/libs/evtchn/include/xenevtchn.h | 5 +++-- tools/libs/foreignmemory/include/xenforeignmemory.h | 4 ++-- tools/libs/gnttab/include/xengnttab.h | 7 ++++--- tools/libvchan/init.c | 13 +++++++++---- tools/libvchan/libxenvchan.h | 10 ++++++++-- 6 files changed, 29 insertions(+), 15 deletions(-) diff --git a/tools/libs/call/include/xencall.h b/tools/libs/call/include/xencall.h index 559624a..bafacdd 100644 --- a/tools/libs/call/include/xencall.h +++ b/tools/libs/call/include/xencall.h @@ -26,7 +26,7 @@ #include /* Callers who don't care don't need to #include */ -typedef struct xentoollog_logger xentoollog_logger; +struct xentoollog_logger; typedef struct xencall_handle xencall_handle; @@ -56,7 +56,8 @@ typedef struct xencall_handle xencall_handle; * Calling xencall_close() is the only safe operation on a * xencall_handle which has been inherited. */ -xencall_handle *xencall_open(xentoollog_logger *logger, unsigned open_flags); +xencall_handle *xencall_open(struct xentoollog_logger *logger, + unsigned open_flags); /* * Close a handle previously allocated with xencall_open(). diff --git a/tools/libs/evtchn/include/xenevtchn.h b/tools/libs/evtchn/include/xenevtchn.h index 4d26161..0fa3f84 100644 --- a/tools/libs/evtchn/include/xenevtchn.h +++ b/tools/libs/evtchn/include/xenevtchn.h @@ -33,7 +33,7 @@ typedef int evtchn_port_or_error_t; typedef struct xenevtchn_handle xenevtchn_handle; /* Callers who don't care don't need to #include */ -typedef struct xentoollog_logger xentoollog_logger; +struct xentoollog_logger; /* * EVENT CHANNEL FUNCTIONS @@ -66,7 +66,8 @@ typedef struct xentoollog_logger xentoollog_logger; * xenevtchn_handle which has been inherited. */ /* Currently no flags are defined */ -xenevtchn_handle *xenevtchn_open(xentoollog_logger *logger, unsigned open_flags); +xenevtchn_handle *xenevtchn_open(struct xentoollog_logger *logger, + unsigned open_flags); /* * Close a handle previously allocated with xenevtchn_open(). diff --git a/tools/libs/foreignmemory/include/xenforeignmemory.h b/tools/libs/foreignmemory/include/xenforeignmemory.h index 3724c63..92b9277 100644 --- a/tools/libs/foreignmemory/include/xenforeignmemory.h +++ b/tools/libs/foreignmemory/include/xenforeignmemory.h @@ -27,7 +27,7 @@ #include /* Callers who don't care don't need to #include */ -typedef struct xentoollog_logger xentoollog_logger; +struct xentoollog_logger; typedef struct xenforeignmemory_handle xenforeignmemory_handle; @@ -55,7 +55,7 @@ typedef struct xenforeignmemory_handle xenforeignmemory_handle; * Calling xenforeignmemory_close() is the only safe operation on a * xenforeignmemory_handle which has been inherited. */ -xenforeignmemory_handle *xenforeignmemory_open(xentoollog_logger *logger, +xenforeignmemory_handle *xenforeignmemory_open(struct xentoollog_logger *logger, unsigned open_flags); /* diff --git a/tools/libs/gnttab/include/xengnttab.h b/tools/libs/gnttab/include/xengnttab.h index 1ca1e70..0431dcf 100644 --- a/tools/libs/gnttab/include/xengnttab.h +++ b/tools/libs/gnttab/include/xengnttab.h @@ -28,7 +28,7 @@ #include /* Callers who don't care don't need to #include */ -typedef struct xentoollog_logger xentoollog_logger; +struct xentoollog_logger; /* * PRODUCING AND CONSUMING GRANT REFERENCES @@ -132,7 +132,8 @@ typedef struct xengntdev_handle xengnttab_handle; * xengnttab_handle which has been inherited. xengnttab_unmap() must * not be called under such circumstances. */ -xengnttab_handle *xengnttab_open(xentoollog_logger *logger, unsigned open_flags); +xengnttab_handle *xengnttab_open(struct xentoollog_logger *logger, + unsigned open_flags); /* * Close a handle previously allocated with xengnttab_open(), @@ -287,7 +288,7 @@ typedef struct xengntdev_handle xengntshr_handle; * Calling xengntshr_close() is the only safe operation on a * xengntshr_handle which has been inherited. */ -xengntshr_handle *xengntshr_open(xentoollog_logger *logger, +xengntshr_handle *xengntshr_open(struct xentoollog_logger *logger, unsigned open_flags); /* diff --git a/tools/libvchan/init.c b/tools/libvchan/init.c index 91531b9..cadd12c 100644 --- a/tools/libvchan/init.c +++ b/tools/libvchan/init.c @@ -212,7 +212,8 @@ static int init_gnt_cli(struct libxenvchan *ctrl, int domain, uint32_t ring_ref) goto out; } -static int init_evt_srv(struct libxenvchan *ctrl, int domain, xentoollog_logger *logger) +static int init_evt_srv(struct libxenvchan *ctrl, int domain, + struct xentoollog_logger *logger) { evtchn_port_or_error_t port; @@ -293,7 +294,9 @@ static int min_order(size_t siz) return rv; } -struct libxenvchan *libxenvchan_server_init(xentoollog_logger *logger, int domain, const char* xs_path, size_t left_min, size_t right_min) +struct libxenvchan *libxenvchan_server_init(struct xentoollog_logger *logger, + int domain, const char* xs_path, + size_t left_min, size_t right_min) { struct libxenvchan *ctrl; int ring_ref; @@ -342,7 +345,8 @@ out: return 0; } -static int init_evt_cli(struct libxenvchan *ctrl, int domain, xentoollog_logger *logger) +static int init_evt_cli(struct libxenvchan *ctrl, int domain, + struct xentoollog_logger *logger) { evtchn_port_or_error_t port; @@ -372,7 +376,8 @@ fail: } -struct libxenvchan *libxenvchan_client_init(xentoollog_logger *logger, int domain, const char* xs_path) +struct libxenvchan *libxenvchan_client_init(struct xentoollog_logger *logger, + int domain, const char* xs_path) { struct libxenvchan *ctrl = malloc(sizeof(struct libxenvchan)); struct xs_handle *xs = NULL; diff --git a/tools/libvchan/libxenvchan.h b/tools/libvchan/libxenvchan.h index 341c375..2adbdfe 100644 --- a/tools/libvchan/libxenvchan.h +++ b/tools/libvchan/libxenvchan.h @@ -47,6 +47,9 @@ #include #include +/* Callers who don't care don't need to #include */ +struct xentoollog_logger; + struct libxenvchan_ring { /* Pointer into the shared page. Offsets into buffer. */ struct ring_shared* shr; @@ -93,7 +96,9 @@ struct libxenvchan { * @param recv_min The minimum size (in bytes) of the receive ring (right) * @return The structure, or NULL in case of an error */ -struct libxenvchan *libxenvchan_server_init(xentoollog_logger *logger, int domain, const char* xs_path, size_t read_min, size_t write_min); +struct libxenvchan *libxenvchan_server_init(struct xentoollog_logger *logger, + int domain, const char* xs_path, + size_t read_min, size_t write_min); /** * Connect to an existing vchan. Note: you can reconnect to an existing vchan * safely, however no locking is performed, so you must prevent multiple clients @@ -104,7 +109,8 @@ struct libxenvchan *libxenvchan_server_init(xentoollog_logger *logger, int domai * @param xs_path Base xenstore path for storing ring/event data * @return The structure, or NULL in case of an error */ -struct libxenvchan *libxenvchan_client_init(xentoollog_logger *logger, int domain, const char* xs_path); +struct libxenvchan *libxenvchan_client_init(struct xentoollog_logger *logger, + int domain, const char* xs_path); /** * Close a vchan. This deallocates the vchan and attempts to free its * resources. The other side is notified of the close, but can still read any