public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] random: make it possible to enable debugging without rebuild
@ 2012-10-08 14:39 Jiri Kosina
  2012-10-08 14:40 ` [PATCH 2/2] random: fix debug format strings Jiri Kosina
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Jiri Kosina @ 2012-10-08 14:39 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-kernel

The module parameter that turns debugging mode (which basically means 
printing a few extra lines during runtime) is in '#if 0' block. Forcing 
everyone who would like to see how entropy is behaving on his system seems 
to be a little bit too harsh.
If we were concerned about speed, we could potentially turn 'debug' into
a static key, but I don't think it's necessary.

Drop the '#if 0' block to allow using the 'debug' parameter without rebuilding.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/char/random.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index b86eae9..9ac4443 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -399,7 +399,6 @@ static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
 static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
 static struct fasync_struct *fasync;
 
-#if 0
 static bool debug;
 module_param(debug, bool, 0644);
 #define DEBUG_ENT(fmt, arg...) do { \
@@ -410,9 +409,6 @@ module_param(debug, bool, 0644);
 		blocking_pool.entropy_count,\
 		nonblocking_pool.entropy_count,\
 		## arg); } while (0)
-#else
-#define DEBUG_ENT(fmt, arg...) do {} while (0)
-#endif
 
 /**********************************************************************
  *

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] random: fix debug format strings
  2012-10-08 14:39 [PATCH 1/2] random: make it possible to enable debugging without rebuild Jiri Kosina
@ 2012-10-08 14:40 ` Jiri Kosina
  2012-10-15 21:43   ` [RESEND] " Jiri Kosina
  2012-10-08 19:45 ` [PATCH 1/2] random: make it possible to enable debugging without rebuild Joe Perches
  2012-10-15 21:42 ` [RESEND] " Jiri Kosina
  2 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2012-10-08 14:40 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-kernel

Fix the following warnings in formatting debug output:

drivers/char/random.c: In function ‘xfer_secondary_pool’:
drivers/char/random.c:827: warning: format ‘%d’ expects type ‘int’, but argument 7 has type ‘size_t’
drivers/char/random.c: In function ‘account’:
drivers/char/random.c:859: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
drivers/char/random.c:881: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
drivers/char/random.c: In function ‘random_read’:
drivers/char/random.c:1141: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
drivers/char/random.c:1145: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
drivers/char/random.c:1145: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘long unsigned int’

by using '%zd' instead of '%d' to properly denote ssize_t/size_t conversion.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/char/random.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 9ac4443..5d513c3 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -825,7 +825,7 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
 		bytes = min_t(int, bytes, sizeof(tmp));
 
 		DEBUG_ENT("going to reseed %s with %d bits "
-			  "(%d of %d requested)\n",
+			  "(%zd of %d requested)\n",
 			  r->name, bytes * 8, nbytes * 8, r->entropy_count);
 
 		bytes = extract_entropy(r->pull, tmp, bytes,
@@ -856,7 +856,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
 	spin_lock_irqsave(&r->lock, flags);
 
 	BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
-	DEBUG_ENT("trying to extract %d bits from %s\n",
+	DEBUG_ENT("trying to extract %zd bits from %s\n",
 		  nbytes * 8, r->name);
 
 	/* Can we pull enough? */
@@ -878,7 +878,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
 		}
 	}
 
-	DEBUG_ENT("debiting %d entropy credits from %s%s\n",
+	DEBUG_ENT("debiting %zd entropy credits from %s%s\n",
 		  nbytes * 8, r->name, r->limit ? "" : " (unlimited)");
 
 	spin_unlock_irqrestore(&r->lock, flags);
@@ -1138,11 +1138,11 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 		if (n > SEC_XFER_SIZE)
 			n = SEC_XFER_SIZE;
 
-		DEBUG_ENT("reading %d bits\n", n*8);
+		DEBUG_ENT("reading %zd bits\n", n*8);
 
 		n = extract_entropy_user(&blocking_pool, buf, n);
 
-		DEBUG_ENT("read got %d bits (%d still needed)\n",
+		DEBUG_ENT("read got %zd bits (%zd still needed)\n",
 			  n*8, (nbytes-n)*8);
 
 		if (n == 0) {
-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] random: make it possible to enable debugging without rebuild
  2012-10-08 14:39 [PATCH 1/2] random: make it possible to enable debugging without rebuild Jiri Kosina
  2012-10-08 14:40 ` [PATCH 2/2] random: fix debug format strings Jiri Kosina
