[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Fri Feb 21 03:36:02 UTC 2020


The branch, master has been updated
       via  a2692b64946 lib:util: Add (PULL|PUSH)_(BE|LE)_I(8|16|32|64) byterarray macros
       via  a84c24e71de lib:util: Do not expose internal header files
       via  7ab1156b1e4 librpc:ndr: Remove byteorder.h from libndr.h
       via  5268c83a480 librpc:ndr: Use bytearray.h in ndr_basic.c
       via  fc4064eae61 lib:util: Add comments to use bytearray.h to byteorder.h
       via  83cb44dbe8a lib:util: Use (PULL|PUSH)_BE_(U16|U32|U64) for R*VAL*
       via  c3b627f476f lib:util: Use PUSH_LE_(U16|U32) for S(I|S)VALS
       via  656d293a922 lib:util: Use PUSH_LE_(U16|U32) for S(S|I)VAL
       via  b880441654c lib:util: Use PULL_LE_(U16|U32) for SVAL and IVAL
       via  841e243625b lib:util: Use _DATA_BYTE(_CONST) from bytearray.h
       via  8a87fdb4a7a lib:util: Add test to verify old and new macros are the same
       via  3d8680e6a87 lib:util: Add bytearray.h
      from  aebe427b77b smbd: Separate aio_pthread indicator from normal EINTR

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit a2692b6494626b1b0b60dd2e1b7c767c1d08fdb5
Author: Andreas Schneider <asn at samba.org>
Date:   Tue Feb 4 17:47:51 2020 +0100

    lib:util: Add (PULL|PUSH)_(BE|LE)_I(8|16|32|64) byterarray macros
    
    The only difference is that the pull macros do the correct casting of
    the integer in the end.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Fri Feb 21 03:35:58 UTC 2020 on sn-devel-184

commit a84c24e71de40c30801260561914981adc565a35
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 18 17:39:36 2019 +0100

    lib:util: Do not expose internal header files
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 7ab1156b1e409e0b2fae55dddc45c0c280d40de1
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 18 17:39:01 2019 +0100

    librpc:ndr: Remove byteorder.h from libndr.h
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 5268c83a4802d3f44850fe5b78b016682690540d
Author: Andreas Schneider <asn at samba.org>
Date:   Mon Feb 18 17:35:42 2019 +0100

    librpc:ndr: Use bytearray.h in ndr_basic.c
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit fc4064eae61ebc981d070284ceb9668642401943
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jan 17 11:00:23 2019 +0100

    lib:util: Add comments to use bytearray.h to byteorder.h
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 83cb44dbe8a4181805770195c2ef7afef72de17d
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 20 11:24:29 2018 +0100

    lib:util: Use (PULL|PUSH)_BE_(U16|U32|U64) for R*VAL*
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit c3b627f476fa1980bb4453233ce6cd5a2f53a78b
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 20 11:57:08 2018 +0100

    lib:util: Use PUSH_LE_(U16|U32) for S(I|S)VALS
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 656d293a922781413265553e0cceb19e01c3cf66
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 20 11:23:46 2018 +0100

    lib:util: Use PUSH_LE_(U16|U32) for S(S|I)VAL
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit b880441654c6d50fea4fd59061ee0cd486090073
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Dec 21 09:48:29 2018 +0100

    lib:util: Use PULL_LE_(U16|U32) for SVAL and IVAL
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 841e243625b46d5966bde59fbdc575cd70174278
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 20 11:21:00 2018 +0100

    lib:util: Use _DATA_BYTE(_CONST) from bytearray.h
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 8a87fdb4a7aec8fb4da817abbf9efe797b16fed8
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Jan 17 10:52:25 2019 +0100

    lib:util: Add test to verify old and new macros are the same
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

commit 3d8680e6a879c0c785e491a3fa78ba8ce86c2380
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Dec 20 08:37:32 2018 +0100

    lib:util: Add bytearray.h
    
    This is an implementation which doesn't have undefined behavior
    problems. It casts correctly that calculations are don in the correct
    integer space. Also the naming is less confusing than what we have in
    byteorder.h.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/util/bytearray.h                               | 124 ++++++++++
 lib/util/byteorder.h                               |  82 +++++--
 .../tests/{test_byteorder.c => test_bytearray.c}   | 142 +++++------
 lib/util/tests/test_byteorder_verify.c             | 273 +++++++++++++++++++++
 lib/util/wscript_build                             |  13 +-
 librpc/ndr/libndr.h                                |   1 -
 librpc/ndr/ndr_basic.c                             |  85 ++++---
 selftest/tests.py                                  |   4 +
 8 files changed, 601 insertions(+), 123 deletions(-)
 create mode 100644 lib/util/bytearray.h
 copy lib/util/tests/{test_byteorder.c => test_bytearray.c} (75%)
 create mode 100644 lib/util/tests/test_byteorder_verify.c


Changeset truncated at 500 lines:

diff --git a/lib/util/bytearray.h b/lib/util/bytearray.h
new file mode 100644
index 00000000000..ecab90b067d
--- /dev/null
+++ b/lib/util/bytearray.h
@@ -0,0 +1,124 @@
+/*
+ * Macros for handling integer types in byte arrays
+ *
+ * This file is originally from the libssh.org project
+ *
+ * Copyright (c) 2018 Andreas Schneider <asn at cryptomilk.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#ifndef _BYTEARRAY_H
+#define _BYTEARRAY_H
+
+#define _DATA_BYTE_CONST(data, pos) \
+    ((uint8_t)(((const uint8_t *)(data))[(pos)]))
+
+#define _DATA_BYTE(data, pos) \
+    (((uint8_t *)(data))[(pos)])
+
+/*
+ * These macros pull or push integer values from byte arrays stored in
+ * little-endian byte order.
+ */
+#define PULL_LE_U8(data, pos) \
+    (_DATA_BYTE_CONST(data, pos))
+#define PULL_LE_I8(data, pos) \
+    (int8_t)PULL_LE_U8(data, pos)
+
+#define PULL_LE_U16(data, pos) \
+    ((uint16_t)PULL_LE_U8(data, pos) | ((uint16_t)(PULL_LE_U8(data, (pos) + 1))) << 8)
+#define PULL_LE_I16(data, pos) \
+    (int16_t)PULL_LE_U16(data, pos)
+
+#define PULL_LE_U32(data, pos) \
+    ((uint32_t)(PULL_LE_U16(data, pos) | ((uint32_t)PULL_LE_U16(data, (pos) + 2)) << 16))
+#define PULL_LE_I32(data, pos) \
+    (int32_t)PULL_LE_U32(data, pos)
+
+#define PULL_LE_U64(data, pos) \
+    ((uint64_t)(PULL_LE_U32(data, pos) | ((uint64_t)PULL_LE_U32(data, (pos) + 4)) << 32))
+#define PULL_LE_I64(data, pos) \
+    (int64_t)PULL_LE_U64(data, pos)
+
+
+#define PUSH_LE_U8(data, pos, val) \
+    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
+#define PUSH_LE_I8(data, pos, val) \
+    PUSH_LE_U8(data, pos, val)
+
+#define PUSH_LE_U16(data, pos, val) \
+    (PUSH_LE_U8((data), (pos), (uint8_t)((uint16_t)(val) & 0xff)), PUSH_LE_U8((data), (pos) + 1, (uint8_t)((uint16_t)(val) >> 8)))
+#define PUSH_LE_I16(data, pos, val) \
+    PUSH_LE_U16(data, pos, val)
+
+#define PUSH_LE_U32(data, pos, val) \
+    (PUSH_LE_U16((data), (pos), (uint16_t)((uint32_t)(val) & 0xffff)), PUSH_LE_U16((data), (pos) + 2, (uint16_t)((uint32_t)(val) >> 16)))
+#define PUSH_LE_I32(data, pos, val) \
+    PUSH_LE_U32(data, pos, val)
+
+#define PUSH_LE_U64(data, pos, val) \
+    (PUSH_LE_U32((data), (pos), (uint32_t)((uint64_t)(val) & 0xffffffff)), PUSH_LE_U32((data), (pos) + 4, (uint32_t)((uint64_t)(val) >> 32)))
+#define PUSH_LE_I64(data, pos, val) \
+    PUSH_LE_U64(data, pos, val)
+
+
+
+/*
+ * These macros pull or push integer values from byte arrays stored in
+ * big-endian byte order (network byte order).
+ */
+#define PULL_BE_U8(data, pos) \
+    (_DATA_BYTE_CONST(data, pos))
+#define PULL_BE_I8(data, pos) \
+    (int8_t)PULL_BE_U8(data, pos)
+
+#define PULL_BE_U16(data, pos) \
+    ((((uint16_t)(PULL_BE_U8(data, pos))) << 8) | (uint16_t)PULL_BE_U8(data, (pos) + 1))
+#define PULL_BE_I16(data, pos) \
+    (int16_t)PULL_BE_U16(data, pos)
+
+#define PULL_BE_U32(data, pos) \
+    ((((uint32_t)PULL_BE_U16(data, pos)) << 16) | (uint32_t)(PULL_BE_U16(data, (pos) + 2)))
+#define PULL_BE_I32(data, pos) \
+    (int32_t)PULL_BE_U32(data, pos)
+
+#define PULL_BE_U64(data, pos) \
+    ((((uint64_t)PULL_BE_U32(data, pos)) << 32) | (uint64_t)(PULL_BE_U32(data, (pos) + 4)))
+#define PULL_BE_I64(data, pos) \
+    (int64_t)PULL_BE_U64(data, pos)
+
+
+
+#define PUSH_BE_U8(data, pos, val) \
+    (_DATA_BYTE(data, pos) = ((uint8_t)(val)))
+#define PUSH_BE_I8(data, pos, val) \
+    PUSH_BE_U8(data, pos, val)
+
+#define PUSH_BE_U16(data, pos, val) \
+    (PUSH_BE_U8((data), (pos), (uint8_t)(((uint16_t)(val)) >> 8)), PUSH_BE_U8((data), (pos) + 1, (uint8_t)((val) & 0xff)))
+#define PUSH_BE_I16(data, pos, val) \
+    PUSH_BE_U16(data, pos, val)
+
+#define PUSH_BE_U32(data, pos, val) \
+    (PUSH_BE_U16((data), (pos), (uint16_t)(((uint32_t)(val)) >> 16)), PUSH_BE_U16((data), (pos) + 2, (uint16_t)((val) & 0xffff)))
+#define PUSH_BE_I32(data, pos, val) \
+    PUSH_BE_U32(data, pos, val)
+
+#define PUSH_BE_U64(data, pos, val) \
+    (PUSH_BE_U32((data), (pos), (uint32_t)(((uint64_t)(val)) >> 32)), PUSH_BE_U32((data), (pos) + 4, (uint32_t)((val) & 0xffffffff)))
+#define PUSH_BE_I64(data, pos, val) \
+    PUSH_BE_U64(data, pos, val)
+
+#endif /* _BYTEARRAY_H */
diff --git a/lib/util/byteorder.h b/lib/util/byteorder.h
index d58e6d0b7d7..7f7dc7960ad 100644
--- a/lib/util/byteorder.h
+++ b/lib/util/byteorder.h
@@ -20,6 +20,8 @@
 #ifndef _BYTEORDER_H
 #define _BYTEORDER_H
 
+#include "bytearray.h"
+
 /*
    This file implements macros for machine independent short and 
    int manipulation
@@ -88,44 +90,80 @@ it also defines lots of intermediate macros, just ignore those :-)
 */
 
 
-#define CVAL(buf,pos) ((unsigned int)(((const uint8_t *)(buf))[pos]))
-#define CVAL_NC(buf,pos) (((uint8_t *)(buf))[pos]) /* Non-const version of CVAL */
+/****************************************************************************
+ *
+ * ATTENTION: Do not use those macros anymore, use the ones from bytearray.h
+ *
+ ****************************************************************************/
+
+#define CVAL(buf,pos) ((uint32_t)_DATA_BYTE_CONST(buf, pos))
+#define CVAL_NC(buf,pos) _DATA_BYTE(buf, pos) /* Non-const version of CVAL */
 #define PVAL(buf,pos) (CVAL(buf,pos))
 #define SCVAL(buf,pos,val) (CVAL_NC(buf,pos) = (val))
 
-#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
-#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
+/****************************************************************************
+ *
+ * ATTENTION: Do not use those macros anymore, use the ones from bytearray.h
+ *
+ ****************************************************************************/
+
+#define SVAL(buf,pos) (uint32_t)PULL_LE_U16(buf, pos)
+#define IVAL(buf,pos) PULL_LE_U32(buf, pos)
 #define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(uint8_t)((val)&0xFF),CVAL_NC(buf,pos+1)=(uint8_t)((val)>>8))
 #define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
 #define SVALS(buf,pos) ((int16_t)SVAL(buf,pos))
 #define IVALS(buf,pos) ((int32_t)IVAL(buf,pos))
-#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16_t)(val)))
-#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32_t)(val)))
-#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16_t)(val)))
-#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32_t)(val)))
+#define SSVAL(buf,pos,val) PUSH_LE_U16(buf, pos, val)
+#define SIVAL(buf,pos,val) PUSH_LE_U32(buf, pos, val)
+#define SSVALS(buf,pos,val) PUSH_LE_U16(buf, pos, val)
+#define SIVALS(buf,pos,val) PUSH_LE_U32(buf, pos, val)
+
+/****************************************************************************
+ *
+ * ATTENTION: Do not use those macros anymore, use the ones from bytearray.h
+ *
+ ****************************************************************************/
 
 /* 64 bit macros */
-#define BVAL(p, ofs) (IVAL(p,ofs) | (((uint64_t)IVAL(p,(ofs)+4)) << 32))
+#define BVAL(p, ofs) PULL_LE_U64(p, ofs)
 #define BVALS(p, ofs) ((int64_t)BVAL(p,ofs))
-#define SBVAL(p, ofs, v) (SIVAL(p,ofs,(v)&0xFFFFFFFF), SIVAL(p,(ofs)+4,((uint64_t)(v))>>32))
+#define SBVAL(p, ofs, v) PUSH_LE_U64(p, ofs, v)
 #define SBVALS(p, ofs, v) (SBVAL(p,ofs,(uint64_t)v))
 
+/****************************************************************************
+ *
+ * ATTENTION: Do not use those macros anymore, use the ones from bytearray.h
+ *
+ ****************************************************************************/
+
 /* now the reverse routines - these are used in nmb packets (mostly) */
 #define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
 #define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
 #define BREV(x) ((IREV((uint64_t)x)<<32) | (IREV(((uint64_t)x)>>32)))
 
-#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
-#define RSVALS(buf,pos) SREV(SVALS(buf,pos))
-#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
-#define RIVALS(buf,pos) IREV(IVALS(buf,pos))
-#define RBVAL(buf,pos) BREV(BVAL(buf,pos))
-#define RBVALS(buf,pos) BREV(BVALS(buf,pos))
-#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
-#define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val))
-#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
-#define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val))
-#define RSBVAL(buf,pos,val) SBVAL(buf,pos,BREV(val))
-#define RSBVALS(buf,pos,val) SBVALS(buf,pos,BREV(val))
+/****************************************************************************
+ *
+ * ATTENTION: Do not use those macros anymore, use the ones from bytearray.h
+ *
+ ****************************************************************************/
+
+#define RSVAL(buf,pos) (uint32_t)PULL_BE_U16(buf, pos)
+#define RSVALS(buf,pos) PULL_BE_U16(buf, pos)
+#define RIVAL(buf,pos) PULL_BE_U32(buf, pos)
+#define RIVALS(buf,pos) PULL_BE_U32(buf, pos)
+#define RBVAL(buf,pos) PULL_BE_U64(buf, pos)
+#define RBVALS(buf,pos) PULL_BE_U64(buf, pos)
+#define RSSVAL(buf,pos,val) PUSH_BE_U16(buf, pos, val)
+#define RSSVALS(buf,pos,val) PUSH_BE_U16(buf, pos, val)
+#define RSIVAL(buf,pos,val) PUSH_BE_U32(buf, pos, val)
+#define RSIVALS(buf,pos,val) PUSH_BE_U32(buf, pos, val)
+#define RSBVAL(buf,pos,val) PUSH_BE_U64(buf, pos, val)
+#define RSBVALS(buf,pos,val) PUSH_BE_U64(buf, pos, val)
+
+/****************************************************************************
+ *
+ * ATTENTION: Do not use those macros anymore, use the ones from bytearray.h
+ *
+ ****************************************************************************/
 
 #endif /* _BYTEORDER_H */
diff --git a/lib/util/tests/test_byteorder.c b/lib/util/tests/test_bytearray.c
similarity index 75%
copy from lib/util/tests/test_byteorder.c
copy to lib/util/tests/test_bytearray.c
index 9faa0380826..fcf63d8226f 100644
--- a/lib/util/tests/test_byteorder.c
+++ b/lib/util/tests/test_bytearray.c
@@ -24,7 +24,7 @@
 #include <cmocka.h>
 
 #include "lib/replace/replace.h"
-#include "lib/util/byteorder.h"
+#include "lib/util/bytearray.h"
 
 static void torture_pull_le_u8(void **state)
 {
@@ -33,24 +33,24 @@ static void torture_pull_le_u8(void **state)
 
 	(void)state;
 
-	result = CVAL(data, 0);
+	result = PULL_LE_U8(data, 0);
 	assert_int_equal(result, 0);
 
 	data[0] = 0x2a;
-	result = CVAL(data, 0);
+	result = PULL_LE_U8(data, 0);
 	assert_int_equal(result, 42);
 
 
 	data[0] = 0xf;
-	result = CVAL(data, 0);
+	result = PULL_LE_U8(data, 0);
 	assert_int_equal(result, 0xf);
 
 	data[0] = 0xff;
-	result = CVAL(data, 0);
+	result = PULL_LE_U8(data, 0);
 	assert_int_equal(result, 0xff);
 
 	data[1] = 0x2a;
-	result = CVAL(data, 1);
+	result = PULL_LE_U8(data, 1);
 	assert_int_equal(result, 42);
 }
 
@@ -61,27 +61,27 @@ static void torture_pull_le_u16(void **state)
 
 	(void)state;
 
-	result = SVAL(data, 0);
+	result = PULL_LE_U16(data, 0);
 	assert_int_equal(result, 0);
 
 	data[0] = 0x2a;
 	data[1] = 0x00;
-	result = SVAL(data, 0);
+	result = PULL_LE_U16(data, 0);
 	assert_int_equal(result, 42);
 
 	data[0] = 0xff;
 	data[1] = 0x00;
-	result = SVAL(data, 0);
+	result = PULL_LE_U16(data, 0);
 	assert_int_equal(result, 0x00ff);
 
 	data[0] = 0x00;
 	data[1] = 0xff;
-	result = SVAL(data, 0);
+	result = PULL_LE_U16(data, 0);
 	assert_int_equal(result, 0xff00);
 
 	data[0] = 0xff;
 	data[1] = 0xff;
-	result = SVAL(data, 0);
+	result = PULL_LE_U16(data, 0);
 	assert_int_equal(result, 0xffff);
 }
 
