[SLOF] [PATCH slof v2] instance: Fix set-my-args for empty arguments

Alexey Kardashevskiy aik at ozlabs.ru
Mon Aug 22 14:27:34 AEST 2016


From: Benjamin Herrenschmidt <benh at kernel.crashing.org>

It would put the pointer and len in the wrong order in the instance>args
buffer. As alloc-mem can handle zero length itself (and return NULL),
this also removes "if" to make the code simpler.

Signed-off-by: Benjamin Herrenschmidt <benh at kernel.crashing.org>
[aik: removed "if" as Segher suggested]
Signed-off-by: Alexey Kardashevskiy <aik at ozlabs.ru>
---
 slof/fs/instance.fs | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/slof/fs/instance.fs b/slof/fs/instance.fs
index 9e5c921..9159a5d 100644
--- a/slof/fs/instance.fs
+++ b/slof/fs/instance.fs
@@ -129,13 +129,9 @@ CONSTANT <instancevariable>
 
 \ copy args from original instance to new created
 : set-my-args   ( old-addr len -- )
-   dup IF                             \ IF len > 0                    ( old-addr len )
-      dup alloc-mem                   \ | allocate space for new args ( old-addr len new-addr )
-      2dup my-self instance>args 2!   \ | write into instance struct  ( old-addr len new-addr )
-      swap move                       \ | and copy the args           ( )
-   ELSE                               \ ELSE                          ( old-addr len )
-      my-self instance>args 2!        \ | set new args to zero, too   ( )
-   THEN                               \ FI
+   dup alloc-mem                   \ | allocate space for new args ( old-addr len new-addr )
+   2dup my-self instance>args 2!   \ | write into instance struct  ( old-addr len new-addr )
+   swap move                       \ | and copy the args           ( )
 ;
 
 \ Current node has already been set, when this is called.
-- 
2.5.0.rc3



More information about the SLOF mailing list