@ 2012-10-08 19:45 ` Joe Perches
  2012-10-15 21:42 ` [RESEND] " Jiri Kosina
  2 siblings, 0 replies; 7+ messages in thread
From: Joe Perches @ 2012-10-08 19:45 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Theodore Ts'o, linux-kernel

On Mon, 2012-10-08 at 16:39 +0200, Jiri Kosina wrote:
> The module parameter that turns debugging mode (which basically means 
> printing a few extra lines during runtime) is in '#if 0' block. Forcing 
> everyone who would like to see how entropy is behaving on his system seems 
> to be a little bit too harsh.
> If we were concerned about speed, we could potentially turn 'debug' into
> a static key, but I don't think it's necessary.
> 
> Drop the '#if 0' block to allow using the 'debug' parameter without rebuilding.

I'd also convert the printk(KERN_DEBUG to pr_debug
to avoid penalizing non-debug builds altogether.




^ permalink raw reply	[flat|nested] 7+ messages in thread

* [RESEND] [PATCH 1/2] random: make it possible to enable debugging without rebuild
  2012-10-08 14:39 [PATCH 1/2] random: make it possible to enable debugging without rebuild Jiri Kosina
  2012-10-08 14:40 ` [PATCH 2/2] random: fix debug format strings Jiri Kosina
  2012-10-08 19:45 ` [PATCH 1/2] random: make it possible to enable debugging without rebuild Joe Perches
@ 2012-10-15 21:42 ` Jiri Kosina
  2012-10-16  3:43   ` Theodore Ts'o
  2 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2012-10-15 21:42 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-kernel, Andrew Morton

The module parameter that turns debugging mode (which basically means 
printing a few extra lines during runtime) is in '#if 0' block. Forcing 
everyone who would like to see how entropy is behaving on his system to 
rebuild seems to be a little bit too harsh.

If we were concerned about speed, we could potentially turn 'debug' into a 
static key, but I don't think it's necessary.

Drop the '#if 0' block to allow using the 'debug' parameter without rebuilding.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/char/random.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index b86eae9..9ac4443 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -399,7 +399,6 @@ static DECLARE_WAIT_QUEUE_HEAD(random_read_wait);
 static DECLARE_WAIT_QUEUE_HEAD(random_write_wait);
 static struct fasync_struct *fasync;
 
-#if 0
 static bool debug;
 module_param(debug, bool, 0644);
 #define DEBUG_ENT(fmt, arg...) do { \
@@ -410,9 +409,6 @@ module_param(debug, bool, 0644);
 		blocking_pool.entropy_count,\
 		nonblocking_pool.entropy_count,\
 		## arg); } while (0)
-#else
-#define DEBUG_ENT(fmt, arg...) do {} while (0)
-#endif
 
 /**********************************************************************
  *

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [RESEND] [PATCH 2/2] random: fix debug format strings
  2012-10-08 14:40 ` [PATCH 2/2] random: fix debug format strings Jiri Kosina
@ 2012-10-15 21:43   ` Jiri Kosina
  2012-10-16  3:43     ` Theodore Ts'o
  0 siblings, 1 reply; 7+ messages in thread
From: Jiri Kosina @ 2012-10-15 21:43 UTC (permalink / raw)
  To: Theodore Ts'o; +Cc: linux-kernel, Andrew Morton

Fix the following warnings in formatting debug output:

drivers/char/random.c: In function ‘xfer_secondary_pool’:
drivers/char/random.c:827: warning: format ‘%d’ expects type ‘int’, but argument 7 has type ‘size_t’
drivers/char/random.c: In function ‘account’:
drivers/char/random.c:859: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
drivers/char/random.c:881: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
drivers/char/random.c: In function ‘random_read’:
drivers/char/random.c:1141: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
drivers/char/random.c:1145: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
drivers/char/random.c:1145: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘long unsigned int’

by using '%zd' instead of '%d' to properly denote ssize_t/size_t conversion.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
---
 drivers/char/random.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index 9ac4443..5d513c3 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -825,7 +825,7 @@ static void xfer_secondary_pool(struct entropy_store *r, size_t nbytes)
 		bytes = min_t(int, bytes, sizeof(tmp));
 
 		DEBUG_ENT("going to reseed %s with %d bits "
-			  "(%d of %d requested)\n",
+			  "(%zd of %d requested)\n",
 			  r->name, bytes * 8, nbytes * 8, r->entropy_count);
 
 		bytes = extract_entropy(r->pull, tmp, bytes,
@@ -856,7 +856,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
 	spin_lock_irqsave(&r->lock, flags);
 
 	BUG_ON(r->entropy_count > r->poolinfo->POOLBITS);
-	DEBUG_ENT("trying to extract %d bits from %s\n",
+	DEBUG_ENT("trying to extract %zd bits from %s\n",
 		  nbytes * 8, r->name);
 
 	/* Can we pull enough? */