@@ -92,49 +92,49 @@ static void torture_pull_le_u32(void **state)
 
 	(void)state;
 
-	result = IVAL(data, 0);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 0);
 
 	data[0] = 0x2a;
 	data[1] = 0x00;
 	data[2] = 0x00;
 	data[3] = 0x00;
-	result = IVAL(data, 0);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 42);
 
 	data[0] = 0xff;
 	data[1] = 0x00;
 	data[2] = 0x00;
 	data[3] = 0x00;
-	result = IVAL(data, 0);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 0x00ff);
 
 	data[0] = 0x00;
 	data[1] = 0xff;
 	data[2] = 0x00;
 	data[3] = 0x00;
-	result = IVAL(data, 0);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 0xff00);
 
 	data[0] = 0x00;
 	data[1] = 0x00;
 	data[2] = 0xff;
 	data[3] = 0x00;
-	result = IVAL(data, 0);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 0xff0000);
 
 	data[0] = 0x00;
 	data[1] = 0x00;
 	data[2] = 0x00;
 	data[3] = 0xff;
-	result = IVAL(data, 0);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 0xff000000);
 
 	data[0] = 0xff;
 	data[1] = 0xff;
 	data[2] = 0xff;
 	data[3] = 0xff;
-	result = IVAL(data, 0);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 0xffffffff);
 }
 
@@ -145,10 +145,10 @@ static void torture_push_le_u8(void **state)
 
 	(void)state;
 
-	SCVAL(data, 0, 42);
-	SCVAL(data, 1, 42);
-	SCVAL(data, 2, 42);
-	SCVAL(data, 3, 42);
+	PUSH_LE_U8(data, 0, 42);
+	PUSH_LE_U8(data, 1, 42);
+	PUSH_LE_U8(data, 2, 42);
+	PUSH_LE_U8(data, 3, 42);
 	assert_memory_equal(data, data2, sizeof(data));
 }
 
@@ -160,14 +160,14 @@ static void torture_push_le_u16(void **state)
 
 	(void)state;
 
-	SSVALX(data, 0, 32678);
-	SSVALX(data, 2, 42);
+	PUSH_LE_U16(data, 0, 32678);
+	PUSH_LE_U16(data, 2, 42);
 	assert_memory_equal(data, data2, sizeof(data));
 
-	result = SVAL(data, 2);
+	result = PULL_LE_U16(data, 2);
 	assert_int_equal(result, 42);
 
-	result = SVAL(data, 0);
+	result = PULL_LE_U16(data, 0);
 	assert_int_equal(result, 32678);
 }
 
@@ -179,18 +179,18 @@ static void torture_push_le_u32(void **state)
 
 	(void)state;
 
