From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 6016 invoked from network); 26 Sep 2023 00:42:40 -0000 Received: from alyss.skarnet.org (95.142.172.232) by inbox.vuxu.org with ESMTPUTF8; 26 Sep 2023 00:42:40 -0000 Received: (qmail 53862 invoked by uid 89); 26 Sep 2023 00:43:05 -0000 Mailing-List: contact supervision-help@list.skarnet.org; run by ezmlm Sender: Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Received: (qmail 53855 invoked from network); 26 Sep 2023 00:43:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=westernsemico.com; s=default; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=3o4NlBA+ka+WHAc1fEGrOkNPhn6tTwmOQdeUaYlTP2U=; b=Y81YOPfD4z8+9gvkQaZw0Ik4pA sg5j07sO4Hja+V2hFqY7NhReUSW3SPScpvIQdiXCGLhyjLEhvoFexFVwpAN6EYTOBswQeibMX10NG 1rbvTe22E4qeNVuPIJsM9P91u6qXaOk4WGR+N58hDtGi4V+gXUWlwYi/iqNv8FSbdPtCDfo3XSYCa j7OCIZPEJr+EM0zE/GEXvzTZE22tp1gesp9XHQnpSrYfMyU7g3Ly36L5tdpZFNIszPWiIZ/LrVHFy F1paZisjMb4xpFh8Pz1JW4CvB4Kc1LQ3XrtoxYSkcwZqGAWp1Ff/IdwYfn+Kx5tNMVP5qsMiGn9Gh RI+H+A5A==; From: Adam Joseph To: supervision@list.skarnet.org Cc: Adam Joseph Subject: [PATCH] libs6rc/s6rc_graph_closure.c: add comments explaining behavior Date: Mon, 25 Sep 2023 17:41:57 -0700 Message-ID: <20230926004157.23807-1-adam@westernsemico.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - server220.web-hosting.com X-AntiAbuse: Original Domain - list.skarnet.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - westernsemico.com X-Get-Message-Sender-Via: server220.web-hosting.com: authenticated_id: westwhdn/from_h X-Authenticated-Sender: server220.web-hosting.com: adam@westernsemico.com X-Source: X-Source-Args: X-Source-Dir: X-From-Rewrite: unmodified, already matched While reviewing the algorithm implemented by s6-rc-update I found it difficult to determine the meaning of some of the arguments to the functions in libs6rc/s6rc_graph_closure.c. This commit adds comments to that file documenting those arguments and functions where their behavior was not immediately obvious to me. Signed-off-by: Adam Joseph --- src/libs6rc/s6rc_graph_closure.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/libs6rc/s6rc_graph_closure.c b/src/libs6rc/s6rc_graph_closure.c index 7c3a8f9..50af30b 100644 --- a/src/libs6rc/s6rc_graph_closure.c +++ b/src/libs6rc/s6rc_graph_closure.c @@ -11,11 +11,19 @@ struct recinfo_s s6rc_db_t const *db ; unsigned int n ; unsigned char *bits ; + /* bitarray in which the i^th bit is set iff the closure routine + has already visited the i^th graph node */ unsigned char *mark ; unsigned char mask ; unsigned char h : 1 ; } ; +/* + If the i^th graph node has *any* bit of `recinfo->mask` set then + this function will be called on each of the i^th node's + dependencies. This function will then set *every* `mask` bit on + that node and call itself recursively on that node. +*/ static void s6rc_graph_closure_rec (recinfo_t *recinfo, unsigned int i) { if (!bitarray_peek(recinfo->mark, i)) @@ -27,6 +35,11 @@ static void s6rc_graph_closure_rec (recinfo_t *recinfo, unsigned int i) } } +/* + `h` indicates whether you want a forward or reverse search. + - If `h==0` then we close over everything that the marked node *depends upon* + - If `h==1` then we close over everything that *depends upon* the marked node +*/ void s6rc_graph_closure (s6rc_db_t const *db, unsigned char *bits, unsigned int bitno, int h) { unsigned int n = db->nshort + db->nlong ; -- 2.41.0