@@ -878,7 +878,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min,
 		}
 	}
 
-	DEBUG_ENT("debiting %d entropy credits from %s%s\n",
+	DEBUG_ENT("debiting %zd entropy credits from %s%s\n",
 		  nbytes * 8, r->name, r->limit ? "" : " (unlimited)");
 
 	spin_unlock_irqrestore(&r->lock, flags);
@@ -1138,11 +1138,11 @@ random_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
 		if (n > SEC_XFER_SIZE)
 			n = SEC_XFER_SIZE;
 
-		DEBUG_ENT("reading %d bits\n", n*8);
+		DEBUG_ENT("reading %zd bits\n", n*8);
 
 		n = extract_entropy_user(&blocking_pool, buf, n);
 
-		DEBUG_ENT("read got %d bits (%d still needed)\n",
+		DEBUG_ENT("read got %zd bits (%zd still needed)\n",
 			  n*8, (nbytes-n)*8);
 
 		if (n == 0) {
-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [RESEND] [PATCH 1/2] random: make it possible to enable debugging without rebuild
  2012-10-15 21:42 ` [RESEND] " Jiri Kosina
@ 2012-10-16  3:43   ` Theodore Ts'o
  0 siblings, 0 replies; 7+ messages in thread
From: Theodore Ts'o @ 2012-10-16  3:43 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-kernel, Andrew Morton

On Mon, Oct 15, 2012 at 11:42:55PM +0200, Jiri Kosina wrote:
> The module parameter that turns debugging mode (which basically means 
> printing a few extra lines during runtime) is in '#if 0' block. Forcing 
> everyone who would like to see how entropy is behaving on his system to 
> rebuild seems to be a little bit too harsh.
> 
> If we were concerned about speed, we could potentially turn 'debug' into a 
> static key, but I don't think it's necessary.
> 
> Drop the '#if 0' block to allow using the 'debug' parameter without rebuilding.
> 
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Applied to the random tree, thanks.

						- Ted

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [RESEND] [PATCH 2/2] random: fix debug format strings
  2012-10-15 21:43   ` [RESEND] " Jiri Kosina
@ 2012-10-16  3:43     ` Theodore Ts'o
  0 siblings, 0 replies; 7+ messages in thread
From: Theodore Ts'o @ 2012-10-16  3:43 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-kernel, Andrew Morton

On Mon, Oct 15, 2012 at 11:43:29PM +0200, Jiri Kosina wrote:
> Fix the following warnings in formatting debug output:
> 
> drivers/char/random.c: In function ‘xfer_secondary_pool’:
> drivers/char/random.c:827: warning: format ‘%d’ expects type ‘int’, but argument 7 has type ‘size_t’
> drivers/char/random.c: In function ‘account’:
> drivers/char/random.c:859: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
> drivers/char/random.c:881: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
> drivers/char/random.c: In function ‘random_read’:
> drivers/char/random.c:1141: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
> drivers/char/random.c:1145: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
> drivers/char/random.c:1145: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘long unsigned int’
> 
> by using '%zd' instead of '%d' to properly denote ssize_t/size_t conversion.
> 
> Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Applied to the random tree, thanks.

						- Ted

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-10-16  3:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-08 14:39 [PATCH 1/2] random: make it possible to enable debugging without rebuild Jiri Kosina
2012-10-08 14:40 ` [PATCH 2/2] random: fix debug format strings Jiri Kosina
2012-10-15 21:43   ` [RESEND] " Jiri Kosina
2012-10-16  3:43     ` Theodore Ts'o
2012-10-08 19:45 ` [PATCH 1/2] random: make it possible to enable debugging without rebuild Joe Perches
2012-10-15 21:42 ` [RESEND] " Jiri Kosina
2012-10-16  3:43   ` Theodore Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox