From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS60404 103.251.164.0/22 X-Spam-Status: No, score=-0.5 required=3.0 tests=AWL,BAYES_00, RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_ZBI,RCVD_IN_SBL_CSS,RCVD_IN_XBL,RDNS_NONE,SPF_FAIL, SPF_HELO_FAIL,TO_EQ_FM_DOM_SPF_FAIL shortcircuit=no autolearn=no autolearn_force=no version=3.4.6 Received: from 80x24.org (unknown [103.251.167.20]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id B43401F406 for ; Fri, 25 Aug 2023 19:40:13 +0000 (UTC) From: Eric Wong To: spew@80x24.org Subject: [PATCH] xap_helper: fix C++-specific warnings Date: Fri, 25 Aug 2023 19:38:43 +0000 Message-ID: <20230825193843.23407-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: While initialization of zeroed structs in C is done via `{0}', I've just learned from g++(1) that C++ uses `{}'. I can't seem to get use of a single designated initializer to compile without warnings in C++, either, so we'll just initialize them as zero and assign them ASAP for __cleanup__ functions. This fixes compilation warnings under -Wextra in g++ (Debian 10.2.1-6) which adds -Wmissing-field-initializers. This also fixes compilation warnings under -Wall in clang (FreeBSD 13.0.0) from -Wmissing. --- lib/PublicInbox/xap_helper.h | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/xap_helper.h b/lib/PublicInbox/xap_helper.h index e3ccfd41..e10527d1 100644 --- a/lib/PublicInbox/xap_helper.h +++ b/lib/PublicInbox/xap_helper.h @@ -436,7 +436,7 @@ static enum exc_iter dump_roots_iter(struct req *req, struct dump_roots_tmp *drt, Xapian::MSetIterator *i) { - CLEANUP_FBUF struct fbuf root_ids = { 0 }; // " $ID0 $ID1 $IDx..\n" + CLEANUP_FBUF struct fbuf root_ids = {}; // " $ID0 $ID1 $IDx..\n" try { Xapian::Document doc = i->get_document(); if (!root2ids_str(&root_ids, &doc)) @@ -453,7 +453,8 @@ static enum exc_iter dump_roots_iter(struct req *req, static bool cmd_dump_roots(struct req *req) { - CLEANUP_DUMP_ROOTS struct dump_roots_tmp drt = { .root2id_fd = -1 }; + CLEANUP_DUMP_ROOTS struct dump_roots_tmp drt = {}; + drt.root2id_fd = -1; if ((optind + 1) >= req->argc) { warnx("usage: dump_roots [OPTIONS] ROOT2ID_FILE QRY_STR"); return false; // need file + qry_str @@ -563,12 +564,13 @@ union my_cmsg { static bool recv_req(struct req *req, char *rbuf, size_t *len) { - union my_cmsg cmsg = { 0 }; - struct msghdr msg = { .msg_iovlen = 1 }; + union my_cmsg cmsg = {}; + struct msghdr msg = {}; struct iovec iov; iov.iov_base = rbuf; iov.iov_len = *len; msg.msg_iov = &iov; + msg.msg_iovlen = 1; msg.msg_control = &cmsg.hdr; msg.msg_controllen = CMSG_SPACE(RECV_FD_SPACE); @@ -823,7 +825,7 @@ static void recv_loop(void) // worker process loop static char rbuf[4096 * 33]; // per-process while (!parent_pid || getppid() == parent_pid) { size_t len = sizeof(rbuf); - struct req req = { 0 }; + struct req req = {}; if (!recv_req(&req, rbuf, &len)) continue; if (req.fp[1]) {