linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] floppy: make local variable non-static
@ 2015-12-01 14:54 Rasmus Villemoes
  2015-12-08 14:16 ` Jiri Kosina
  0 siblings, 1 reply; 2+ messages in thread
From: Rasmus Villemoes @ 2015-12-01 14:54 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: Rasmus Villemoes, linux-kernel

There's no reason for temparea to be static, since it's only used for
temporary sprintf output. It's not immediately obvious that the output
will always fit (in the worst case, the output including '\0' is
exactly 32 bytes), so save a future reader from worrying about that.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/block/floppy.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 331363e7de0f..9e251201dd48 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -3585,7 +3585,7 @@ static void __init config_types(void)
 		unsigned int type = UDP->cmos;
 		struct floppy_drive_params *params;
 		const char *name = NULL;
-		static char temparea[32];
+		char temparea[32];
 
 		if (type < ARRAY_SIZE(default_drive_params)) {
 			params = &default_drive_params[type].params;
@@ -3596,7 +3596,8 @@ static void __init config_types(void)
 				allowed_drive_mask &= ~(1 << drive);
 		} else {
 			params = &default_drive_params[0].params;
-			sprintf(temparea, "unknown type %d (usb?)", type);
+			snprintf(temparea, sizeof(temparea),
+				 "unknown type %d (usb?)", type);
 			name = temparea;
 		}
 		if (name) {
-- 
2.6.1


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

* Re: [PATCH] floppy: make local variable non-static
  2015-12-01 14:54 [PATCH] floppy: make local variable non-static Rasmus Villemoes
@ 2015-12-08 14:16 ` Jiri Kosina
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Kosina @ 2015-12-08 14:16 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: linux-kernel

On Tue, 1 Dec 2015, Rasmus Villemoes wrote:

> There's no reason for temparea to be static, since it's only used for
> temporary sprintf output. It's not immediately obvious that the output
> will always fit (in the worst case, the output including '\0' is
> exactly 32 bytes), so save a future reader from worrying about that.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Applied, thanks.

(I have applied this to trivial.git, as was too lazy to revive floppy tree 
just for this :) ).

-- 
Jiri Kosina
SUSE Labs


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

end of thread, other threads:[~2015-12-08 14:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-01 14:54 [PATCH] floppy: make local variable non-static Rasmus Villemoes
2015-12-08 14:16 ` Jiri Kosina

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).