user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 4/4] xap_helper: fix C++-specific warnings
  2023-08-26  6:13  6% [PATCH 0/4] minor cindex-related build stuff Eric Wong
@ 2023-08-26  6:13  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-08-26  6:13 UTC (permalink / raw)
  To: meta

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]) {

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/4] minor cindex-related build stuff
@ 2023-08-26  6:13  6% Eric Wong
  2023-08-26  6:13  7% ` [PATCH 4/4] xap_helper: fix C++-specific warnings Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-08-26  6:13 UTC (permalink / raw)
  To: meta

The first one is a minor test improvement I had lying around
on a VM I nearly forgot about.  The rest are small improvements
related to -cindex.  Allowing stuff to work on non-Linux
w/o Inline::C nor Socket::MsgHdr still needs doing...

Eric Wong (4):
  t/psgi_scan_all: reduce use_ok statements
  makefile: add targets for ASan and valgrind
  cindex: document pipelines created for prune
  xap_helper: fix C++-specific warnings

 Makefile.PL                      |  9 +++++++++
 lib/PublicInbox/CodeSearchIdx.pm |  9 ++++++++-
 lib/PublicInbox/xap_helper.h     | 12 +++++++-----
 t/psgi_scan_all.t                | 16 +++++++---------
 4 files changed, 31 insertions(+), 15 deletions(-)

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-08-26  6:13  6% [PATCH 0/4] minor cindex-related build stuff Eric Wong
2023-08-26  6:13  7% ` [PATCH 4/4] xap_helper: fix C++-specific warnings Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).