From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MMLSCCLKk17CJAAA0tVLHw (envelope-from ) for ; Mon, 13 Apr 2020 02:10:42 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id jaHoGCTKk16/agAAB5/wlQ (envelope-from ) for ; Mon, 13 Apr 2020 02:10:44 +0000 Received: from arlo.cworth.org (arlo.cworth.org [50.126.95.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 53DF6940446 for ; Mon, 13 Apr 2020 02:10:42 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id E941A6DE1498; Sun, 12 Apr 2020 19:10:32 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id hbTJgsphacni; Sun, 12 Apr 2020 19:10:32 -0700 (PDT) Received: from arlo.cworth.org (localhost [IPv6:::1]) by arlo.cworth.org (Postfix) with ESMTP id B80016DE13BA; Sun, 12 Apr 2020 19:10:27 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id AF3066DE0F16 for ; Sun, 12 Apr 2020 19:10:25 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id r-OGdHCr8uqN for ; Sun, 12 Apr 2020 19:10:25 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id 543B76DE0EF3 for ; Sun, 12 Apr 2020 19:10:24 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.92) (envelope-from ) id 1jNoYJ-0003iT-Fw; Sun, 12 Apr 2020 22:10:23 -0400 Received: (nullmailer pid 2799598 invoked by uid 1000); Mon, 13 Apr 2020 02:10:19 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org Subject: [PATCH 3/5] cli/dump: define GZPRINTF macro and use it in place of gzprintf Date: Sun, 12 Apr 2020 23:10:14 -0300 Message-Id: <20200413021016.2799496-4-david@tethera.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200413021016.2799496-1-david@tethera.net> References: <20200412173432.2575450-1-david@tethera.net> <20200413021016.2799496-1-david@tethera.net> MIME-Version: 1.0 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: notmuch-bounces@notmuchmail.org Sender: "notmuch" X-Scanner: scn0 X-Spam-Score: -0.01 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 50.126.95.6 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Scan-Result: default: False [-0.01 / 13.00]; ARC_NA(0.00)[]; GENERIC_REPUTATION(0.00)[-0.44943427509714]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+a:c]; IP_REPUTATION_HAM(0.00)[asn: 27017(-0.18), country: US(-0.01), ip: 50.126.95.6(-0.45)]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[notmuch@notmuchmail.org]; DMARC_NA(0.00)[tethera.net]; HAS_LIST_UNSUB(-0.01)[]; RCVD_TLS_LAST(0.00)[]; MX_GOOD(-0.50)[cached: notmuchmail.org]; RCPT_COUNT_TWO(0.00)[2]; MID_CONTAINS_FROM(1.00)[]; MAILLIST(-0.20)[mailman]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:27017, ipnet:50.126.64.0/18, country:US]; FROM_NEQ_ENVFROM(0.00)[david@tethera.net,notmuch-bounces@notmuchmail.org]; RCVD_COUNT_SEVEN(0.00)[8] X-TUID: dfkxvqAmiLlm This will at least catch errors, and can be replaced with more sophisticated error handling where appropriate. --- notmuch-client.h | 3 +++ notmuch-dump.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/notmuch-client.h b/notmuch-client.h index 467e1d84..55d4d526 100644 --- a/notmuch-client.h +++ b/notmuch-client.h @@ -497,6 +497,9 @@ print_status_gzbytes (const char *loc, gzFile file, int bytes); +#define ASSERT_GZBYTES(file, bytes) ( (print_status_gzbytes(__location__, file, bytes)) ? exit(1) : 0 ) +#define GZPRINTF(file, fmt, ...) ASSERT_GZBYTES(file, gzprintf (file, fmt, ##__VA_ARGS__)); + #include "command-line-arguments.h" extern const char *notmuch_requested_db_uuid; diff --git a/notmuch-dump.c b/notmuch-dump.c index 65e02639..ca45d885 100644 --- a/notmuch-dump.c +++ b/notmuch-dump.c @@ -42,7 +42,7 @@ database_dump_config (notmuch_database_t *notmuch, gzFile output) notmuch_config_list_key (list)); goto DONE; } - gzprintf (output, "#@ %s", buffer); + GZPRINTF (output, "#@ %s", buffer); if (hex_encode (notmuch, notmuch_config_list_value (list), &buffer, &buffer_size) != HEX_SUCCESS) { @@ -51,7 +51,7 @@ database_dump_config (notmuch_database_t *notmuch, gzFile output) goto DONE; } - gzprintf (output, " %s\n", buffer); + GZPRINTF (output, " %s\n", buffer); } ret = EXIT_SUCCESS; @@ -71,7 +71,7 @@ print_dump_header (gzFile output, int output_format, int include) { const char *sep = ""; - gzprintf (output, "#notmuch-dump %s:%d ", + GZPRINTF (output, "#notmuch-dump %s:%d ", (output_format == DUMP_FORMAT_SUP) ? "sup" : "batch-tag", NOTMUCH_DUMP_VERSION); @@ -80,11 +80,11 @@ print_dump_header (gzFile output, int output_format, int include) sep = ","; } if (include & DUMP_INCLUDE_PROPERTIES) { - gzprintf (output, "%sproperties", sep); + GZPRINTF (output, "%sproperties", sep); sep = ","; } if (include & DUMP_INCLUDE_TAGS) { - gzprintf (output, "%stags", sep); + GZPRINTF (output, "%stags", sep); } gzputs (output, "\n"); } @@ -115,7 +115,7 @@ dump_properties_message (void *ctx, fprintf (stderr, "Error: failed to hex-encode message-id %s\n", message_id); return 1; } - gzprintf (output, "#= %s", *buffer_p); + GZPRINTF (output, "#= %s", *buffer_p); first = false; } @@ -126,18 +126,18 @@ dump_properties_message (void *ctx, fprintf (stderr, "Error: failed to hex-encode key %s\n", key); return 1; } - gzprintf (output, " %s", *buffer_p); + GZPRINTF (output, " %s", *buffer_p); if (hex_encode (ctx, val, buffer_p, size_p) != HEX_SUCCESS) { fprintf (stderr, "Error: failed to hex-encode value %s\n", val); return 1; } - gzprintf (output, "=%s", *buffer_p); + GZPRINTF (output, "=%s", *buffer_p); } notmuch_message_properties_destroy (list); if (! first) - gzprintf (output, "\n", *buffer_p); + GZPRINTF (output, "\n", *buffer_p); return 0; } @@ -165,7 +165,7 @@ dump_tags_message (void *ctx, } if (output_format == DUMP_FORMAT_SUP) { - gzprintf (output, "%s (", message_id); + GZPRINTF (output, "%s (", message_id); } for (notmuch_tags_t *tags = notmuch_message_get_tags (message); @@ -187,7 +187,7 @@ dump_tags_message (void *ctx, tag_str); return EXIT_FAILURE; } - gzprintf (output, "+%s", *buffer_p); + GZPRINTF (output, "+%s", *buffer_p); } } @@ -200,7 +200,7 @@ dump_tags_message (void *ctx, message_id, strerror (errno)); return EXIT_FAILURE; } - gzprintf (output, " -- %s\n", *buffer_p); + GZPRINTF (output, " -- %s\n", *buffer_p); } return EXIT_SUCCESS; } -- 2.25.1