linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] iio: Do not accept multiple '.' in fixed point numbers
@ 2012-10-22 11:15 Lars-Peter Clausen
  2012-10-22 11:15 ` [PATCH 2/3] iio: Reject trailing garbage when parsing " Lars-Peter Clausen
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Lars-Peter Clausen @ 2012-10-22 11:15 UTC (permalink / raw)
  To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen

Currently when parsing a fix-point number we silently skip any additional '.'
found in the string.  E.g. '1.2.3.4' gets parsed as '1.234'. This patch
disallows this and returns an error if more than one '.' is encountered.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
 drivers/iio/industrialio-core.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 6eb24db..a2e9953 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -449,7 +449,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
 				break;
 			else
 				return -EINVAL;
-		} else if (*buf == '.') {
+		} else if (*buf == '.' && integer_part) {
 			integer_part = false;
 		} else {
 			return -EINVAL;
-- 
1.7.10.4


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

end of thread, other threads:[~2012-11-02  9:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-22 11:15 [PATCH 1/3] iio: Do not accept multiple '.' in fixed point numbers Lars-Peter Clausen
2012-10-22 11:15 ` [PATCH 2/3] iio: Reject trailing garbage when parsing " Lars-Peter Clausen
2012-11-02  9:45   ` Jonathan Cameron
2012-10-22 11:15 ` [PATCH 3/3] iio: Accept a leading '+' sign " Lars-Peter Clausen
2012-11-02  9:46   ` Jonathan Cameron
2012-11-02  9:44 ` [PATCH 1/3] iio: Do not accept multiple '.' in " Jonathan Cameron

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).