From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.1 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id D0C1A1FAF1 for ; Mon, 12 Dec 2022 11:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1670845256; bh=YzrUi4nRxATZW7MCepClQjQ21whYk0IUEgAJFxkTs/c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jfaDqT4HDnVi8dUDUqF3Xnjbxb0JLAzOwvkdXPaV9ziZEBmIAlXp51BU2f2AVI0FB 543O0GjUtiWzaB8mwA1r5ORDIClB90VxXQerBTAw9DIYICwbGp9NUEoNPmEcaLe86b tDqQ0TeUMOgeKNHzx5+cLr4isN/e0qcahSPcFwK4= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 3/5] use `%m' for *printf rather than strerror(errno) Date: Mon, 12 Dec 2022 11:40:54 +0000 Message-Id: <20221212114056.9615-4-e@80x24.org> In-Reply-To: <20221212114056.9615-1-e@80x24.org> References: <20221212114056.9615-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: FreeBSD, glibc both support it, as do minimalist libcs such as uClibc and musl. --- mwrap_core.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mwrap_core.h b/mwrap_core.h index 6d498c1..179f136 100644 --- a/mwrap_core.h +++ b/mwrap_core.h @@ -826,8 +826,7 @@ static void dump_destructor(void) dump_fd = open(dump_path, O_CLOEXEC|O_WRONLY|O_APPEND|O_CREAT, 0666); if (dump_fd < 0) { - fprintf(stderr, "open %s failed: %s\n", dump_path, - strerror(errno)); + fprintf(stderr, "open %s failed: %m\n", dump_path); goto out; } } @@ -850,8 +849,7 @@ static void dump_destructor(void) a.fp = fdopen(dump_fd, modes[i]); if (!a.fp) { - fprintf(stderr, "failed to open fd=%d: %s\n", - dump_fd, strerror(errno)); + fprintf(stderr, "failed to open fd=%d: %m\n", dump_fd); goto out; } /* we'll leak some memory here, but this is a destructor */ @@ -948,7 +946,7 @@ __attribute__((constructor)) static void mwrap_ctor(void) h->real = h; call_rcu(&h->as.dead, free_hdr_rcu); } else - fprintf(stderr, "malloc failed: %s\n", strerror(errno)); + fprintf(stderr, "malloc: %m\n"); h1d_start(); CHECK(int, 0, pthread_sigmask(SIG_SETMASK, &old, NULL));