All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/5] scsi_debug: remove temporary hack around sscanf for negative values
@ 2008-03-20  2:09 FUJITA Tomonori
  2008-03-20  2:09 ` [PATCH 2/5] scsi_debug: create new scsi_debug devices at a single place FUJITA Tomonori
  2008-03-20 14:53 ` [PATCHes 1,2,3,4,5] scsi_debug Douglas Gilbert
  0 siblings, 2 replies; 6+ messages in thread
From: FUJITA Tomonori @ 2008-03-20  2:09 UTC (permalink / raw)
  To: linux-scsi; +Cc: tomof, FUJITA Tomonori, Douglas Gilbert, James Bottomley

sscanf can handle negative values.

Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Cc: Douglas Gilbert <dougg@torque.net>
Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
---
 drivers/scsi/scsi_debug.c |   17 +++--------------
 1 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 7a2a3ed..2a388d0 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -2681,21 +2681,10 @@ static ssize_t sdebug_add_host_show(struct device_driver * ddp, char * buf)
 static ssize_t sdebug_add_host_store(struct device_driver * ddp,
 				     const char * buf, size_t count)
 {
-        int delta_hosts;
-	char work[20];
+	int delta_hosts;
 
-        if (1 != sscanf(buf, "%10s", work))
+	if (sscanf(buf, "%d", &delta_hosts) != 1)
 		return -EINVAL;
-	{	/* temporary hack around sscanf() problem with -ve nums */
-		int neg = 0;
-
-		if ('-' == *work)
-			neg = 1;
-		if (1 != sscanf(work + neg, "%d", &delta_hosts))
-			return -EINVAL;
-		if (neg)
-			delta_hosts = -delta_hosts;
-	}
 	if (delta_hosts > 0) {
 		do {
 			sdebug_add_adapter();
@@ -2707,7 +2696,7 @@ static ssize_t sdebug_add_host_store(struct device_driver * ddp,
 	}
 	return count;
 }
-DRIVER_ATTR(add_host, S_IRUGO | S_IWUSR, sdebug_add_host_show, 
+DRIVER_ATTR(add_host, S_IRUGO | S_IWUSR, sdebug_add_host_show,
 	    sdebug_add_host_store);
 
 static ssize_t sdebug_vpd_use_hostno_show(struct device_driver * ddp,
-- 
1.5.3.7


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

end of thread, other threads:[~2008-03-20 14:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-20  2:09 [PATCH 1/5] scsi_debug: remove temporary hack around sscanf for negative values FUJITA Tomonori
2008-03-20  2:09 ` [PATCH 2/5] scsi_debug: create new scsi_debug devices at a single place FUJITA Tomonori
2008-03-20  2:09   ` [PATCH 3/5] scsi_debug: remove unnecessary condition test in devInfoReg FUJITA Tomonori
2008-03-20  2:09     ` [PATCH 4/5] scsi_debug: use list_for_each_entry_safe FUJITA Tomonori
2008-03-20  2:09       ` [PATCH 5/5] scsi_debug: remove unnecessary function declarations FUJITA Tomonori
2008-03-20 14:53 ` [PATCHes 1,2,3,4,5] scsi_debug Douglas Gilbert

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.