diff --git a/vlib/arrays/arrays.v b/vlib/arrays/arrays.v index 23b90c7ef8..3a9eaeb778 100644 --- a/vlib/arrays/arrays.v +++ b/vlib/arrays/arrays.v @@ -544,7 +544,7 @@ fn swap_nonoverlapping(x_ &T, y_ &T, count int) { // copy copies the `src` array elements to the `dst` array. // The number of the elements copied is the minimum of the length of both arrays. // Returns the number of elements copied. -pub fn copy(dst []T, src []T) int { +pub fn copy(mut dst []T, src []T) int { min := if dst.len < src.len { dst.len } else { src.len } if min > 0 { blen := min * int(sizeof(T)) diff --git a/vlib/arrays/arrays_test.v b/vlib/arrays/arrays_test.v index dfb3f364ff..0245e8d4e6 100644 --- a/vlib/arrays/arrays_test.v +++ b/vlib/arrays/arrays_test.v @@ -268,16 +268,16 @@ fn test_rotate_left_string() { fn test_copy() { mut a := [1, 2, 3] mut b := [4, 5, 6] - assert copy(b, a) == 3 + assert copy(mut b, a) == 3 assert b == [1, 2, 3] // check independent copies b[0] = 99 assert a[0] == 1 // check longer src b << 7 - assert copy(a, b) == 3 + assert copy(mut a, b) == 3 assert a == [99, 2, 3] // check longer dst - assert copy(b, [8, 9]) == 2 + assert copy(mut b, [8, 9]) == 2 assert b == [8, 9, 3, 7] } diff --git a/vlib/builtin/array.v b/vlib/builtin/array.v index 4c7620251a..3b8bc040ca 100644 --- a/vlib/builtin/array.v +++ b/vlib/builtin/array.v @@ -816,7 +816,7 @@ pub fn (b []byte) hex() string { // Returns the number of elements copied. // NOTE: This is not an `array` method. It is a function that takes two arrays of bytes. // See also: `arrays.copy`. -pub fn copy(dst []byte, src []byte) int { +pub fn copy(mut dst []byte, src []byte) int { min := if dst.len < src.len { dst.len } else { src.len } if min > 0 { unsafe { vmemmove(&byte(dst.data), src.data, min) } diff --git a/vlib/crypto/bcrypt/bcrypt.v b/vlib/crypto/bcrypt/bcrypt.v index 4a8320d89f..8f1b13389f 100644 --- a/vlib/crypto/bcrypt/bcrypt.v +++ b/vlib/crypto/bcrypt/bcrypt.v @@ -151,13 +151,13 @@ fn (mut h Hashed) hash_byte() []byte { } arr[n] = `$` n++ - copy(arr[n..], '${int(h.cost):02}'.bytes()) + copy(mut arr[n..], '${int(h.cost):02}'.bytes()) n += 2 arr[n] = `$` n++ - copy(arr[n..], h.salt) + copy(mut arr[n..], h.salt) n += bcrypt.encoded_salt_size - copy(arr[n..], h.hash) + copy(mut arr[n..], h.hash) n += bcrypt.encoded_hash_size res := arr[..n].clone() return res diff --git a/vlib/crypto/cipher/aes_cbc_test.v b/vlib/crypto/cipher/aes_cbc_test.v index 1c5071e7c4..7c37ac5603 100644 --- a/vlib/crypto/cipher/aes_cbc_test.v +++ b/vlib/crypto/cipher/aes_cbc_test.v @@ -21,7 +21,7 @@ fn test_aes_cbc() { fn aes_cbc_en(mut src []byte, key []byte, iv []byte) { block := aes.new_cipher(key) - mode := cipher.new_cbc(block, iv) + mut mode := cipher.new_cbc(block, iv) mode.encrypt_blocks(mut src, src.clone()) } diff --git a/vlib/crypto/cipher/aes_cfb_test.v b/vlib/crypto/cipher/aes_cfb_test.v index db30e27b41..1fa7a437b2 100644 --- a/vlib/crypto/cipher/aes_cfb_test.v +++ b/vlib/crypto/cipher/aes_cfb_test.v @@ -18,7 +18,7 @@ fn test_aes_cfb() { fn aes_cfb_en(mut src []byte, key []byte, iv []byte) { block := aes.new_cipher(key) - mode := cipher.new_cfb_encrypter(block, iv) + mut mode := cipher.new_cfb_encrypter(block, iv) mode.xor_key_stream(mut src, src.clone()) } diff --git a/vlib/crypto/cipher/aes_ofb_test.v b/vlib/crypto/cipher/aes_ofb_test.v index d5bd2bf380..40e32a51f6 100644 --- a/vlib/crypto/cipher/aes_ofb_test.v +++ b/vlib/crypto/cipher/aes_ofb_test.v @@ -20,7 +20,7 @@ fn test_aes_ofb() { fn aes_ofb_en(mut src []byte, key []byte, iv []byte) { block := aes.new_cipher(key) - mode := cipher.new_ofb(block, iv) + mut mode := cipher.new_ofb(block, iv) mode.xor_key_stream(mut src, src.clone()) } diff --git a/vlib/crypto/cipher/cbc.v b/vlib/crypto/cipher/cbc.v index 45b2e87f5f..694a69923f 100644 --- a/vlib/crypto/cipher/cbc.v +++ b/vlib/crypto/cipher/cbc.v @@ -41,7 +41,7 @@ pub fn new_cbc(b Block, iv []byte) Cbc { // encrypt_blocks encrypts the blocks in `src_` to `dst_`. // Please note: `dst_` is mutable for performance reasons. -pub fn (x &Cbc) encrypt_blocks(mut dst_ []byte, src_ []byte) { +pub fn (mut x Cbc) encrypt_blocks(mut dst_ []byte, src_ []byte) { unsafe { mut dst := *dst_ mut src := src_ @@ -69,7 +69,7 @@ pub fn (x &Cbc) encrypt_blocks(mut dst_ []byte, src_ []byte) { dst = dst[x.block_size..] } // Save the iv for the next crypt_blocks call. - copy(x.iv, iv) + copy(mut x.iv, iv) } } @@ -94,7 +94,7 @@ pub fn (mut x Cbc) decrypt_blocks(mut dst []byte, src []byte) { mut start := end - x.block_size mut prev := start - x.block_size // Copy the last block of ciphertext in preparation as the new iv. - copy(x.tmp, src[start..end]) + copy(mut x.tmp, src[start..end]) // Loop over all but the first block. for start > 0 { src_chunk := src[start..end] @@ -113,9 +113,9 @@ pub fn (mut x Cbc) decrypt_blocks(mut dst []byte, src []byte) { x.tmp = x.iv } -fn (x &Cbc) set_iv(iv []byte) { +fn (mut x Cbc) set_iv(iv []byte) { if iv.len != x.iv.len { panic('cipher: incorrect length IV') } - copy(x.iv, iv) + copy(mut x.iv, iv) } diff --git a/vlib/crypto/cipher/cfb.v b/vlib/crypto/cipher/cfb.v index 6f041c6683..2c4747cd81 100644 --- a/vlib/crypto/cipher/cfb.v +++ b/vlib/crypto/cipher/cfb.v @@ -39,20 +39,18 @@ fn new_cfb(b Block, iv []byte, decrypt bool) Cfb { if iv.len != block_size { panic('cipher.new_cfb: IV length must be equal block size') } - x := Cfb{ + mut x := Cfb{ b: b out: []byte{len: b.block_size} next: []byte{len: b.block_size} out_used: block_size decrypt: decrypt } - - copy(x.next, iv) - + copy(mut x.next, iv) return x } -pub fn (x &Cfb) xor_key_stream(mut dst_ []byte, src_ []byte) { +pub fn (mut x Cfb) xor_key_stream(mut dst_ []byte, src_ []byte) { unsafe { mut dst := *dst_ mut src := src_ @@ -71,12 +69,12 @@ pub fn (x &Cfb) xor_key_stream(mut dst_ []byte, src_ []byte) { } if x.decrypt { - copy(x.next[x.out_used..], src) + copy(mut x.next[x.out_used..], src) } n := xor_bytes(mut dst, src, x.out[x.out_used..]) if !x.decrypt { - copy(x.next[x.out_used..], dst) + copy(mut x.next[x.out_used..], dst) } dst = dst[n..] src = src[n..] diff --git a/vlib/crypto/cipher/cipher.v b/vlib/crypto/cipher/cipher.v index 81db26ee71..97de4448df 100644 --- a/vlib/crypto/cipher/cipher.v +++ b/vlib/crypto/cipher/cipher.v @@ -50,6 +50,6 @@ interface BlockMode { // fn dup(p []byte) []byte { // q := make([]byte, p.len) -// copy(q, p) +// copy(mut q, p) // return q // } diff --git a/vlib/crypto/cipher/des_cbc_test.v b/vlib/crypto/cipher/des_cbc_test.v index 1640cd985f..bdc6d62852 100644 --- a/vlib/crypto/cipher/des_cbc_test.v +++ b/vlib/crypto/cipher/des_cbc_test.v @@ -31,7 +31,7 @@ fn test_des_cbc() { fn des_cbc_en(mut src []byte, key []byte, iv []byte) { block := des.new_cipher(key) - mode := cipher.new_cbc(block, iv) + mut mode := cipher.new_cbc(block, iv) mode.encrypt_blocks(mut src, src.clone()) } @@ -43,7 +43,7 @@ fn des_cbc_de(mut src []byte, key []byte, iv []byte) { fn triple_des_cbc_en(mut src []byte, key []byte, iv []byte) { block := des.new_triple_des_cipher(key) - mode := cipher.new_cbc(block, iv) + mut mode := cipher.new_cbc(block, iv) mode.encrypt_blocks(mut src, src.clone()) } diff --git a/vlib/crypto/cipher/des_cfb_test.v b/vlib/crypto/cipher/des_cfb_test.v index 0aa172b360..b5143e86e0 100644 --- a/vlib/crypto/cipher/des_cfb_test.v +++ b/vlib/crypto/cipher/des_cfb_test.v @@ -31,7 +31,7 @@ fn test_des_cfb() { fn des_cfb_en(mut src []byte, key []byte, iv []byte) { block := des.new_cipher(key) - mode := cipher.new_cfb_encrypter(block, iv) + mut mode := cipher.new_cfb_encrypter(block, iv) mode.xor_key_stream(mut src, src.clone()) } @@ -43,12 +43,12 @@ fn des_cfb_de(mut src []byte, key []byte, iv []byte) { fn triple_des_cfb_en(mut src []byte, key []byte, iv []byte) { block := des.new_triple_des_cipher(key) - mode := cipher.new_cfb_encrypter(block, iv) + mut mode := cipher.new_cfb_encrypter(block, iv) mode.xor_key_stream(mut src, src.clone()) } fn triple_des_cfb_de(mut src []byte, key []byte, iv []byte) { block := des.new_triple_des_cipher(key) - mode := cipher.new_cfb_decrypter(block, iv) + mut mode := cipher.new_cfb_decrypter(block, iv) mode.xor_key_stream(mut src, src.clone()) } diff --git a/vlib/crypto/cipher/des_ofb_test.v b/vlib/crypto/cipher/des_ofb_test.v index f01e471d85..966cfb4c11 100644 --- a/vlib/crypto/cipher/des_ofb_test.v +++ b/vlib/crypto/cipher/des_ofb_test.v @@ -31,7 +31,7 @@ fn test_des_ofb() { fn des_ofb_en(mut src []byte, key []byte, iv []byte) { block := des.new_cipher(key) - mode := cipher.new_ofb(block, iv) + mut mode := cipher.new_ofb(block, iv) mode.xor_key_stream(mut src, src.clone()) } @@ -43,7 +43,7 @@ fn des_ofb_de(mut src []byte, key []byte, iv []byte) { fn triple_des_ofb_en(mut src []byte, key []byte, iv []byte) { block := des.new_triple_des_cipher(key) - mode := cipher.new_ofb(block, iv) + mut mode := cipher.new_ofb(block, iv) mode.xor_key_stream(mut src, src.clone()) } diff --git a/vlib/crypto/cipher/ofb.v b/vlib/crypto/cipher/ofb.v index d60d064e72..eaaa1259e5 100644 --- a/vlib/crypto/cipher/ofb.v +++ b/vlib/crypto/cipher/ofb.v @@ -25,19 +25,17 @@ pub fn new_ofb(b Block, iv []byte) Ofb { if iv.len != block_size { panic('cipher.new_ofb: IV length must be equal block size') } - x := Ofb{ + mut x := Ofb{ b: b out: []byte{len: b.block_size} next: []byte{len: b.block_size} out_used: block_size } - - copy(x.next, iv) - + copy(mut x.next, iv) return x } -pub fn (x &Ofb) xor_key_stream(mut dst_ []byte, src_ []byte) { +pub fn (mut x Ofb) xor_key_stream(mut dst_ []byte, src_ []byte) { unsafe { mut dst := *dst_ mut src := src_ @@ -55,7 +53,7 @@ pub fn (x &Ofb) xor_key_stream(mut dst_ []byte, src_ []byte) { x.out_used = 0 } - copy(x.next, x.out) + copy(mut x.next, x.out) n := xor_bytes(mut dst, src, x.out) dst = dst[n..] diff --git a/vlib/crypto/ed25519/ed25519.v b/vlib/crypto/ed25519/ed25519.v index 4827c717a7..9a3c7d415c 100644 --- a/vlib/crypto/ed25519/ed25519.v +++ b/vlib/crypto/ed25519/ed25519.v @@ -32,7 +32,7 @@ pub type PrivateKey = []byte // RFC 8032's private keys correspond to seeds in this module. pub fn (priv PrivateKey) seed() []byte { mut seed := []byte{len: ed25519.seed_size} - copy(seed, priv[..32]) + copy(mut seed, priv[..32]) return seed } @@ -40,7 +40,7 @@ pub fn (priv PrivateKey) seed() []byte { pub fn (priv PrivateKey) public_key() PublicKey { assert priv.len == ed25519.private_key_size mut publickey := []byte{len: ed25519.public_key_size} - copy(publickey, priv[32..]) + copy(mut publickey, priv[32..]) return PublicKey(publickey) } @@ -62,11 +62,11 @@ pub fn (priv PrivateKey) sign(message []byte) ?[]byte { // sign`signs the message with privatekey and returns a signature pub fn sign(privatekey PrivateKey, message []byte) ?[]byte { mut signature := []byte{len: ed25519.signature_size} - sign_generic(signature, privatekey, message) ? + sign_generic(mut signature, privatekey, message) ? return signature } -fn sign_generic(signature []byte, privatekey []byte, message []byte) ? { +fn sign_generic(mut signature []byte, privatekey []byte, message []byte) ? { if privatekey.len != ed25519.private_key_size { panic('ed25519: bad private key length: $privatekey.len') } @@ -103,8 +103,8 @@ fn sign_generic(signature []byte, privatekey []byte, message []byte) ? { mut ss := edwards25519.new_scalar() ss.multiply_add(k, s, r) - copy(signature[..32], rr.bytes()) - copy(signature[32..], ss.bytes()) + copy(mut signature[..32], rr.bytes()) + copy(mut signature[32..], ss.bytes()) } // verify reports whether sig is a valid signature of message by publickey. @@ -148,8 +148,8 @@ pub fn generate_key() ?(PublicKey, PrivateKey) { mut seed := rand.bytes(ed25519.seed_size) ? privatekey := new_key_from_seed(seed) - publickey := []byte{len: ed25519.public_key_size} - copy(publickey, privatekey[32..]) + mut publickey := []byte{len: ed25519.public_key_size} + copy(mut publickey, privatekey[32..]) return publickey, privatekey } @@ -158,12 +158,12 @@ pub fn generate_key() ?(PublicKey, PrivateKey) { // correspond to seeds in this module pub fn new_key_from_seed(seed []byte) PrivateKey { // Outline the function body so that the returned key can be stack-allocated. - privatekey := []byte{len: ed25519.private_key_size} - new_key_from_seed_generic(privatekey, seed) + mut privatekey := []byte{len: ed25519.private_key_size} + new_key_from_seed_generic(mut privatekey, seed) return PrivateKey(privatekey) } -fn new_key_from_seed_generic(privatekey []byte, seed []byte) { +fn new_key_from_seed_generic(mut privatekey []byte, seed []byte) { if seed.len != ed25519.seed_size { panic('ed25519: bad seed length: $seed.len') } @@ -176,6 +176,6 @@ fn new_key_from_seed_generic(privatekey []byte, seed []byte) { mut publickey := aa.bytes() - copy(privatekey, seed) - copy(privatekey[32..], publickey) + copy(mut privatekey, seed) + copy(mut privatekey[32..], publickey) } diff --git a/vlib/crypto/ed25519/internal/ed25519_test.v b/vlib/crypto/ed25519/internal/ed25519_test.v index 98e3d38c77..412bb0a776 100644 --- a/vlib/crypto/ed25519/internal/ed25519_test.v +++ b/vlib/crypto/ed25519/internal/ed25519_test.v @@ -97,8 +97,8 @@ fn works_check_on_sign_input_string(item string) bool { sig = sig[..ed25519.signature_size] mut priv := []byte{len: ed25519.private_key_size} - copy(priv[..], privbytes) - copy(priv[32..], pubkey) + copy(mut priv[..], privbytes) + copy(mut priv[32..], pubkey) sig2 := ed25519.sign(priv[..], msg) or { panic(err.msg) } if sig != sig2[..] { @@ -182,8 +182,8 @@ fn test_input_from_djb_ed25519_crypto_sign_input_without_syncpool() ? { sig = sig[..signature_size] mut priv := []byte{len: ed25519.private_key_size} - copy(priv[..], privbytes) - copy(priv[32..], pubkey) + copy(mut priv[..], privbytes) + copy(mut priv[32..], pubkey) sig2 := ed25519.sign(priv[..], msg) ? assert sig == sig2[..] diff --git a/vlib/crypto/ed25519/internal/edwards25519/element_test.v b/vlib/crypto/ed25519/internal/edwards25519/element_test.v index 7fae269467..a0dbf43b68 100644 --- a/vlib/crypto/ed25519/internal/edwards25519/element_test.v +++ b/vlib/crypto/ed25519/internal/edwards25519/element_test.v @@ -398,7 +398,7 @@ fn test_bytes_big_equivalence() ? { mut buf := []byte{len: 32} // pad with zeroes fedtobig := fe1.to_big_integer() mut fedbig_bytes, _ := fedtobig.bytes() - copy(buf, fedbig_bytes) // does not need to do swap_endianness + copy(mut buf, fedbig_bytes) // does not need to do swap_endianness assert fe.bytes() == buf && is_in_bounds(fe) && is_in_bounds(fe1) // assert big_equivalence(inp, fe, fe1) == true diff --git a/vlib/crypto/ed25519/internal/edwards25519/point.v b/vlib/crypto/ed25519/internal/edwards25519/point.v index 3e9222dda7..4bf085d87e 100644 --- a/vlib/crypto/ed25519/internal/edwards25519/point.v +++ b/vlib/crypto/ed25519/internal/edwards25519/point.v @@ -229,7 +229,7 @@ fn (mut v Point) bytes_generic(mut buf [32]byte) []byte { fn copy_field_element(mut buf [32]byte, mut v Element) []byte { // this fail in test /* - copy(buf[..], v.bytes()) + copy(mut buf[..], v.bytes()) return buf[..] */ diff --git a/vlib/crypto/ed25519/internal/edwards25519/scalar.v b/vlib/crypto/ed25519/internal/edwards25519/scalar.v index aa1f3cc8e6..500d0c2525 100644 --- a/vlib/crypto/ed25519/internal/edwards25519/scalar.v +++ b/vlib/crypto/ed25519/internal/edwards25519/scalar.v @@ -91,7 +91,7 @@ pub fn (mut s Scalar) set_uniform_bytes(x []byte) ?Scalar { return error('edwards25519: invalid set_uniform_bytes input length') } mut wide_bytes := []byte{len: 64} - copy(wide_bytes, x) + copy(mut wide_bytes, x) // for i, item in x { // wide_bytes[i] = item //} @@ -112,7 +112,7 @@ pub fn (mut s Scalar) set_canonical_bytes(x []byte) ?Scalar { ss.s[i] = item } - //_ := copy(ss.s[..], x) //its not working + //_ := copy(mut ss.s[..], x) //its not working if !is_reduced(ss) { return error('invalid scalar encoding') } @@ -162,7 +162,7 @@ pub fn (mut s Scalar) set_bytes_with_clamping(x []byte) ?Scalar { } mut wide_bytes := []byte{len: 64, cap: 64} - copy(wide_bytes, x) + copy(mut wide_bytes, x) // for i, item in x { // wide_bytes[i] = item //} @@ -176,7 +176,7 @@ pub fn (mut s Scalar) set_bytes_with_clamping(x []byte) ?Scalar { // bytes returns the canonical 32-byte little-endian encoding of s. pub fn (mut s Scalar) bytes() []byte { mut buf := []byte{len: 32} - copy(buf, s.s[..]) + copy(mut buf, s.s[..]) return buf } @@ -1116,7 +1116,7 @@ fn generate_scalar(size int) ?Scalar { // using builtin rand.read([]buf) rand.read(mut s.s[..16]) // buf := rand.read(s.s[..16].len) ? - // copy(s.s[..16], buf) + // copy(mut s.s[..16], buf) /* for i, item in buf { @@ -1133,7 +1133,7 @@ fn generate_scalar(size int) ?Scalar { // rand.Read(s.s[:16]) rand.read(mut s.s[..16]) // buf := rand.read(s.s[..16].len) ? - // copy(s.s[..16], buf) + // copy(mut s.s[..16], buf) /* for i, item in buf { @@ -1149,7 +1149,7 @@ fn generate_scalar(size int) ?Scalar { // rand.Read(s.s[:]) rand.read(mut s.s[..]) // buf := crand.read(s.s.len) ? - // copy(s.s[..], buf) + // copy(mut s.s[..], buf) /* for i, item in buf { diff --git a/vlib/crypto/md5/md5.v b/vlib/crypto/md5/md5.v index 17ca5da6f2..496e18053f 100644 --- a/vlib/crypto/md5/md5.v +++ b/vlib/crypto/md5/md5.v @@ -58,7 +58,7 @@ pub fn (mut d Digest) write(p_ []byte) ?int { nn := p.len d.len += u64(nn) if d.nx > 0 { - n := copy(d.x[d.nx..], p) + n := copy(mut d.x[d.nx..], p) d.nx += n if d.nx == md5.block_size { block(mut d, d.x) @@ -80,7 +80,7 @@ pub fn (mut d Digest) write(p_ []byte) ?int { } } if p.len > 0 { - d.nx = copy(d.x, p) + d.nx = copy(mut d.x, p) } return nn } diff --git a/vlib/crypto/sha1/sha1.v b/vlib/crypto/sha1/sha1.v index ee606df8e5..b7a80f3af0 100644 --- a/vlib/crypto/sha1/sha1.v +++ b/vlib/crypto/sha1/sha1.v @@ -62,7 +62,7 @@ pub fn (mut d Digest) write(p_ []byte) ?int { mut p := p_ d.len += u64(nn) if d.nx > 0 { - n := copy(d.x[d.nx..], p) + n := copy(mut d.x[d.nx..], p) d.nx += n if d.nx == sha1.chunk { block(mut d, d.x) @@ -84,7 +84,7 @@ pub fn (mut d Digest) write(p_ []byte) ?int { } } if p.len > 0 { - d.nx = copy(d.x, p) + d.nx = copy(mut d.x, p) } } return nn diff --git a/vlib/crypto/sha256/sha256.v b/vlib/crypto/sha256/sha256.v index e5d391986f..76be52e314 100644 --- a/vlib/crypto/sha256/sha256.v +++ b/vlib/crypto/sha256/sha256.v @@ -96,7 +96,7 @@ pub fn (mut d Digest) write(p_ []byte) ?int { nn := p.len d.len += u64(nn) if d.nx > 0 { - n := copy(d.x[d.nx..], p) + n := copy(mut d.x[d.nx..], p) d.nx += n if d.nx == sha256.chunk { block(mut d, d.x) @@ -118,7 +118,7 @@ pub fn (mut d Digest) write(p_ []byte) ?int { } } if p.len > 0 { - d.nx = copy(d.x, p) + d.nx = copy(mut d.x, p) } return nn } @@ -191,8 +191,8 @@ pub fn sum224(data []byte) []byte { mut d := new224() d.write(data) or { panic(err) } sum := d.checksum() - sum224 := []byte{len: sha256.size224} - copy(sum224, sum[..sha256.size224]) + mut sum224 := []byte{len: sha256.size224} + copy(mut sum224, sum[..sha256.size224]) return sum224 } diff --git a/vlib/crypto/sha512/sha512.v b/vlib/crypto/sha512/sha512.v index a13c7fa65a..6a22ee7d26 100644 --- a/vlib/crypto/sha512/sha512.v +++ b/vlib/crypto/sha512/sha512.v @@ -155,7 +155,7 @@ pub fn (mut d Digest) write(p_ []byte) ?int { nn := p.len d.len += u64(nn) if d.nx > 0 { - n := copy(d.x[d.nx..], p) + n := copy(mut d.x[d.nx..], p) d.nx += n if d.nx == sha512.chunk { block(mut d, d.x) @@ -177,7 +177,7 @@ pub fn (mut d Digest) write(p_ []byte) ?int { } } if p.len > 0 { - d.nx = copy(d.x, p) + d.nx = copy(mut d.x, p) } return nn } @@ -258,8 +258,8 @@ pub fn sum384(data []byte) []byte { mut d := new_digest(.sha384) d.write(data) or { panic(err) } sum := d.checksum() - sum384 := []byte{len: sha512.size384} - copy(sum384, sum[..sha512.size384]) + mut sum384 := []byte{len: sha512.size384} + copy(mut sum384, sum[..sha512.size384]) return sum384 } @@ -268,8 +268,8 @@ pub fn sum512_224(data []byte) []byte { mut d := new_digest(.sha512_224) d.write(data) or { panic(err) } sum := d.checksum() - sum224 := []byte{len: sha512.size224} - copy(sum224, sum[..sha512.size224]) + mut sum224 := []byte{len: sha512.size224} + copy(mut sum224, sum[..sha512.size224]) return sum224 } @@ -278,8 +278,8 @@ pub fn sum512_256(data []byte) []byte { mut d := new_digest(.sha512_256) d.write(data) or { panic(err) } sum := d.checksum() - sum256 := []byte{len: sha512.size256} - copy(sum256, sum[..sha512.size256]) + mut sum256 := []byte{len: sha512.size256} + copy(mut sum256, sum[..sha512.size256]) return sum256 } diff --git a/vlib/encoding/base58/alphabet.v b/vlib/encoding/base58/alphabet.v index 44d4fc30f9..60e469e083 100644 --- a/vlib/encoding/base58/alphabet.v +++ b/vlib/encoding/base58/alphabet.v @@ -47,7 +47,7 @@ pub fn new_alphabet(str string) ?Alphabet { } mut ret := Alphabet{} - copy(ret.encode, str.bytes()) + copy(mut ret.encode, str.bytes()) mut distinct := 0 for i, b in ret.encode { diff --git a/vlib/io/buffered_reader.v b/vlib/io/buffered_reader.v index f336e2dfed..3df4128464 100644 --- a/vlib/io/buffered_reader.v +++ b/vlib/io/buffered_reader.v @@ -47,7 +47,7 @@ pub fn (mut r BufferedReader) read(mut buf []byte) ?int { return none } } - read := copy(buf, r.buf[r.offset..r.len]) + read := copy(mut buf, r.buf[r.offset..r.len]) if read == 0 { return none } diff --git a/vlib/io/custom_string_reading_test.v b/vlib/io/custom_string_reading_test.v index 76e3307395..432fcf3b30 100644 --- a/vlib/io/custom_string_reading_test.v +++ b/vlib/io/custom_string_reading_test.v @@ -19,7 +19,7 @@ fn (mut s StringReader) read(mut buf []byte) ?int { } mut howmany := imin(buf.len, s.text.len - s.place) xxx := s.text[s.place..s.place + howmany].bytes() - read := copy(buf, xxx) + read := copy(mut buf, xxx) s.place += read return read } diff --git a/vlib/io/io_test.v b/vlib/io/io_test.v index 20c949eca7..682a47a861 100644 --- a/vlib/io/io_test.v +++ b/vlib/io/io_test.v @@ -16,7 +16,7 @@ fn (mut b Buf) read(mut buf []byte) ?int { if !(b.i < b.bytes.len) { return none } - n := copy(buf, b.bytes[b.i..]) + n := copy(mut buf, b.bytes[b.i..]) b.i += n return n } diff --git a/vlib/io/reader_test.v b/vlib/io/reader_test.v index c7a2265af9..7918744228 100644 --- a/vlib/io/reader_test.v +++ b/vlib/io/reader_test.v @@ -11,7 +11,7 @@ fn (mut b Buf) read(mut buf []byte) ?int { if !(b.i < b.bytes.len) { return none } - n := copy(buf, b.bytes[b.i..]) + n := copy(mut buf, b.bytes[b.i..]) b.i += n return n } @@ -48,7 +48,7 @@ fn (mut s StringReader) read(mut buf []byte) ?int { if s.place >= s.text.len { return none } - read := copy(buf, s.text[s.place..].bytes()) + read := copy(mut buf, s.text[s.place..].bytes()) s.place += read return read } diff --git a/vlib/net/http/request_test.v b/vlib/net/http/request_test.v index 27abb35a23..ce7b92a63e 100644 --- a/vlib/net/http/request_test.v +++ b/vlib/net/http/request_test.v @@ -14,7 +14,7 @@ fn (mut s StringReader) read(mut buf []byte) ?int { } max_bytes := 100 end := if s.place + max_bytes >= s.text.len { s.text.len } else { s.place + max_bytes } - n := copy(buf, s.text[s.place..end].bytes()) + n := copy(mut buf, s.text[s.place..end].bytes()) s.place += n return n } diff --git a/vlib/net/urllib/urllib.v b/vlib/net/urllib/urllib.v index 5217703720..dc632f254f 100644 --- a/vlib/net/urllib/urllib.v +++ b/vlib/net/urllib/urllib.v @@ -274,7 +274,7 @@ fn escape(s string, mode EncodingMode) string { required := s.len + 2 * hex_count mut t := []byte{len: required} if hex_count == 0 { - copy(t, s.bytes()) + copy(mut t, s.bytes()) for i in 0 .. s.len { if s[i] == ` ` { t[i] = `+` diff --git a/vlib/v/gen/js/sourcemap/vlq/vlq_decode_test.v b/vlib/v/gen/js/sourcemap/vlq/vlq_decode_test.v index fdb4acfc51..6d188e1220 100644 --- a/vlib/v/gen/js/sourcemap/vlq/vlq_decode_test.v +++ b/vlib/v/gen/js/sourcemap/vlq/vlq_decode_test.v @@ -39,7 +39,7 @@ fn (mut b TestReader) read(mut buf []byte) ?int { if !(b.i < b.bytes.len) { return none } - n := copy(buf, b.bytes[b.i..]) + n := copy(mut buf, b.bytes[b.i..]) b.i += n return n }