unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
* [PATCH 0/4] minor cindex-related build stuff
@ 2023-08-26  6:13 Eric Wong
  2023-08-26  6:13 ` [PATCH 1/4] t/psgi_scan_all: reduce use_ok statements Eric Wong
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
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	[flat|nested] 5+ messages in thread

* [PATCH 1/4] t/psgi_scan_all: reduce use_ok statements
  2023-08-26  6:13 [PATCH 0/4] minor cindex-related build stuff Eric Wong
@ 2023-08-26  6:13 ` Eric Wong
  2023-08-26  6:13 ` [PATCH 2/4] makefile: add targets for ASan and valgrind Eric Wong
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2023-08-26  6:13 UTC (permalink / raw)
  To: meta

This can save a handful of cycles to avoid testing things which
are already implicit from other tests.
---
 t/psgi_scan_all.t | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/t/psgi_scan_all.t b/t/psgi_scan_all.t
index 09e8eaf9..20b93b78 100644
--- a/t/psgi_scan_all.t
+++ b/t/psgi_scan_all.t
@@ -1,16 +1,14 @@
 #!perl -w
-# Copyright (C) 2019-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
-use strict;
-use v5.10.1;
+use v5.12;
 use PublicInbox::TestCommon;
 use PublicInbox::Eml;
-use PublicInbox::Config;
-my @mods = qw(HTTP::Request::Common Plack::Test URI::Escape DBD::SQLite);
-require_git 2.6;
-require_mods(@mods);
-use_ok 'PublicInbox::WWW';
-foreach my $mod (@mods) { use_ok $mod; }
+my @use = qw(HTTP::Request::Common Plack::Test);
+my @req = qw(URI::Escape DBD::SQLite);
+require_git v2.6;
+require_mods(@use, @req, qw(PublicInbox::WWW PublicInbox::Config));
+$_->import for @use;
 my $cfg = '';
 foreach my $i (1..2) {
 	my $ibx = create_inbox "test-$i", version => 2, indexlevel => 'basic',

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] makefile: add targets for ASan and valgrind
  2023-08-26  6:13 [PATCH 0/4] minor cindex-related build stuff Eric Wong
  2023-08-26  6:13 ` [PATCH 1/4] t/psgi_scan_all: reduce use_ok statements Eric Wong
@ 2023-08-26  6:13 ` Eric Wong
  2023-08-26  6:13 ` [PATCH 3/4] cindex: document pipelines created for prune Eric Wong
  2023-08-26  6:13 ` [PATCH 4/4] xap_helper: fix C++-specific warnings Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2023-08-26  6:13 UTC (permalink / raw)
  To: meta

I would never consider working on C++ code without at least one
one of these tools present.
---
 Makefile.PL | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/Makefile.PL b/Makefile.PL
index 710d705d..5865a252 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -262,5 +262,14 @@ symlink-install : lib/PublicInbox.pm
 pure_all :: lib/PublicInbox.pm
 lib/PublicInbox.pm : FORCE
 	VERSION=\$(VERSION) \$(PERL) -w ./version-gen.perl
+
+test-asan : pure_all
+	CXXFLAGS='-O0 -Wall -ggdb3 -fsanitize=address' \
+		prove -bvw t/xap_helper.t
+
+VG_OPT = '-v --trace-children=yes --track-fds=yes'
+VG_OPT += ' --leak-check=yes --track-origins=yes'
+test-valgrind : pure_all
+	VALGRIND="valgrind \$\$(VG_OPT)" prove -bvw t/xap_helper.t
 EOF
 }

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] cindex: document pipelines created for prune
  2023-08-26  6:13 [PATCH 0/4] minor cindex-related build stuff Eric Wong
  2023-08-26  6:13 ` [PATCH 1/4] t/psgi_scan_all: reduce use_ok statements Eric Wong
  2023-08-26  6:13 ` [PATCH 2/4] makefile: add targets for ASan and valgrind Eric Wong
@ 2023-08-26  6:13 ` Eric Wong
  2023-08-26  6:13 ` [PATCH 4/4] xap_helper: fix C++-specific warnings Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2023-08-26  6:13 UTC (permalink / raw)
  To: meta

This ought to make things easier-to-understand for people
reading the code for the first time (or rereading it for the
first time in a few days :x)
---
 lib/PublicInbox/CodeSearchIdx.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lib/PublicInbox/CodeSearchIdx.pm b/lib/PublicInbox/CodeSearchIdx.pm
index a9a7d313..2700744d 100644
--- a/lib/PublicInbox/CodeSearchIdx.pm
+++ b/lib/PublicInbox/CodeSearchIdx.pm
@@ -948,7 +948,8 @@ sub init_prune ($) {
 	# Dealing with millions of commits here at once, so use faster tools.
 	# xapian-delve is nearly an order-of-magnitude faster than Xapian Perl
 	# bindings.  sed/awk are faster than Perl for simple stream ops, and
-	# sort+comm are more memory-efficient with gigantic lists
+	# sort+comm are more memory-efficient with gigantic lists.
+	# pipeline: delve | sed | sort >indexed_commits
 	my @delve = (undef, qw(-A Q -1));
 	my @sed = (undef, '-ne', 's/^Q//p');
 	@COMM = (undef, qw(-2 -3 indexed_commits -));
@@ -988,6 +989,12 @@ sub dump_git_commits { # awaitpid cb
 sub run_prune { # OnDestroy when `git config extensions.objectFormat' are done
 	my ($self) = @_;
 	return if $DO_QUIT;
+	# setup the following pipeline: (
+	#	git --git-dir=hexlen40.git cat-file \
+	#		--batch-all-objects --batch-check &&
+	#	git --git-dir=hexlen64.git cat-file \
+	#		--batch-all-objects --batch-check
+	# ) | awk | sort | comm | cidx_read_comm()
 	pipe(my ($awk_in, $batch_out)) or die "pipe: $!";
 	pipe(my ($sort_in, $awk_out)) or die "pipe: $!";
 	pipe(my ($comm_in, $sort_out)) or die "pipe: $!";

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] xap_helper: fix C++-specific warnings
  2023-08-26  6:13 [PATCH 0/4] minor cindex-related build stuff Eric Wong
                   ` (2 preceding siblings ...)
  2023-08-26  6:13 ` [PATCH 3/4] cindex: document pipelines created for prune Eric Wong
@ 2023-08-26  6:13 ` Eric Wong
  3 siblings, 0 replies; 5+ messages in thread
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	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-08-26  6:13 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-26  6:13 [PATCH 0/4] minor cindex-related build stuff Eric Wong
2023-08-26  6:13 ` [PATCH 1/4] t/psgi_scan_all: reduce use_ok statements Eric Wong
2023-08-26  6:13 ` [PATCH 2/4] makefile: add targets for ASan and valgrind Eric Wong
2023-08-26  6:13 ` [PATCH 3/4] cindex: document pipelines created for prune Eric Wong
2023-08-26  6:13 ` [PATCH 4/4] xap_helper: fix C++-specific warnings Eric Wong

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).