Skip to contentSkip to conversation

crypto: add missing KERN_* constants to printks

PATCH Superseded Frank Seidel 4 participants 9 messages Feb 6, 2009 – Feb 10, 2009 Crypto API

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: add missing KERN_* constants to printks

From: Frank Seidel <[email protected]>

According to kerneljanitors todo list all printk calls (beginning a new line) should have an according KERN_* constant. Those are the missing pieces here for the crypto subsystem.

---
 crypto/ansi_cprng.c |    2 +-
 crypto/tcrypt.c     |   48 +++++++++++++++++++++++++++---------------------
 2 files changed, 28 insertions(+), 22 deletions(-)
crypto/tcrypt.c +27 -21
@@ -74,7 +74,7 @@ static int test_cipher_jiffies(struct bl
 			return ret;
 	}
 
-	printk("%d operations in %d seconds (%ld bytes)\n",
+	printk(KERN_WARNING "%d operations in %d seconds (%ld bytes)\n",
 	       bcount, sec, (long)bcount * blen);
 	return 0;
 }
@@ -122,7 +122,7 @@ out:
 	local_bh_enable();
 
 	if (ret == 0)
-		printk("1 operation in %lu cycles (%d bytes)\n",
+		printk(KERN_WARNING "1 operation in %lu cycles (%d bytes)\n",
 		       (cycles + 4) / 8, blen);
 
 	return ret;
@@ -146,13 +146,13 @@ static void test_cipher_speed(const char
 	else
 		e = "decryption";
 
-	printk("\ntesting speed of %s %s\n", algo, e);
+	printk(KERN_WARNING "\ntesting speed of %s %s\n", algo, e);
 
 	tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC);
 
 	if (IS_ERR(tfm)) {
-		printk("failed to load transform for %s: %ld\n", algo,
-		       PTR_ERR(tfm));
+		printk(KERN_WARNING "failed to load transform for %s: %ld\n",
+		       algo, PTR_ERR(tfm));
 		return;
 	}
 	desc.tfm = tfm;
@@ -166,14 +166,16 @@ static void test_cipher_speed(const char
 			struct scatterlist sg[TVMEMSIZE];
 
 			if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
-				printk("template (%u) too big for "
+				printk(KERN_WARNING
+				       "template (%u) too big for "
 				       "tvmem (%lu)\n", *keysize + *b_size,
 				       TVMEMSIZE * PAGE_SIZE);
 				goto out;
 			}
 
-			printk("test %u (%d bit key, %d byte blocks): ", i,
-					*keysize * 8, *b_size);
+			printk(KERN_WARNING
+					"test %u (%d bit key, %d byte blocks): ",
+					i, *keysize * 8, *b_size);
 
 			memset(tvmem[0], 0xff, PAGE_SIZE);
 
@@ -188,7 +190,8 @@ static void test_cipher_speed(const char
 
 			ret = crypto_blkcipher_setkey(tfm, key, *keysize);
 			if (ret) {
-				printk("setkey() failed flags=%x\n",
+				printk(KERN_WARNING
+						"setkey() failed flags=%x\n",
 						crypto_blkcipher_get_flags(tfm));
 				goto out;
 			}
@@ -215,7 +218,8 @@ static void test_cipher_speed(const char
 							 *b_size);
 
 			if (ret) {
-				printk("%s() failed flags=%x\n", e, desc.flags);
+				printk(KERN_WARNING "%s() failed flags=%x\n",
+				       e, desc.flags);
 				break;
 			}
 			b_size++;
@@ -243,7 +247,7 @@ static int test_hash_jiffies_digest(stru
 			return ret;
 	}
 
-	printk("%6u opers/sec, %9lu bytes/sec\n",
+	printk(KERN_WARNING "%6u opers/sec, %9lu bytes/sec\n",
 	       bcount / sec, ((long)bcount * blen) / sec);
 
 	return 0;
@@ -275,7 +279,7 @@ static int test_hash_jiffies(struct hash
 			return ret;
 	}
 
-	printk("%6u opers/sec, %9lu bytes/sec\n",
+	printk(KERN_WARNING "%6u opers/sec, %9lu bytes/sec\n",
 	       bcount / sec, ((long)bcount * blen) / sec);
 
 	return 0;
@@ -320,7 +324,7 @@ out:
 	if (ret)
 		return ret;
 
-	printk("%6lu cycles/operation, %4lu cycles/byte\n",
+	printk(KERN_WARNING "%6lu cycles/operation, %4lu cycles/byte\n",
 	       cycles / 8, cycles / (8 * blen));
 
 	return 0;
@@ -384,7 +388,7 @@ out:
 	if (ret)
 		return ret;
 
-	printk("%6lu cycles/operation, %4lu cycles/byte\n",
+	printk(KERN_WARNING "%6lu cycles/operation, %4lu cycles/byte\n",
 	       cycles / 8, cycles / (8 * blen));
 
 	return 0;
@@ -400,13 +404,13 @@ static void test_hash_speed(const char *
 	int i;
 	int ret;
 
-	printk("\ntesting speed of %s\n", algo);
+	printk(KERN_WARNING "\ntesting speed of %s\n", algo);
 
 	tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
 
 	if (IS_ERR(tfm)) {
-		printk("failed to load transform for %s: %ld\n", algo,
-		       PTR_ERR(tfm));
+		printk(KERN_WARNING "failed to load transform for %s: %ld\n",
+		       algo, PTR_ERR(tfm));
 		return;
 	}
 
@@ -414,7 +418,7 @@ static void test_hash_speed(const char *
 	desc.flags = 0;
 
 	if (crypto_hash_digestsize(tfm) > sizeof(output)) {
-		printk("digestsize(%u) > outputbuffer(%zu)\n",
+		printk(KERN_WARNING "digestsize(%u) > outputbuffer(%zu)\n",
 		       crypto_hash_digestsize(tfm), sizeof(output));
 		goto out;
 	}
@@ -427,12 +431,14 @@ static void test_hash_speed(const char *
 
 	for (i = 0; speed[i].blen != 0; i++) {
 		if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
-			printk("template (%u) too big for tvmem (%lu)\n",
+			printk(KERN_WARNING
+			       "template (%u) too big for tvmem (%lu)\n",
 			       speed[i].blen, TVMEMSIZE * PAGE_SIZE);
 			goto out;
 		}
 
-		printk("test%3u (%5u byte blocks,%5u bytes per update,%4u updates): ",
+		printk(KERN_WARNING
+		       "test%3u (%5u byte blocks,%5u bytes per update,%4u updates): ",
 		       i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
 
 		if (sec)
@@ -443,7 +449,7 @@ static void test_hash_speed(const char *
 					       speed[i].plen, output);
 
 		if (ret) {
-			printk("hashing failed ret=%d\n", ret);
+			printk(KERN_WARNING "hashing failed ret=%d\n", ret);
 			break;
 		}
 	}
crypto/ansi_cprng.c +1 -1
@@ -167,7 +167,7 @@ static int _get_more_prng_bytes(struct p
 			break;
 	}
 
-	dbgprint("Returning new block for context %p\n", ctx);
+	dbgprint(KERN_WARNING "Returning new block for context %p\n", ctx);
 	ctx->rand_data_valid = 0;
 
 	hexdump("Output DT: ", ctx->DT, DEFAULT_BLK_SZ);
#1 lore raw
Quoted 2 lines · Frank Seidel

According to kerneljanitors todo list all printk calls (beginning a new line) should have an according KERN_* constant.

Forget about kernel janitors todo list, fix a bug instead.

Quoted 1 line

Those are the missing pieces here for the crypto subsystem.

You're inserting KERN_WARNING everywhere, what for?

Quoted 173 lines
crypto/tcrypt.c +27 -21
@@ -74,7 +74,7 @@ static int test_cipher_jiffies(struct bl
 			return ret;
 	}
 
-	printk("%d operations in %d seconds (%ld bytes)\n",
+	printk(KERN_WARNING "%d operations in %d seconds (%ld bytes)\n",
 	       bcount, sec, (long)bcount * blen);
 	return 0;
 }
@@ -122,7 +122,7 @@ out:
 	local_bh_enable();
 
 	if (ret == 0)
-		printk("1 operation in %lu cycles (%d bytes)\n",
+		printk(KERN_WARNING "1 operation in %lu cycles (%d bytes)\n",
 		       (cycles + 4) / 8, blen);
 
 	return ret;
@@ -146,13 +146,13 @@ static void test_cipher_speed(const char
 	else
 		e = "decryption";
 
-	printk("\ntesting speed of %s %s\n", algo, e);
+	printk(KERN_WARNING "\ntesting speed of %s %s\n", algo, e);
 
 	tfm = crypto_alloc_blkcipher(algo, 0, CRYPTO_ALG_ASYNC);
 
 	if (IS_ERR(tfm)) {
-		printk("failed to load transform for %s: %ld\n", algo,
-		       PTR_ERR(tfm));
+		printk(KERN_WARNING "failed to load transform for %s: %ld\n",
+		       algo, PTR_ERR(tfm));
 		return;
 	}
 	desc.tfm = tfm;
@@ -166,14 +166,16 @@ static void test_cipher_speed(const char
 			struct scatterlist sg[TVMEMSIZE];
 
 			if ((*keysize + *b_size) > TVMEMSIZE * PAGE_SIZE) {
-				printk("template (%u) too big for "
+				printk(KERN_WARNING
+				       "template (%u) too big for "
 				       "tvmem (%lu)\n", *keysize + *b_size,
 				       TVMEMSIZE * PAGE_SIZE);
 				goto out;
 			}
 
-			printk("test %u (%d bit key, %d byte blocks): ", i,
-					*keysize * 8, *b_size);
+			printk(KERN_WARNING
+					"test %u (%d bit key, %d byte blocks): ",
+					i, *keysize * 8, *b_size);
 
 			memset(tvmem[0], 0xff, PAGE_SIZE);
 
@@ -188,7 +190,8 @@ static void test_cipher_speed(const char
 
 			ret = crypto_blkcipher_setkey(tfm, key, *keysize);
 			if (ret) {
-				printk("setkey() failed flags=%x\n",
+				printk(KERN_WARNING
+						"setkey() failed flags=%x\n",
 						crypto_blkcipher_get_flags(tfm));
 				goto out;
 			}
@@ -215,7 +218,8 @@ static void test_cipher_speed(const char
 							 *b_size);
 
 			if (ret) {
-				printk("%s() failed flags=%x\n", e, desc.flags);
+				printk(KERN_WARNING "%s() failed flags=%x\n",
+				       e, desc.flags);
 				break;
 			}
 			b_size++;
@@ -243,7 +247,7 @@ static int test_hash_jiffies_digest(stru
 			return ret;
 	}
 
-	printk("%6u opers/sec, %9lu bytes/sec\n",
+	printk(KERN_WARNING "%6u opers/sec, %9lu bytes/sec\n",
 	       bcount / sec, ((long)bcount * blen) / sec);
 
 	return 0;
@@ -275,7 +279,7 @@ static int test_hash_jiffies(struct hash
 			return ret;
 	}
 
-	printk("%6u opers/sec, %9lu bytes/sec\n",
+	printk(KERN_WARNING "%6u opers/sec, %9lu bytes/sec\n",
 	       bcount / sec, ((long)bcount * blen) / sec);
 
 	return 0;
@@ -320,7 +324,7 @@ out:
 	if (ret)
 		return ret;
 
-	printk("%6lu cycles/operation, %4lu cycles/byte\n",
+	printk(KERN_WARNING "%6lu cycles/operation, %4lu cycles/byte\n",
 	       cycles / 8, cycles / (8 * blen));
 
 	return 0;
@@ -384,7 +388,7 @@ out:
 	if (ret)
 		return ret;
 
-	printk("%6lu cycles/operation, %4lu cycles/byte\n",
+	printk(KERN_WARNING "%6lu cycles/operation, %4lu cycles/byte\n",
 	       cycles / 8, cycles / (8 * blen));
 
 	return 0;
@@ -400,13 +404,13 @@ static void test_hash_speed(const char *
 	int i;
 	int ret;
 
-	printk("\ntesting speed of %s\n", algo);
+	printk(KERN_WARNING "\ntesting speed of %s\n", algo);
 
 	tfm = crypto_alloc_hash(algo, 0, CRYPTO_ALG_ASYNC);
 
 	if (IS_ERR(tfm)) {
-		printk("failed to load transform for %s: %ld\n", algo,
-		       PTR_ERR(tfm));
+		printk(KERN_WARNING "failed to load transform for %s: %ld\n",
+		       algo, PTR_ERR(tfm));
 		return;
 	}
 
@@ -414,7 +418,7 @@ static void test_hash_speed(const char *
 	desc.flags = 0;
 
 	if (crypto_hash_digestsize(tfm) > sizeof(output)) {
-		printk("digestsize(%u) > outputbuffer(%zu)\n",
+		printk(KERN_WARNING "digestsize(%u) > outputbuffer(%zu)\n",
 		       crypto_hash_digestsize(tfm), sizeof(output));
 		goto out;
 	}
@@ -427,12 +431,14 @@ static void test_hash_speed(const char *
 
 	for (i = 0; speed[i].blen != 0; i++) {
 		if (speed[i].blen > TVMEMSIZE * PAGE_SIZE) {
-			printk("template (%u) too big for tvmem (%lu)\n",
+			printk(KERN_WARNING
+			       "template (%u) too big for tvmem (%lu)\n",
 			       speed[i].blen, TVMEMSIZE * PAGE_SIZE);
 			goto out;
 		}
 
-		printk("test%3u (%5u byte blocks,%5u bytes per update,%4u updates): ",
+		printk(KERN_WARNING
+		       "test%3u (%5u byte blocks,%5u bytes per update,%4u updates): ",
 		       i, speed[i].blen, speed[i].plen, speed[i].blen / speed[i].plen);
 
 		if (sec)
@@ -443,7 +449,7 @@ static void test_hash_speed(const char *
 					       speed[i].plen, output);
 
 		if (ret) {
-			printk("hashing failed ret=%d\n", ret);
+			printk(KERN_WARNING "hashing failed ret=%d\n", ret);
 			break;
 		}
 	}
crypto/ansi_cprng.c +1 -1
@@ -167,7 +167,7 @@ static int _get_more_prng_bytes(struct p
 			break;
 	}
 
-	dbgprint("Returning new block for context %p\n", ctx);
+	dbgprint(KERN_WARNING "Returning new block for context %p\n", ctx);
#2 lore raw
Quoted 5 lines · Alexey Dobriyan
Quoted 2 lines · Frank Seidel

According to kerneljanitors todo list all printk calls (beginning a new line) should have an according KERN_* constant.

Forget about kernel janitors todo list, fix a bug instead.

Sure, i am eager to get my hands dirty in the kernel ;-), but i needed to start somewhere and everybody told me that the janitors todo list would be good place to start.

Quoted 3 lines
Quoted 1 line

Those are the missing pieces here for the crypto subsystem.

You're inserting KERN_WARNING everywhere, what for?

Because every new line should have KERN_* constant and KERN_WARNING is default/doesn't change current printout behaviour.

Thanks,
Frank

#3 lore raw
Quoted 11 lines · Frank Seidel
Quoted 5 lines · Alexey Dobriyan
Quoted 2 lines · Frank Seidel

According to kerneljanitors todo list all printk calls (beginning a new line) should have an according KERN_* constant.

Forget about kernel janitors todo list, fix a bug instead.

Sure, i am eager to get my hands dirty in the kernel ;-), but i needed to start somewhere and everybody told me that the janitors todo list would be good place to start.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Those are the missing pieces here for the crypto subsystem.

You're inserting KERN_WARNING everywhere, what for?

Because every new line should have KERN_* constant and KERN_WARNING is default/doesn't change current printout behaviour.

Some messages there were truly debugging and some clearly weren't WARNING, but INFO.

#4 lore raw
Quoted 2 lines · Alexey Dobriyan

Some messages there were truly debugging and some clearly weren't WARNING, but INFO.

Yes, i also thought so, but i didn't venture to change it to i think it looks like. And as bevor they also were all at the same (unspecified/default) level...
Do you think its worth/i should redo it and adapt the loglevel more appropriate?

Thanks,
Frank

maintainer
#5 lore raw
Quoted 6 lines · Frank Seidel

Yes, i also thought so, but i didn't venture to change it to i think it looks like. And as bevor they also were all at the same (unspecified/default) level...
Do you think its worth/i should redo it and adapt the loglevel more appropriate?

Please do. If it doesn't have any markings at least we know that it needs fixing. If you just add WARNINGs then we lose that information.

Thanks,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
#6 lore raw
Quoted 3 lines · Herbert Xu

Please do. If it doesn't have any markings at least we know that it needs fixing. If you just add WARNINGs then we lose that information.

Thats right, i fully agree. So i'll redo it asap.

Thanks,
Frank

#7 lore raw

PATCH v2 1/1 crypto: add missing KERN_* constants to printks

In reply to Frank Seidel

From: Frank Seidel <[email protected]>

According to kerneljanitors todo list all printk calls (beginning a new line) should have an according KERN_* constant. Those are the missing pieces here for the crypto subsystem.

---
 crypto/ansi_cprng.c |    2 +-
 crypto/tcrypt.c     |   51 +++++++++++++++++++++++++++++----------------------
 2 files changed, 30 insertions(+), 23 deletions(-)
crypto/ansi_cprng.c +1 -1
@@ -167,7 +167,7 @@ static int _get_more_prng_bytes(struct p
 			break;
 	}
 
-	dbgprint("Returning new block for context %p\n", ctx);
+	dbgprint(KERN_DEBUG "Returning new block for context %p\n", ctx);
 	ctx->rand_data_valid = 0;
 
 	hexdump("Output DT: ", ctx->DT, DEFAULT_BLK_SZ);
crypto/tcrypt.c +29 -22

152 lines not on this page · raw message

maintainer
#8 lore raw
Quoted 7 lines · Frank Seidel

From: Frank Seidel <[email protected]>

According to kerneljanitors todo list all printk calls (beginning a new line) should have an according KERN_* constant. Those are the missing pieces here for the crypto subsystem.

Patch applied. Thanks a lot!

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt