From patchwork Fri Jun 9 21:50:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Williams X-Patchwork-Id: 9779391 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7E8FE60393 for ; Fri, 9 Jun 2017 21:57:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D2E92870F for ; Fri, 9 Jun 2017 21:57:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E7F228712; Fri, 9 Jun 2017 21:57:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 765322870F for ; Fri, 9 Jun 2017 21:57:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EE03B21967BEE; Fri, 9 Jun 2017 14:55:51 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id D2ECA21952CD7 for ; Fri, 9 Jun 2017 14:55:50 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jun 2017 14:57:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,320,1493708400"; d="scan'208";a="97697981" Received: from dwillia2-desk3.jf.intel.com (HELO dwillia2-desk3.amr.corp.intel.com) ([10.54.39.125]) by orsmga002.jf.intel.com with ESMTP; 09 Jun 2017 14:57:00 -0700 Subject: [ndctl PATCH] ndctl, log: save errno over calls to emit log messages From: Dan Williams To: linux-nvdimm@lists.01.org Date: Fri, 09 Jun 2017 14:50:33 -0700 Message-ID: <149704503297.35935.12657932919759124474.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Virus-Scanned: ClamAV using ClamSMTP Some ndctl routines return errno after logging a result. Given the log message may have updated errno save and restore it over calls to ->log_fn(). Suggested-by: Andy Rudoff Signed-off-by: Dan Williams --- util/log.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/log.c b/util/log.c index 8ecaf11d3d64..cc4d7d8aad7c 100644 --- a/util/log.c +++ b/util/log.c @@ -14,16 +14,19 @@ #include #include #include +#include #include void do_log(struct log_ctx *ctx, int priority, const char *file, int line, const char *fn, const char *format, ...) { va_list args; + int errno_save = errno; va_start(args, format); ctx->log_fn(ctx, priority, file, line, fn, format, args); va_end(args); + errno = errno_save; } static void log_stderr(struct log_ctx *ctx, int priority, const char *file,