Module Name:    src
Committed By:   riastradh
Date:           Wed Oct  9 14:28:56 UTC 2024

Modified Files:
        src/lib/libc/locale: c16rtomb.c

Log Message:
c16rtomb(3): Omit needless cast.

Now that lint has been taught to propagate the range in this kind of
expression (PR toolchain/58728), we can omit the cast -- the result is
guaranteed not to the truncated.

PR standards/58601: uchar.h C23 compliance: char8_t, mbrtoc8, c8rtomb
PR toolchain/58728: lint objects to __SHIFTIN/__BITS of values in
  known-limited range without cast


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/lib/libc/locale/c16rtomb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libc/locale/c16rtomb.c
diff -u src/lib/libc/locale/c16rtomb.c:1.8 src/lib/libc/locale/c16rtomb.c:1.9
--- src/lib/libc/locale/c16rtomb.c:1.8	Tue Oct  8 13:42:17 2024
+++ src/lib/libc/locale/c16rtomb.c	Wed Oct  9 14:28:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: c16rtomb.c,v 1.8 2024/10/08 13:42:17 riastradh Exp $	*/
+/*	$NetBSD: c16rtomb.c,v 1.9 2024/10/09 14:28:56 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2024 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: c16rtomb.c,v 1.8 2024/10/08 13:42:17 riastradh Exp $");
+__RCSID("$NetBSD: c16rtomb.c,v 1.9 2024/10/09 14:28:56 riastradh Exp $");
 
 #include "namespace.h"
 
@@ -177,14 +177,8 @@ c16rtomb_l(char *restrict s, char16_t c1
 		}
 		const char16_t w1 = S->surrogate;
 		const char16_t w2 = c16;
-		/*
-		 * XXX lint is unconvinced that this cast is needless:
-		 * PR toolchain/58728: __SHIFTIN/__BITS of values in
-		 * known-limited range without cast
-		 */
-		c32 = (char32_t)(
-		    __SHIFTIN(__SHIFTOUT(w1, __BITS(9,0)), __BITS(19,10)) |
-		    __SHIFTIN(__SHIFTOUT(w2, __BITS(9,0)), __BITS(9,0)));
+		c32 = __SHIFTIN(__SHIFTOUT(w1, __BITS(9,0)), __BITS(19,10)) |
+		    __SHIFTIN(__SHIFTOUT(w2, __BITS(9,0)), __BITS(9,0));
 		c32 += 0x10000;
 		S->surrogate = 0;
 	} else if (c16 >= 0xd800 && c16 <= 0xdbff) { /* 3. high surrogate */

Reply via email to