From nobody Mon Nov 3 18:26:06 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1727106882; cv=none; d=zohomail.com; s=zohoarc; b=Hdfqz3Xgur9DHDmvI4l1mfUNgzWr4uJ6uwxjWyFlmDt12tDU56Mr4CWCkJSy6rouhayos5MeiScQ/1d2rQgvNbcza6gqtH1S43CU41wHWdQhxyUhcjDwPzAxW2orMUw2UoAPbyAuDnppc5pRPVqoY2y503lATLlT1axa+P6DvKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727106882; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YYwJGPHlrRxYAkIwiT1rq7m0wmSkPz2GGZv9Yo1GCoQ=; b=bAhKSibm7zZCOt/WsxLOwW4IPaqlvjGAwonKrQ9KYz5KXkfhYoBzuSsEhGwsz4jl49mGiKbiqF/UcbMTkULPv7id3jV4DrgGi0vOamY4xixWXyc1PPP2kFrmvdu/LSBJQ0EyEZWaGjG1eGqwnkk5LXo/z3eQyyUlwX6T1Ut1HA0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17271068823731007.7597749294879; Mon, 23 Sep 2024 08:54:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.802197.1212390 (Exim 4.92) (envelope-from ) id 1sslOK-0007Ja-7T; Mon, 23 Sep 2024 15:54:24 +0000 Received: by outflank-mailman (output) from mailman id 802197.1212390; Mon, 23 Sep 2024 15:54:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sslOK-0007JP-2y; Mon, 23 Sep 2024 15:54:24 +0000 Received: by outflank-mailman (input) for mailman id 802197; Mon, 23 Sep 2024 15:54:22 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sslOI-000730-Qk for xen-devel@lists.xenproject.org; Mon, 23 Sep 2024 15:54:22 +0000 Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [2a00:1450:4864:20::12b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 18f56706-79c4-11ef-99a2-01e77a169b0f; Mon, 23 Sep 2024 17:54:21 +0200 (CEST) Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-53568ffc525so5123234e87.0 for ; Mon, 23 Sep 2024 08:54:21 -0700 (PDT) Received: from andrewcoop.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a90613315e3sm1240926866b.209.2024.09.23.08.54.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2024 08:54:19 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 18f56706-79c4-11ef-99a2-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=citrix.com; s=google; t=1727106860; x=1727711660; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=YYwJGPHlrRxYAkIwiT1rq7m0wmSkPz2GGZv9Yo1GCoQ=; b=ldyx5mIrzb2djfX02qS8Vt3kMyMedjmgxh3gH6YW7wpd0bd19rLrxgarojN7YaCfiV fqo31y5T29MurrgAYlV1EAG9KUxOeOrYwrdWyyoQJNAns71A+ePZavAMuWU/6ivUM87g 7Nsv/3bGTVsF+hpUODsEH6BHnmB34XlkAgS8E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727106860; x=1727711660; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=YYwJGPHlrRxYAkIwiT1rq7m0wmSkPz2GGZv9Yo1GCoQ=; b=KFu6Gc3htI9qHtjPPIlDsNnHv586Qkn6aEjjUt6XPLNFwNLrGfQuP3R1QiKen0TdQg SH33d93rkU31MqKAEEeIOvI2DrQzTt5+7t2FwVj9QP7KoS4KzFzgyUggdHnpue310Vhh fI+6KaBhRbhVMwqte8FUIkrqQYH5JzxdDS//WpoMdFu6bjydz4m083egjomVl+9LxKeo kHC4Mf/s7QGlu7t0EgXkzrzW++OsX3CTe24LK3dU5gvhxsGeLulTVGDj+FZu4gA8JnUb BwJE/HVDk4ZOqUoqEm2dZjiSZ0X7++g3+Rt9pOly4WhMm3WMBc3uLOWIkkZTG4oWMVUY MIaw== X-Gm-Message-State: AOJu0YzLIVc7+Zey0Y8yMrNzvndff1Y9f22/0ZQeZUD6WfP83JlMU5Vz p6SjDK97jSVT0BueZoHkE7vS7W7D4+mSI00NwziHV/5oPGI02TjTQfaGMjRNP7J825DmfaczzoM ULGZxIg== X-Google-Smtp-Source: AGHT+IE13+2HF8paXNonRdWJY1840DGkVLW2sKKXETqMBn++YnaxMcz4ttxuni3k3jDsqPnGeY5dIQ== X-Received: by 2002:a05:6512:ba4:b0:52e:9f17:841a with SMTP id 2adb3069b0e04-536ac2d051fmr6445237e87.6.1727106860059; Mon, 23 Sep 2024 08:54:20 -0700 (PDT) From: Andrew Cooper To: Xen-devel Cc: Andrew Cooper , Anthony PERARD , Juergen Gross Subject: [PATCH] tools/libxs: Style consistency improvements Date: Mon, 23 Sep 2024 16:54:16 +0100 Message-Id: <20240923155416.101538-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.39.5 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1727106882890116600 Content-Type: text/plain; charset="utf-8" This is mostly Linux sytle. Make the file self-consistent. Drop trailing whitespace, and use tabs consistently. No functional change. Signed-off-by: Andrew Cooper Reviewed-by: Juergen Gross --- CC: Anthony PERARD CC: Juergen Gross From the SIGPIPE work, but not submitted at the time. --- tools/libs/store/xs.c | 74 ++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/tools/libs/store/xs.c b/tools/libs/store/xs.c index 5d9c7151e8bb..e22f99b59f61 100644 --- a/tools/libs/store/xs.c +++ b/tools/libs/store/xs.c @@ -1,4 +1,4 @@ -/*=20 +/* Xen Store Daemon interface providing simple tree-like database. Copyright (C) 2005 Rusty Russell IBM Corporation =20 @@ -164,8 +164,10 @@ static void *read_thread(void *arg); =20 static int read_message(struct xs_handle *h, int nonblocking); =20 -static bool setnonblock(int fd, int nonblock) { +static bool setnonblock(int fd, int nonblock) +{ int flags =3D fcntl(fd, F_GETFL); + if (flags =3D=3D -1) return false; =20 @@ -236,7 +238,7 @@ static int get_socket(const char *connect_to) goto error; =20 addr.sun_family =3D AF_UNIX; - if(strlen(connect_to) >=3D sizeof(addr.sun_path)) { + if (strlen(connect_to) >=3D sizeof(addr.sun_path)) { errno =3D EINVAL; goto error; } @@ -276,9 +278,11 @@ static int get_dev(const char *connect_to) return -1; } =20 -static int all_restrict_cb(Xentoolcore__Active_Handle *ah, domid_t domid) { - struct xs_handle *h =3D CONTAINER_OF(ah, *h, tc_ah); - return xentoolcore__restrict_by_dup2_null(h->fd); +static int all_restrict_cb(Xentoolcore__Active_Handle *ah, domid_t domid) +{ + struct xs_handle *h =3D CONTAINER_OF(ah, *h, tc_ah); + + return xentoolcore__restrict_by_dup2_null(h->fd); } =20 static struct xs_handle *get_handle(const char *connect_to) @@ -362,8 +366,10 @@ struct xs_handle *xs_domain_open(void) static const char *xs_domain_dev(void) { char *s =3D getenv("XENSTORED_PATH"); + if (s) return s; + #if defined(__RUMPUSER_XEN__) || defined(__RUMPRUN__) return "/dev/xen/xenbus"; #elif defined(__linux__) @@ -394,7 +400,8 @@ struct xs_handle *xs_open(unsigned long flags) return xsh; } =20 -static void close_free_msgs(struct xs_handle *h) { +static void close_free_msgs(struct xs_handle *h) +{ struct xs_stored_msg *msg, *tmsg; =20 XEN_TAILQ_FOREACH_SAFE(msg, &h->reply_list, list, tmsg) { @@ -408,7 +415,8 @@ static void close_free_msgs(struct xs_handle *h) { } } =20 -static void close_fds_free(struct xs_handle *h) { +static void close_fds_free(struct xs_handle *h) +{ if (h->watch_pipe[0] !=3D -1) { close(h->watch_pipe[0]); close(h->watch_pipe[1]); @@ -416,7 +424,7 @@ static void close_fds_free(struct xs_handle *h) { =20 xentoolcore__deregister_active_handle(&h->tc_ah); close(h->fd); - =20 + free(h); } =20 @@ -448,7 +456,7 @@ void xs_daemon_close(struct xs_handle *h) close_fds_free(h); } =20 -void xs_close(struct xs_handle* xsh) +void xs_close(struct xs_handle *xsh) { if (xsh) xs_daemon_close(xsh); @@ -995,7 +1003,7 @@ bool xs_watch(struct xs_handle *h, const char *path, c= onst char *token) =20 #define READ_THREAD_STACKSIZE \ ((DEFAULT_THREAD_STACKSIZE < PTHREAD_STACK_MIN) ? \ - PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE) + PTHREAD_STACK_MIN : DEFAULT_THREAD_STACKSIZE) =20 /* We dynamically create a reader thread on demand. */ mutex_lock(&h->request_mutex); @@ -1258,7 +1266,7 @@ bool xs_transaction_end(struct xs_handle *h, xs_trans= action_t t, strcpy(abortstr, "F"); else strcpy(abortstr, "T"); -=09 + return xs_bool(xs_single(h, t, XS_TRANSACTION_END, abortstr, NULL)); } =20 @@ -1293,7 +1301,7 @@ bool xs_introduce_domain(struct xs_handle *h, } =20 bool xs_set_target(struct xs_handle *h, - unsigned int domid, unsigned int target) + unsigned int domid, unsigned int target) { struct xsd_sockmsg msg =3D { .type =3D XS_SET_TARGET }; char domid_str[MAX_STRLEN(domid)]; @@ -1377,30 +1385,30 @@ bool xs_is_domain_introduced(struct xs_handle *h, u= nsigned int domid) =20 int xs_suspend_evtchn_port(int domid) { - char path[128]; - char *portstr; - int port; - unsigned int plen; - struct xs_handle *xs; - - xs =3D xs_daemon_open(); - if (!xs) - return -1; + char path[128]; + char *portstr; + int port; + unsigned int plen; + struct xs_handle *xs; + + xs =3D xs_daemon_open(); + if (!xs) + return -1; =20 - sprintf(path, "/local/domain/%d/device/suspend/event-channel", domid); - portstr =3D xs_read(xs, XBT_NULL, path, &plen); - xs_daemon_close(xs); + sprintf(path, "/local/domain/%d/device/suspend/event-channel", domid); + portstr =3D xs_read(xs, XBT_NULL, path, &plen); + xs_daemon_close(xs); =20 - if (!portstr || !plen) { - port =3D -1; - goto out; - } + if (!portstr || !plen) { + port =3D -1; + goto out; + } =20 - port =3D atoi(portstr); + port =3D atoi(portstr); =20 out: - free(portstr); - return port; + free(portstr); + return port; } =20 char *xs_control_command(struct xs_handle *h, const char *cmd, @@ -1436,7 +1444,7 @@ static int read_message(struct xs_handle *h, int nonb= locking) * whole amount requested. Ie as soon as we have the start of * the message we block until we get all of it. */ - =20 + struct xs_stored_msg *msg =3D NULL; char *body =3D NULL; int saved_errno =3D 0; --=20 2.39.5