Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6df5b9f4 authored by Herbert Xu's avatar Herbert Xu
Browse files

[CRYPTO] Simplify one-member scatterlist expressions



This patch rewrites various occurences of &sg[0] where sg is an array
of length one to simply sg.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 378f058c
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -415,12 +415,12 @@ static void test_cipher(char *algo, int mode, int enc,
static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p,
static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p,
			       int blen, int sec)
			       int blen, int sec)
{
{
	struct scatterlist sg[8];
	struct scatterlist sg[1];
	unsigned long start, end;
	unsigned long start, end;
	int bcount;
	int bcount;
	int ret;
	int ret;


	sg_set_buf(&sg[0], p, blen);
	sg_set_buf(sg, p, blen);


	for (start = jiffies, end = start + sec * HZ, bcount = 0;
	for (start = jiffies, end = start + sec * HZ, bcount = 0;
	     time_before(jiffies, end); bcount++) {
	     time_before(jiffies, end); bcount++) {
@@ -441,12 +441,12 @@ static int test_cipher_jiffies(struct crypto_tfm *tfm, int enc, char *p,
static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p,
static int test_cipher_cycles(struct crypto_tfm *tfm, int enc, char *p,
			      int blen)
			      int blen)
{
{
	struct scatterlist sg[8];
	struct scatterlist sg[1];
	unsigned long cycles = 0;
	unsigned long cycles = 0;
	int ret = 0;
	int ret = 0;
	int i;
	int i;


	sg_set_buf(&sg[0], p, blen);
	sg_set_buf(sg, p, blen);


	local_bh_disable();
	local_bh_disable();
	local_irq_disable();
	local_irq_disable();
+2 −2
Original line number Original line Diff line number Diff line
@@ -1591,9 +1591,9 @@ static void emmh32_setseed(emmh32_context *context, u8 *pkey, int keylen, struct
		aes_counter[12] = (u8)(counter >> 24);
		aes_counter[12] = (u8)(counter >> 24);
		counter++;
		counter++;
		memcpy (plain, aes_counter, 16);
		memcpy (plain, aes_counter, 16);
		sg_set_buf(&sg[0], plain, 16);
		sg_set_buf(sg, plain, 16);
		crypto_cipher_encrypt(tfm, sg, sg, 16);
		crypto_cipher_encrypt(tfm, sg, sg, 16);
		cipher = kmap(sg[0].page) + sg[0].offset;
		cipher = kmap(sg->page) + sg->offset;
		for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) {
		for (j=0; (j<16) && (i< (sizeof(context->coeff)/sizeof(context->coeff[0]))); ) {
			context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
			context->coeff[i++] = ntohl(*(u32 *)&cipher[j]);
			j += 4;
			j += 4;
+2 −2
Original line number Original line Diff line number Diff line
@@ -75,7 +75,7 @@ krb5_encrypt(
		memcpy(local_iv, iv, crypto_tfm_alg_ivsize(tfm));
		memcpy(local_iv, iv, crypto_tfm_alg_ivsize(tfm));


	memcpy(out, in, length);
	memcpy(out, in, length);
	sg_set_buf(&sg[0], out, length);
	sg_set_buf(sg, out, length);


	ret = crypto_cipher_encrypt_iv(tfm, sg, sg, length, local_iv);
	ret = crypto_cipher_encrypt_iv(tfm, sg, sg, length, local_iv);


@@ -115,7 +115,7 @@ krb5_decrypt(
		memcpy(local_iv,iv, crypto_tfm_alg_ivsize(tfm));
		memcpy(local_iv,iv, crypto_tfm_alg_ivsize(tfm));


	memcpy(out, in, length);
	memcpy(out, in, length);
	sg_set_buf(&sg[0], out, length);
	sg_set_buf(sg, out, length);


	ret = crypto_cipher_decrypt_iv(tfm, sg, sg, length, local_iv);
	ret = crypto_cipher_decrypt_iv(tfm, sg, sg, length, local_iv);