aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-08-10 19:36:38 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2009-08-10 19:36:38 +0000
commitd69c554bf4ab96d713b9f58fb22ea449cfd5901b (patch)
tree72e9f08d12cb63bcead8c9313eb1bebdd41d5469 /doc
parenta6751112c3f5effd6608e8fb9dc7afce7b64a05e (diff)
AST-2009-005
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@211580 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'doc')
-rw-r--r--doc/CODING-GUIDELINES11
1 files changed, 11 insertions, 0 deletions
diff --git a/doc/CODING-GUIDELINES b/doc/CODING-GUIDELINES
index da2b1fea7..766e5d970 100644
--- a/doc/CODING-GUIDELINES
+++ b/doc/CODING-GUIDELINES
@@ -381,6 +381,17 @@ you wish to put into it (even if you did not allocate the buffer yourself),
use a direct strcpy(), as it can be inlined and optimized to simple
processor operations, unlike ast_copy_string().
+* String conversions
+--------------------
+
+When converting from strings to integers or floats, use the sscanf function
+in preference to the atoi and atof family of functions, as sscanf detects
+errors. Always check the return value of sscanf to verify that your numeric
+variables successfully scanned before using them. Also, to avoid a potential
+libc bug, always specify a maximum width for each format specifier, including
+integers and floats. A good length for both integers and floats is 30, as
+this is more than generous, even if you're using doubles or long integers.
+
* Use of functions
------------------