[svn-commits] wdoekes: branch 10 r346145 - in /branches/10: ./ include/asterisk/strings.h

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Nov 23 13:55:46 CST 2011


Author: wdoekes
Date: Wed Nov 23 13:55:41 2011
New Revision: 346145

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=346145
Log:
Fix ast_str_truncate signedness warning and documentation.

Review: https://reviewboard.asterisk.org/r/1594
........

Merged revisions 346144 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/10/   (props changed)
    branches/10/include/asterisk/strings.h

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/include/asterisk/strings.h
URL: http://svnview.digium.com/svn/asterisk/branches/10/include/asterisk/strings.h?view=diff&rev=346145&r1=346144&r2=346145
==============================================================================
--- branches/10/include/asterisk/strings.h (original)
+++ branches/10/include/asterisk/strings.h Wed Nov 23 13:55:41 2011
@@ -498,14 +498,20 @@
 
 /*!\brief Truncates the enclosed string to the given length.
  * \param buf A pointer to the ast_str structure.
- * \param len Maximum length of the string.
+ * \param len Maximum length of the string. If len is larger than the
+ *        current maximum length, things will explode. If it is negative
+ *        at most -len characters will be trimmed off the end.
  * \retval A pointer to the resulting string.
  */
 AST_INLINE_API(
 char *ast_str_truncate(struct ast_str *buf, ssize_t len),
 {
 	if (len < 0) {
-		buf->__AST_STR_USED += ((ssize_t) abs(len)) > (ssize_t) buf->__AST_STR_USED ? -buf->__AST_STR_USED : len;
+		if ((typeof(buf->__AST_STR_USED)) -len >= buf->__AST_STR_USED) {
+			buf->__AST_STR_USED = 0;
+		} else {
+			buf->__AST_STR_USED += len;
+		}
 	} else {
 		buf->__AST_STR_USED = len;
 	}




More information about the svn-commits mailing list