git: 503b7f94d831 - main - tree.3: the example code fixed

From: Maxim Konovalov <maxim_at_FreeBSD.org>
Date: Sat, 03 Aug 2024 19:46:42 UTC
The branch main has been updated by maxim:

URL: https://cgit.FreeBSD.org/src/commit/?id=503b7f94d831642308585c980a7cabe4470960d0

commit 503b7f94d831642308585c980a7cabe4470960d0
Author:     Maxim Konovalov <maxim@FreeBSD.org>
AuthorDate: 2024-08-03 19:45:47 +0000
Commit:     Maxim Konovalov <maxim@FreeBSD.org>
CommitDate: 2024-08-03 19:45:47 +0000

    tree.3: the example code fixed
    
    PR:             280566
    Reviewed by:    dougm
---
 share/man/man3/tree.3 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/share/man/man3/tree.3 b/share/man/man3/tree.3
index e6d855c5ade0..83d005a5e481 100644
--- a/share/man/man3/tree.3
+++ b/share/man/man3/tree.3
@@ -28,7 +28,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 27, 2020
+.Dd August 2, 2024
 .Dt TREE 3
 .Os
 .Sh NAME
@@ -675,6 +675,8 @@ To maintain the sum of the values in the tree, each element maintains
 the sum of its value and the sums from its left and right subtrees.
 Lastly, the internal structure of the tree is printed.
 .Bd -literal -offset 3n
+#define RB_AUGMENT(entry) sumaug(entry)
+
 #include <sys/tree.h>
 #include <err.h>
 #include <stdio.h>
@@ -691,7 +693,7 @@ intcmp(struct node *e1, struct node *e2)
 	return (e1->i < e2->i ? -1 : e1->i > e2->i);
 }
 
-int
+void
 sumaug(struct node *e)
 {
 	e->sum = e->i;
@@ -700,7 +702,6 @@ sumaug(struct node *e)
 	if (RB_RIGHT(e, entry) != NULL)
 		e->sum += RB_RIGHT(e, entry)->sum;
 }
-#define RB_AUGMENT(entry) sumaug(entry)
 
 RB_HEAD(inttree, node) head = RB_INITIALIZER(&head);
 RB_GENERATE(inttree, node, entry, intcmp)
@@ -749,8 +750,7 @@ main(void)
 		printf("%d\en", n->i);
 	}
 	print_tree(RB_ROOT(&head));
-	printf("Sum of values = %d\n", RB_ROOT(&head)->sum);
-	printf("\en");
+	printf("\enSum of values = %d\en", RB_ROOT(&head)->sum);
 	return (0);
 }
 .Ed