-	SIVALX(data, 0, 32678);
-	SIVALX(data, 4, 42);
+	PUSH_LE_U32(data, 0, 32678);
+	PUSH_LE_U32(data, 4, 42);
 	assert_memory_equal(data, data2, sizeof(data));
 
-	result = IVAL(data, 4);
+	result = PULL_LE_U32(data, 4);
 	assert_int_equal(result, 42);
 
-	result = IVAL(data, 0);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 32678);
 
-	SIVALX(data, 0, 0xfffefffe);
-	result = IVAL(data, 0);
+	PUSH_LE_U32(data, 0, 0xfffefffe);
+	result = PULL_LE_U32(data, 0);
 	assert_int_equal(result, 0xfffefffe);
 }
 
@@ -201,14 +201,14 @@ static void torture_push_le_u64(void **state)
 
 	(void)state;
 
-	SBVAL(data, 0, 32678);
+	PUSH_LE_U64(data, 0, 32678);
 
-	result = BVAL(data, 0);
+	result = PULL_LE_U64(data, 0);
 	assert_int_equal(result, 32678);
 
-	SBVAL(data, 0, 0xfffefffefffefffeUL);
+	PUSH_LE_U64(data, 0, 0xfffefffefffefffeUL);
 
-	result = BVAL(data, 0);
+	result = PULL_LE_U64(data, 0);
 	assert_int_equal(result, 0xfffefffefffefffeUL);
 }
 
@@ -221,24 +221,24 @@ static void torture_pull_be_u8(void **state)
 
 	(void)state;
 
-	result = CVAL(data, 0);
+	result = PULL_BE_U8(data, 0);
 	assert_int_equal(result, 0);
 
 	data[0] = 0x2a;
-	result = CVAL(data, 0);
+	result = PULL_BE_U8(data, 0);
 	assert_int_equal(result, 42);
 
 
 	data[0] = 0xf;
-	result = CVAL(data, 0);
+	result = PULL_BE_U8(data, 0);
 	assert_int_equal(result, 0xf);
 
 	data[0] = 0xff;
-	result = CVAL(data, 0);
+	result = PULL_BE_U8(data, 0);
 	assert_int_equal(result, 0xff);
 
 	data[1] = 0x2a;
-	result = CVAL(data, 1);
+	result = PULL_BE_U8(data, 1);
 	assert_int_equal(result, 42);
 }
 
@@ -249,27 +249,27 @@ static void torture_pull_be_u16(void **state)
 
 	(void)state;
 
-	result = RSVAL(data, 0);
+	result = PULL_BE_U16(data, 0);
 	assert_int_equal(result, 0);
 
 	data[0] = 0x00;
 	data[1] = 0x2a;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list