gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-scheme] 120/324: netstruct syntactic: Fix error when field is co


From: gnunet
Subject: [gnunet-scheme] 120/324: netstruct syntactic: Fix error when field is constant.
Date: Tue, 21 Sep 2021 13:22:40 +0200

This is an automated email from the git hooks/post-receive script.

maxime-devos pushed a commit to branch master
in repository gnunet-scheme.

commit f7b4ce0889d4c7cbacd6649717d8c6568f4d3cd9
Author: Maxime Devos <maximedevos@telenet.be>
AuthorDate: Sat May 29 19:31:24 2021 +0200

    netstruct syntactic: Fix error when field is constant.
    
    Previously, the code tried to look up fields named
    (static . the-field). Let's fix resulting errors during
    expansion.
    
    * gnu/gnunet/netstruct/syntactic.scm
      (offset+sizeof/partial-tree): Remove 'static from the leading
      static (constant) fields.
    * tests/netstruct.scm
      ("total size (syntactic, constant, one field)")
      ("field size (syntactic, constant, one field)"): Add two tests
      that detect the bug.
---
 gnu/gnunet/netstruct/syntactic.scm |  9 ++++++---
 tests/netstruct.scm                | 14 +++++++++++++-
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/gnu/gnunet/netstruct/syntactic.scm 
b/gnu/gnunet/netstruct/syntactic.scm
index 85120a5..57366ac 100644
--- a/gnu/gnunet/netstruct/syntactic.scm
+++ b/gnu/gnunet/netstruct/syntactic.scm
@@ -198,11 +198,14 @@ syntax"
        (eq? (car field) 'static))
       (receive (static partially-dynamic)
          (span static? fields)
-       (let ((off (p@offsetof ns static))
-             (p   (p@part ns static)))
+       ;; Remove the @code{static} symbol from the car,
+       ;; leaving only the field names in @var{static}.
+       (let* ((static* (map cdr fields))
+              (off (p@offsetof ns static*))
+              (p (p@part ns static*)))
          (if (null? partially-dynamic)
              (values (datum->syntax s off)
-                     (datum->syntax s (p@sizeof ns static))
+                     (datum->syntax s (p@sizeof ns static*))
                      #'#t
                      #f
                      ns)
diff --git a/tests/netstruct.scm b/tests/netstruct.scm
index 5a2bca8..d4edeaf 100644
--- a/tests/netstruct.scm
+++ b/tests/netstruct.scm
@@ -16,7 +16,8 @@
 ;;
 ;; SPDX-License-Identifier: AGPL3.0-or-later
 (import (srfi srfi-26)
-       (gnu gnunet netstruct procedural))
+       (gnu gnunet netstruct procedural)
+       (prefix (gnu gnunet netstruct syntactic) s:))
 
 (test-begin "netstruct procedural")
 
@@ -29,3 +30,14 @@
   (offsetof struct/a '(field)))
 
 (test-end "netstruct procedural")
+(test-begin "nestruct syntactic")
+
+(test-eqv "total size (syntactic, constant, one field)"
+  1 (eval '(s:sizeof struct/a '())
+         (current-module)))
+
+(test-eqv "field size (syntactic, constant, one field)"
+  1 (eval '(s:sizeof struct/a '(field))
+         (current-module)))
+
+(test-end "nestruct syntactic")

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]