]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
xap_helper: drop unnecessary check on split2argv result
authorEric Wong <e@80x24.org>
Fri, 31 Oct 2025 02:45:02 +0000 (02:45 +0000)
committerEric Wong <e@80x24.org>
Sun, 2 Nov 2025 19:52:19 +0000 (19:52 +0000)
Our split2argv will already abort on excessive or zero
arguments, and it's impossible to for a `size_t' to evaluate to
a negative value, anyways.  While we're at it, explain it's
safe to cast its return value to a signed int (typically
32-bit) since `req.argv' is a relatively small fixed value.

lib/PublicInbox/xap_helper.h
lib/PublicInbox/xh_cidx.h

index d582841c474ac8e2a369f3afa862224cddcf8aff..edc418926a8315bdde65a871f6a547fbae0131e7 100644 (file)
@@ -945,6 +945,8 @@ static void recv_loop(void) // worker process loop
                        continue;
                if (req.fp[1])
                        stderr_set(req.fp[1]);
+
+               // MY_ARG_MAX limits the return value of SPLIT2ARGV
                req.argc = (int)SPLIT2ARGV(req.argv, rbuf, len);
                dispatch(&req);
                ERR_CLOSE(req.fp[0], 0);
index 84686dff1509d98283d014d826eb764ebfbb7122..4212da7881c6d1551b7ec7d478c8e532c9f6bf89 100644 (file)
@@ -267,7 +267,6 @@ static bool cmd_dump_roots(struct req *req)
        if (asize < est) ABORT("too many entries: %zu", est);
        drt.entries = (char **)xcalloc(asize, sizeof(char *));
        size_t tot = split2argv(drt.entries, (char *)drt.mm_ptr, size, asize);
-       if (tot <= 0) return false; // split2argv already warned on error
        drt.root2id = root2id_init();
        root2id_cm_resize(drt.root2id, est);
        for (size_t i = 0; i < tot; ) {