From patchwork Tue Dec 13 16:00:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juergen Gross X-Patchwork-Id: 13072189 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8C264C4708E for ; Tue, 13 Dec 2022 16:05:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.460770.718803 (Exim 4.92) (envelope-from ) id 1p57mF-0006NU-Ro; Tue, 13 Dec 2022 16:05:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 460770.718803; Tue, 13 Dec 2022 16:05:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p57mF-0006LD-Co; Tue, 13 Dec 2022 16:05:07 +0000 Received: by outflank-mailman (input) for mailman id 460770; Tue, 13 Dec 2022 16:05:06 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1p57jW-0001dt-4h for xen-devel@lists.xenproject.org; Tue, 13 Dec 2022 16:02:18 +0000 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 84442e7e-7aff-11ed-91b6-6bf2151ebd3b; Tue, 13 Dec 2022 17:02:17 +0100 (CET) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 384F622A34; Tue, 13 Dec 2022 16:02:17 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0B6A0138EE; Tue, 13 Dec 2022 16:02:17 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Ip56AQmimGNIKgAAMHmgww (envelope-from ); Tue, 13 Dec 2022 16:02:17 +0000 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: 84442e7e-7aff-11ed-91b6-6bf2151ebd3b DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1670947337; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=okx7qxg8bFtkyLH12eZ25h2C7wGOfWUBp/Y3Edy1SaY=; b=RaNYIjUBi6HZ8E9257o+IbFLis69cz97V83G93v48zzHI4LeY6Pbadoogvgc8DBOa8OtkW rr2oh6aVCBt85zLSNLh2bx5jBtqH1SFcJWQg8Z7NRoOuS9zY5voB0hJImvCpFUW1YolPaB /sf4hIATk+MLnA23GOTaUQM0av6LBWg= From: Juergen Gross To: xen-devel@lists.xenproject.org Cc: Juergen Gross , Wei Liu , Julien Grall , Anthony PERARD , Julien Grall Subject: [PATCH v2 16/19] tools/xenstore: make log macro globally available Date: Tue, 13 Dec 2022 17:00:42 +0100 Message-Id: <20221213160045.28170-17-jgross@suse.com> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20221213160045.28170-1-jgross@suse.com> References: <20221213160045.28170-1-jgross@suse.com> MIME-Version: 1.0 Move the definition of the log() macro to xenstored_core.h in order to make it usable from other source files, too. While at it preserve errno from being modified. Signed-off-by: Juergen Gross Reviewed-by: Julien Grall --- tools/xenstore/xenstored_core.c | 14 -------------- tools/xenstore/xenstored_core.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index 60433265ed..48c2793aeb 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c @@ -88,20 +88,6 @@ TDB_CONTEXT *tdb_ctx = NULL; static const char *sockmsg_string(enum xsd_sockmsg_type type); -#define log(...) \ - do { \ - char *s = talloc_asprintf(NULL, __VA_ARGS__); \ - if (s) { \ - trace("%s\n", s); \ - syslog(LOG_ERR, "%s\n", s); \ - talloc_free(s); \ - } else { \ - trace("talloc failure during logging\n"); \ - syslog(LOG_ERR, "talloc failure during logging\n"); \ - } \ - } while (0) - - int quota_nb_entry_per_domain = 1000; int quota_nb_watch_per_domain = 128; int quota_max_entry_size = 2048; /* 2K */ diff --git a/tools/xenstore/xenstored_core.h b/tools/xenstore/xenstored_core.h index 3c4e27d0dd..3b96ecd018 100644 --- a/tools/xenstore/xenstored_core.h +++ b/tools/xenstore/xenstored_core.h @@ -267,6 +267,21 @@ void trace(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); void reopen_log(void); void close_log(void); +#define log(...) \ + do { \ + int _saved_errno = errno; \ + char *s = talloc_asprintf(NULL, __VA_ARGS__); \ + if (s) { \ + trace("%s\n", s); \ + syslog(LOG_ERR, "%s\n", s); \ + talloc_free(s); \ + } else { \ + trace("talloc failure during logging\n"); \ + syslog(LOG_ERR, "talloc failure during logging\n"); \ + } \ + errno = _saved_errno; \ + } while (0) + extern int orig_argc; extern char **orig_argv;