From 03258db26dfe57014cbdfbc312330a622038f4e9 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 27 Sep 2020 11:18:55 +0300 Subject: [PATCH] ci: other mut vlib test fixes --- vlib/crypto/aes/aes_cbc.v | 6 ++++-- vlib/crypto/rc4/rc4_test.v | 2 +- vlib/os/os_test.v | 2 +- vlib/sync/channel_polling_test.v | 6 +++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/vlib/crypto/aes/aes_cbc.v b/vlib/crypto/aes/aes_cbc.v index 811430cdb6..8d24d0abcb 100644 --- a/vlib/crypto/aes/aes_cbc.v +++ b/vlib/crypto/aes/aes_cbc.v @@ -105,7 +105,8 @@ pub fn (mut x AesCbc) decrypt_blocks(mut dst []byte, src []byte) { // Loop over all but the first block. for start > 0 { - x.b.decrypt(mut (*dst).slice(start, end), mut src.slice(start, end)) + mut src_chunk := src.slice(start, end) + x.b.decrypt(mut (*dst).slice(start, end), mut src_chunk) cipher.xor_bytes(mut (*dst).slice(start, end), (*dst).slice(start, end), src.slice(prev, start)) end = start @@ -114,7 +115,8 @@ pub fn (mut x AesCbc) decrypt_blocks(mut dst []byte, src []byte) { } // The first block is special because it uses the saved iv. - x.b.decrypt(mut (*dst).slice(start, end), mut src.slice(start, end)) + mut src_chunk := src.slice(start, end) + x.b.decrypt(mut (*dst).slice(start, end), mut src_chunk) cipher.xor_bytes(mut (*dst).slice(start, end), (*dst).slice(start, end), x.iv) diff --git a/vlib/crypto/rc4/rc4_test.v b/vlib/crypto/rc4/rc4_test.v index ce85072e98..1ede6ef4ac 100644 --- a/vlib/crypto/rc4/rc4_test.v +++ b/vlib/crypto/rc4/rc4_test.v @@ -15,7 +15,7 @@ fn test_crypto_rc4() { mut src := 'toencrypt'.bytes() // src & dst same, encrypt in place - c.xor_key_stream(mut src, src) // encrypt data + c.xor_key_stream(mut src, mut src) // encrypt data c.reset() diff --git a/vlib/os/os_test.v b/vlib/os/os_test.v index b97a4171ca..9e8b1a9de1 100644 --- a/vlib/os/os_test.v +++ b/vlib/os/os_test.v @@ -165,7 +165,7 @@ fn test_write_and_read_bytes() { assert rbytes == payload // check that trying to read data from EOF doesn't error and returns 0 mut a := []byte{len: 5} - nread := file_read.read_bytes_into(5, a) or { + nread := file_read.read_bytes_into(5, mut a) or { eprintln(err) int(-1) } diff --git a/vlib/sync/channel_polling_test.v b/vlib/sync/channel_polling_test.v index 879352eab7..731e7cdb69 100755 --- a/vlib/sync/channel_polling_test.v +++ b/vlib/sync/channel_polling_test.v @@ -18,7 +18,7 @@ fn do_rec(ch chan int, resch chan i64, n int) { mut sum := i64(0) for _ in 0 .. n { mut r := 0 - for ch.try_pop(mut r) != .success {} + for ch.try_pop(r) != .success {} sum += r } println(sum) @@ -34,11 +34,11 @@ fn do_send(ch chan int, start, end int) { fn test_channel_polling() { ch := chan int{cap: buflen} resch := chan i64{} - for i in 0 .. nrec { + for _ in 0 .. nrec { go do_rec(ch, resch, objs_per_thread) } mut n := nobj - for i in 0 .. nsend { + for _ in 0 .. nsend { end := n n -= objs_per_thread go do_send(ch, n, end)