From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by sourceware.org (Postfix) with ESMTPS id 2FE683865C28 for ; Thu, 20 Oct 2022 18:26:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2FE683865C28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pj1-x1031.google.com with SMTP id o17-20020a17090aac1100b0020d98b0c0f4so4300495pjq.4 for ; Thu, 20 Oct 2022 11:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7fgEYu6qXaDPRDHYyYp7/B7V8pL4CCh3RRUc906CqbY=; b=CY0CO6vnCjFszPMYikiMHylde2cRKZbA1Wx5pA/+3g1h0QuB6dPXgbJ5H03VIMKQg8 ESWKunh9fi5gJMO3RaELLRyfLQXm+f2kD9aUn/A1KDdLDnGMQ1sAyOKzG4unlA5woLJF wVacp6b+IIoJ9mWn99i2T30Fl+O94UaVd9gdaedUoPadBoZeBWFaJb6dAR1734dpgnO6 bWrZICQtwi3Y4oKFnObN/FBT2h5vCFLlX25AJr3NN0eJ0s2kUxrx0wxOOTuNaHoI/BHW zHSJ2ATweeHfzLfNjWyCET0fb6Ad8eJ2Ak0/orZ6vvRxx2WMUqZVfJUfSc6k5B2BUpKP mKZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7fgEYu6qXaDPRDHYyYp7/B7V8pL4CCh3RRUc906CqbY=; b=ardnAewvAEqypcXXeoD9kvV0gxXQwj2ZNqjq0fg4gE43UxMkJqd6lqIRh4cQnJ6O0q FG0CY3kMPdMtuPgsV3a4UiSNXbAaksXgMT5IUuyx4CZBL7J9Z9kaqhHp/vicG2XB8lry 1tb/Cm73vKEaZ9UiQW785ZsqxMlZgCyPAmAoQ33wFLR1MdOohY5Tx7gdFFE63ZXRMlFf vYTXWXyXNNfp6x7+hpVZ+Iql+CrbMvw07sZaUWxsxmms/z6yreLpjukNLmipioFy01Lv RdQ1m3Em7dONI6dmpue/JaarwdAgtsseFM4zDg+c9P701DRN1ToBdqqzVB/I0ACLjt0A RMOw== X-Gm-Message-State: ACrzQf05ndGudOrxnbg+XyTnzZrs03XsYNAdawvXSBlZ9HrUMMByn6TV fErFdVbeRlUFoH2Xzxcs9MPkWwf05IzxyQ== X-Google-Smtp-Source: AMsMyM5j8NwBw2nr2bumwkIfgLfLGeaNVvXq74APS/TrQIgsy7+FWFk9YyDuBxbmxMNqXwk7eromlw== X-Received: by 2002:a17:903:2306:b0:185:43a2:3d1c with SMTP id d6-20020a170903230600b0018543a23d1cmr15336293plh.154.1666290415441; Thu, 20 Oct 2022 11:26:55 -0700 (PDT) Received: from localhost.localdomain ([103.94.185.75]) by smtp.googlemail.com with ESMTPSA id w15-20020a17090a460f00b00202fbd9c21dsm115067pjg.48.2022.10.20.11.26.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Oct 2022 11:26:54 -0700 (PDT) From: Yonggang Luo To: elfutils-devel@sourceware.org Cc: Yonggang Luo Subject: [PATCH 15/25] lib: Implement error properly even when not HAVE_ERR_H Date: Fri, 21 Oct 2022 02:25:54 +0800 Message-Id: <20221020182603.815-16-luoyonggang@gmail.com> X-Mailer: git-send-email 2.36.1.windows.1 In-Reply-To: <20221020182603.815-1-luoyonggang@gmail.com> References: <20221020182603.815-1-luoyonggang@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: on win32, there is no err.h Signed-off-by: Yonggang Luo --- lib/error.c | 9 ++++++++- lib/system.h | 4 +--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/error.c b/lib/error.c index 5186fc15..7924735e 100644 --- a/lib/error.c +++ b/lib/error.c @@ -28,12 +28,14 @@ #include -#if !defined(HAVE_ERROR_H) && defined(HAVE_ERR_H) +#if !defined(HAVE_ERROR_H) #include #include #include #include +#if defined(HAVE_ERR_H) #include +#endif unsigned int error_message_count = 0; @@ -44,6 +46,7 @@ void error(int status, int errnum, const char *format, ...) { fflush (stdout); va_start(argp, format); +#if defined(HAVE_ERR_H) if (status) { if (errnum) @@ -64,6 +67,10 @@ void error(int status, int errnum, const char *format, ...) { else vwarnx (format, argp); } +#else + (void)status; + vfprintf(stderr, format, argp); +#endif va_end(argp); fflush (stderr); diff --git a/lib/system.h b/lib/system.h index 7132cd6d..264781c2 100644 --- a/lib/system.h +++ b/lib/system.h @@ -51,11 +51,9 @@ #if defined(HAVE_ERROR_H) #include -#elif defined(HAVE_ERR_H) +#else extern int error_message_count; void error(int status, int errnum, const char *format, ...); -#else -#error "err.h or error.h must be available" #endif /* error (EXIT_FAILURE, ...) should be noreturn but on some systems it -- 2.36.1.windows.1