View Issue Details

IDProjectCategoryView StatusLast Update
0000383fileGeneralpublic2022-09-27 19:01
Reporterdelphij Assigned Tochristos  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platformarm64OSFreeBSDOS Version-CURRENT
Product Version5.43 
Summary0000383: printf %lc expects wint_t
DescriptionIn src/file.c, fname_print():

        wchar_t nextchar;
[...]
                        printf("%lc", nextchar);

but %lc expects wint_t, and this will cause build breakage for FreeBSD/arm64.
Steps To Reproducebuild with -Werror and -Wformat.
TagsNo tags attached.

Activities

delphij

2022-09-25 04:27

reporter  

0001-file.c-Explicitly-cast-nextchar-to-wint_t-for-printf.patch (775 bytes)   
From 488cee2b1db20e53f5c124950d05c5ca85b81500 Mon Sep 17 00:00:00 2001
From: Xin LI <delphij@FreeBSD.org>
Date: Sat, 24 Sep 2022 21:09:52 -0700
Subject: [PATCH] file.c: Explicitly cast 'nextchar' to wint_t for printf(3).

%lc expects an wint_t parameter, while 'nextchar' is wchar_t.
This causes build issues for some FreeBSD platforms.
---
 src/file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/file.c b/src/file.c
index cb9845a7..4250abbf 100644
--- a/src/file.c
+++ b/src/file.c
@@ -593,7 +593,7 @@ fname_print(const char *inname)
 		inname += bytesconsumed;
 		n -= bytesconsumed;
 		if (iswprint(nextchar)) {
-			printf("%lc", nextchar);
+			printf("%lc", (wint_t)nextchar);
 			continue;
 		}
 		/* XXX: What if it is > 255? */
-- 
2.37.3

christos

2022-09-27 19:01

manager   ~0003817

fixed, thanks!

Issue History

Date Modified Username Field Change
2022-09-25 04:27 delphij New Issue
2022-09-25 04:27 delphij File Added: 0001-file.c-Explicitly-cast-nextchar-to-wint_t-for-printf.patch
2022-09-27 19:01 christos Assigned To => christos
2022-09-27 19:01 christos Status new => assigned
2022-09-27 19:01 christos Status assigned => resolved
2022-09-27 19:01 christos Resolution open => fixed
2022-09-27 19:01 christos Note Added: 0003817