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.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE 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 27A0B1F619 for ; Sat, 3 Sep 2022 11:18:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1662203909; bh=z/GyQPrY7X7Bq4hA9qQGOGR1SjpJHGvPSI6D5ehii9E=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f09fh1N3IhB+VzfR8kYDa3p9Tyz3kMTgRfF0l/u+t/eFVpFCpvoqlkdzy1otXU567 7mCJRp7rBObEDfNG+IfcSIxAH9FCHI7ooipq49WesaUDH+ryTz8BaFVKuJ5gb6+u3N JNApHq3ZZCDohwj+uO2TkPPva5d3MC+0CU2SW9rc= From: Eric Wong To: mwrap-perl@80x24.org Subject: [PATCH 3/4] use macro to quiet uninitialized and unused variable warnings Date: Sat, 3 Sep 2022 11:18:27 +0000 Message-Id: <20220903111828.2316808-4-mwrap-perl@80x24.org> In-Reply-To: <20220903111828.2316808-1-mwrap-perl@80x24.org> References: <20220903111828.2316808-1-mwrap-perl@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This allows us to avoid some #ifdefs inside function bodies. This cleanup comes from the Ruby version. --- Mwrap.xs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Mwrap.xs b/Mwrap.xs index 3392fee..9e9f571 100644 --- a/Mwrap.xs +++ b/Mwrap.xs @@ -153,14 +153,18 @@ __attribute__((constructor)) static void resolve_malloc(void) --locating; } +#ifdef NDEBUG +#define QUIET_CC_WARNING(var) (void)var; +#else +#define QUIET_CC_WARNING(var) +#endif + static void mutex_lock(pthread_mutex_t *m) { int err = pthread_mutex_lock(m); assert(err == 0); -#ifdef NDEBUG - (void)err; /* quiet gcc warning */ -#endif + QUIET_CC_WARNING(err) } static void @@ -168,9 +172,7 @@ mutex_unlock(pthread_mutex_t *m) { int err = pthread_mutex_unlock(m); assert(err == 0); -#ifdef NDEBUG - (void)err; /* quiet gcc warning */ -#endif + QUIET_CC_WARNING(err) } #ifndef HAVE_MEMPCPY