Browse Source

iconv: fix type mismatches

With gcc-14 warnings caused by type mismatches turn to errors:
- iconv_t is not a pointer type, convert the result directly to iconv_t
  in combine_to_from()
- unsigned int is not the same as wchar_t, use temporary wchar_t wc as
  an argument for utf8dec_wchar()

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Max Filippov 1 month ago
parent
commit
04eae46779
1 changed files with 6 additions and 2 deletions
  1. 6 2
      libiconv/iconv.c

+ 6 - 2
libiconv/iconv.c

@@ -142,7 +142,7 @@ struct stateful_cd {
 
 static iconv_t combine_to_from(size_t t, size_t f)
 {
-	return (void *)(f<<16 | t<<1 | 1);
+	return (iconv_t)(f<<16 | t<<1 | 1);
 }
 
 static size_t extract_from(iconv_t cd)
@@ -382,7 +382,11 @@ size_t iconv(iconv_t cd, char **restrict in, size_t *restrict inb, char **restri
 		switch (type) {
 		case UTF_8:
 			if (c < 128) break;
-			l = utf8dec_wchar(&c, *in, *inb);
+			else {
+				wchar_t wc;
+				l = utf8dec_wchar(&wc, *in, *inb);
+				c = wc;
+			}
 			if (!l) l++;
 			else if (l == (size_t)-1) goto ilseq;
 			else if (l == (size_t)-2) goto starved;