Browse Source

str: fix unused var warning with gcc

Compiler:
/home/rusty/devel/cvs/ccan/ccan/str/str.h: In function ‘main’:
/home/rusty/devel/cvs/ccan/ccan/str/str.h:69:5: warning: variable ‘i’ set but not used [-Wunused-but-set-variable]

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Rusty Russell 13 years ago
parent
commit
39150ca863
1 changed files with 5 additions and 6 deletions
  1. 5 6
      ccan/str/str.h

+ 5 - 6
ccan/str/str.h

@@ -66,10 +66,9 @@ static inline bool strends(const char *str, const char *postfix)
  * @needle: a substring
  * @needle: a substring
  *
  *
  * Example:
  * Example:
- *	int i;
- *      i = strcount("aaa aaa", "a");  // i = 6;
- *      i = strcount("aaa aaa", "ab"); // i = 0;
- *      i = strcount("aaa aaa", "aa"); // i = 2;
+ *      assert(strcount("aaa aaa", "a") == 6);
+ *      assert(strcount("aaa aaa", "ab") == 0);
+ *      assert(strcount("aaa aaa", "aa") == 2);
  */
  */
 size_t strcount(const char *haystack, const char *needle);
 size_t strcount(const char *haystack, const char *needle);
 
 
@@ -84,9 +83,9 @@ size_t strcount(const char *haystack, const char *needle);
  * values will fit (eg. sprintf(... "%p"). )
  * values will fit (eg. sprintf(... "%p"). )
  *
  *
  * Example:
  * Example:
- *	char str[STR_MAX_CHARS(i)];
+ *	char str[STR_MAX_CHARS(int)];
  *
  *
- *	sprintf(str, "%i", i);
+ *	sprintf(str, "%i", 7);
  */
  */
 #define STR_MAX_CHARS(type_or_expr)				\
 #define STR_MAX_CHARS(type_or_expr)				\
 	((sizeof(type_or_expr) * CHAR_BIT + 8) / 9 * 3 + 2	\
 	((sizeof(type_or_expr) * CHAR_BIT + 8) / 9 * 3 + 2	\