mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
check unused and unmodified vars in all modules, not just main
This commit is contained in:
@@ -11,7 +11,7 @@ import (
|
||||
crypto.internal.subtle
|
||||
)
|
||||
|
||||
const (
|
||||
pub const (
|
||||
// The AES block size in bytes.
|
||||
block_size = 16
|
||||
)
|
||||
|
||||
@@ -48,7 +48,7 @@ pub fn new_cbc(b AesCipher, iv []byte) AesCbc {
|
||||
|
||||
pub fn (x &AesCbc) block_size() int { return x.block_size }
|
||||
|
||||
pub fn (x mut AesCbc) encrypt_blocks(dst mut []byte, src_ []byte) {
|
||||
pub fn (x &AesCbc) encrypt_blocks(dst mut []byte, src_ []byte) {
|
||||
mut src := src_
|
||||
if src.len%x.block_size != 0 {
|
||||
panic('crypto.cipher: input not full blocks')
|
||||
@@ -124,7 +124,7 @@ pub fn (x mut AesCbc) decrypt_blocks(dst mut []byte, src []byte) {
|
||||
x.tmp = x.iv
|
||||
}
|
||||
|
||||
fn (x mut AesCbc) set_iv(iv []byte) {
|
||||
fn (x &AesCbc) set_iv(iv []byte) {
|
||||
if iv.len != x.iv.len {
|
||||
panic('cipher: incorrect length IV')
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ fn test_crypto_aes() {
|
||||
if ciphertext.len%aes.block_size != 0 {
|
||||
panic('ciphertext is not a multiple of the block size')
|
||||
}
|
||||
mut mode := aes.new_cbc(block, iv)
|
||||
mode := aes.new_cbc(block, iv)
|
||||
mode.encrypt_blocks(mut ciphertext, ciphertext)
|
||||
|
||||
assert ciphertext.hex() == 'c210459b514668ddc44674885e4979215265a6c44431a248421254ef357a8c2a308a8bddf5623af9df91737562041cf1'
|
||||
|
||||
@@ -14,7 +14,7 @@ module md5
|
||||
|
||||
import encoding.binary
|
||||
|
||||
const (
|
||||
pub const (
|
||||
// The size of an MD5 checksum in bytes.
|
||||
size = 16
|
||||
// The blocksize of MD5 in bytes.
|
||||
|
||||
@@ -14,7 +14,7 @@ module sha1
|
||||
|
||||
import encoding.binary
|
||||
|
||||
const(
|
||||
pub const(
|
||||
// The size of a SHA-1 checksum in bytes.
|
||||
size = 20
|
||||
// The blocksize of SHA-1 in bytes.
|
||||
|
||||
@@ -12,7 +12,7 @@ module sha256
|
||||
|
||||
import encoding.binary
|
||||
|
||||
const (
|
||||
pub const (
|
||||
// The size of a SHA256 checksum in bytes.
|
||||
size = 32
|
||||
// The size of a SHA224 checksum in bytes.
|
||||
@@ -194,7 +194,7 @@ pub fn sum224(data []byte) []byte {
|
||||
mut d := new224()
|
||||
d.write(data)
|
||||
sum := d.checksum()
|
||||
mut sum224 := [byte(0)].repeat(size224)
|
||||
sum224 := [byte(0)].repeat(size224)
|
||||
copy(sum224, sum[..size224])
|
||||
return sum224
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
encoding.binary
|
||||
)
|
||||
|
||||
const (
|
||||
pub const (
|
||||
// size is the size, in bytes, of a SHA-512 checksum.
|
||||
size = 64
|
||||
// size224 is the size, in bytes, of a SHA-512/224 checksum.
|
||||
@@ -183,7 +183,7 @@ fn (d mut Digest) write(p_ []byte) int {
|
||||
return nn
|
||||
}
|
||||
|
||||
fn (d mut Digest) sum(b_in []byte) []byte {
|
||||
fn (d &Digest) sum(b_in []byte) []byte {
|
||||
// Make a copy of d so that caller can keep writing and summing.
|
||||
mut d0 := *d
|
||||
hash := d0.checksum()
|
||||
@@ -237,7 +237,7 @@ fn (d mut Digest) checksum() []byte {
|
||||
}
|
||||
|
||||
mut digest := [byte(0)].repeat(size)
|
||||
|
||||
|
||||
binary.big_endian_put_u64(mut digest, d.h[0])
|
||||
binary.big_endian_put_u64(mut digest[8..], d.h[1])
|
||||
binary.big_endian_put_u64(mut digest[16..], d.h[2])
|
||||
@@ -264,7 +264,7 @@ pub fn sum384(data []byte) []byte {
|
||||
mut d := new_digest(.sha384)
|
||||
d.write(data)
|
||||
sum := d.checksum()
|
||||
mut sum384 := [byte(0)].repeat(size384)
|
||||
sum384 := [byte(0)].repeat(size384)
|
||||
copy(sum384, sum[..size384])
|
||||
return sum384
|
||||
}
|
||||
@@ -274,7 +274,7 @@ pub fn sum512_224(data []byte) []byte {
|
||||
mut d := new_digest(.sha512_224)
|
||||
d.write(data)
|
||||
sum := d.checksum()
|
||||
mut sum224 := [byte(0)].repeat(size224)
|
||||
sum224 := [byte(0)].repeat(size224)
|
||||
copy(sum224, sum[..size224])
|
||||
return sum224
|
||||
}
|
||||
@@ -284,7 +284,7 @@ pub fn sum512_256(data []byte) []byte {
|
||||
mut d := new_digest(.sha512_256)
|
||||
d.write(data)
|
||||
sum := d.checksum()
|
||||
mut sum256 := [byte(0)].repeat(size256)
|
||||
sum256 := [byte(0)].repeat(size256)
|
||||
copy(sum256, sum[..size256])
|
||||
return sum256
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user