git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/5] utf8: fix iconv error detection

From
John Keeping <john@keeping.me.uk>
Date
Feb 16, 2014, 16:06 UTC
Message-ID
<53061a27144d1cbafd509c3b5a13e642a9ea400a.1392565571.git.john@keeping.me.uk>
In-Reply-To
<cover.1392565571.git.john@keeping.me.uk>

iconv(3) returns "(size_t) -1" on error. Make sure that we cast the "-1" properly when checking for this.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
 utf8.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/utf8.c b/utf8.c
index 0d20e0a..24c3c5c 100644
--- a/utf8.c
+++ b/utf8.c
@@ -529,7 +529,7 @@ char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv, int *outs
 	while (1) {
 		size_t cnt = iconv(conv, &cp, &insz, &outpos, &outsz);
 
-		if (cnt == -1) {
+		if (cnt == (size_t) -1) {
 			size_t sofar;
 			if (errno != E2BIG) {
 				free(out);
-- 
1.9.rc0.187.g6292fff
Previous: David KastrupNext: John Keeping
Message 8 of 13 in “Miscellaneous fixes from static analysis”
  1. 0/5 Miscellaneous fixes from static analysisJohn Keeping, Feb 16, 2014
  2. 1/5 notes-utils: handle boolean notes.rewritemode correctlyJohn Keeping, Feb 16, 2014
  3. David KastrupFeb 16, 2014
  4. Jeff KingFeb 18, 2014
  5. David KastrupFeb 18, 2014
  6. Jeff KingFeb 18, 2014
  7. David KastrupFeb 18, 2014
  8. 2/5 utf8: fix iconv error detectionJohn Keeping, Feb 16, 2014
  9. 3/5 utf8: use correct type for values in interval tableJohn Keeping, Feb 16, 2014
  10. 4/5 builtin/mv: don't use memory after freeJohn Keeping, Feb 16, 2014
  11. 5/5 streaming: simplify attaching a filterJohn Keeping, Feb 16, 2014
  12. Junio C HamanoFeb 18, 2014
  13. Junio C HamanoFeb 19, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.