edid: fix uint16_t conversion warning

../../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.

Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.com>
This commit is contained in:
Pekka Paalanen 2022-10-13 13:03:16 +03:00
parent 619fc30c7b
commit 56be915e27

2
edid.c
View file

@ -247,7 +247,7 @@ decode_chromaticity_coord(uint8_t hi, uint8_t lo)
{
uint16_t raw; /* only 10 bits are used */
raw = (uint16_t) (hi << 2) | lo;
raw = (uint16_t) ((hi << 2) | lo);
return (float) raw / 1024;
}