Message ID | 20250415192212.33949-7-nico@fluxnic.net |
---|---|
State | Superseded |
Headers | show |
Series | vt: implement proper Unicode handling | expand |
Hi Nicolas, kernel test robot noticed the following build warnings: [auto build test WARNING on tty/tty-linus] [also build test WARNING on linus/master v6.15-rc2] [cannot apply to tty/tty-testing tty/tty-next next-20250416] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Nicolas-Pitre/vt-minor-cleanup-to-vc_translate_unicode/20250416-142136 base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-linus patch link: https://lore.kernel.org/r/20250415192212.33949-7-nico%40fluxnic.net patch subject: [PATCH v2 06/13] vt: use new tables in ucs.c config: arc-randconfig-002-20250417 (https://download.01.org/0day-ci/archive/20250417/202504171646.NDaNfFql-lkp@intel.com/config) compiler: arc-linux-gcc (GCC) 13.3.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250417/202504171646.NDaNfFql-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202504171646.NDaNfFql-lkp@intel.com/ All warnings (new ones prefixed by >>): >> drivers/tty/vt/ucs.c:43: warning: Function parameter or struct member 'cp' not described in 'ucs_is_zero_width' >> drivers/tty/vt/ucs.c:43: warning: expecting prototype for Determine if a Unicode code point is zero(). Prototype was for ucs_is_zero_width() instead drivers/tty/vt/ucs.c:55: warning: Function parameter or struct member 'cp' not described in 'ucs_is_double_width' drivers/tty/vt/ucs.c:55: warning: expecting prototype for Determine if a Unicode code point is double(). Prototype was for ucs_is_double_width() instead vim +43 drivers/tty/vt/ucs.c 35 36 /** 37 * Determine if a Unicode code point is zero-width. 38 * 39 * @param cp: Unicode code point (UCS-4) 40 * Return: true if the character is zero-width, false otherwise 41 */ 42 bool ucs_is_zero_width(u32 cp) > 43 { 44 return cp_in_range(cp, ucs_zero_width_ranges, 45 ARRAY_SIZE(ucs_zero_width_ranges)); 46 } 47
diff --git a/drivers/tty/vt/ucs.c b/drivers/tty/vt/ucs.c index 0f6c087158..5e71aa3896 100644 --- a/drivers/tty/vt/ucs.c +++ b/drivers/tty/vt/ucs.c @@ -5,22 +5,12 @@ #include <linux/consolemap.h> #include <linux/minmax.h> -/* ucs_is_double_width() is based on the wcwidth() implementation by - * Markus Kuhn -- 2007-05-26 (Unicode 5.0) - * Latest version: https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c - */ - struct ucs_interval { u32 first; u32 last; }; -static const struct ucs_interval ucs_double_width_ranges[] = { - { 0x1100, 0x115F }, { 0x2329, 0x232A }, { 0x2E80, 0x303E }, - { 0x3040, 0xA4CF }, { 0xAC00, 0xD7A3 }, { 0xF900, 0xFAFF }, - { 0xFE10, 0xFE19 }, { 0xFE30, 0xFE6F }, { 0xFF00, 0xFF60 }, - { 0xFFE0, 0xFFE6 }, { 0x20000, 0x2FFFD }, { 0x30000, 0x3FFFD } -}; +#include "ucs_width_table.h" static int interval_cmp(const void *key, const void *element) { @@ -34,6 +24,27 @@ static int interval_cmp(const void *key, const void *element) return 0; } +static bool cp_in_range(u32 cp, const struct ucs_interval *ranges, size_t size) +{ + if (!in_range(cp, ranges[0].first, ranges[size - 1].last)) + return false; + + return __inline_bsearch(&cp, ranges, size, sizeof(*ranges), + interval_cmp) != NULL; +} + +/** + * Determine if a Unicode code point is zero-width. + * + * @param cp: Unicode code point (UCS-4) + * Return: true if the character is zero-width, false otherwise + */ +bool ucs_is_zero_width(u32 cp) +{ + return cp_in_range(cp, ucs_zero_width_ranges, + ARRAY_SIZE(ucs_zero_width_ranges)); +} + /** * Determine if a Unicode code point is double-width. * @@ -42,13 +53,6 @@ static int interval_cmp(const void *key, const void *element) */ bool ucs_is_double_width(u32 cp) { - size_t size = ARRAY_SIZE(ucs_double_width_ranges); - - if (!in_range(cp, ucs_double_width_ranges[0].first, - ucs_double_width_ranges[size - 1].last)) - return false; - - return __inline_bsearch(&cp, ucs_double_width_ranges, size, - sizeof(*ucs_double_width_ranges), - interval_cmp) != NULL; + return cp_in_range(cp, ucs_double_width_ranges, + ARRAY_SIZE(ucs_double_width_ranges)); } diff --git a/include/linux/consolemap.h b/include/linux/consolemap.h index 7d778752dc..b3a9118666 100644 --- a/include/linux/consolemap.h +++ b/include/linux/consolemap.h @@ -29,11 +29,7 @@ u32 conv_8bit_to_uni(unsigned char c); int conv_uni_to_8bit(u32 uni); void console_map_init(void); bool ucs_is_double_width(uint32_t cp); -static inline bool ucs_is_zero_width(uint32_t cp) -{ - /* coming soon */ - return false; -} +bool ucs_is_zero_width(uint32_t cp); #else static inline u16 inverse_translate(const struct vc_data *conp, u16 glyph, bool use_unicode)