Skip to content

edid: fix uint16_t conversion warning

Pekka Paalanen requested to merge pq/libdisplay-info:mr/comfix into main
../../git/weston/subprojects/display-info/edid.c: In function ‘decode_chromaticity_coord’:
../../git/weston/subprojects/display-info/edid.c:250:8: warning: conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} may change value [-Wconversion]
  250 |  raw = (uint16_t) (hi << 2) | lo;
      |        ^

Apparently the cast applies to (hi << 2), then bitwise-or implicitly promotes to signed int, and that gets assigned to uint16_t raw. At least gcc 10.2.1 from Debian seems to think so.

Fix it by forcing the cast on the complete result.

Merge request reports