summaryrefslogtreecommitdiffstats
path: root/src/widgets/doc/snippets/qtablewidget-using/main.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-08-01 08:28:35 +0200
committerMarc Mutz <marc.mutz@qt.io>2025-08-18 13:37:38 +0000
commit480ac7bbf450a1d02708dd99740e2235eafdd402 (patch)
tree16a5a164e16c2f9b722aca5c02656929d9dfd463 /src/widgets/doc/snippets/qtablewidget-using/main.cpp
parent70433155f56b68ed2789a10dfe554edb428a0b43 (diff)
QLocale: fix Coverity complaint re: signed → unsigned underflow
Coverity complained that asBmpDigit() may return a negative number, so assigning that to an unsigned variable may thus underflow. The apparent intention of the code is to use the unsigned variable to map negative values to values ≥ 10, to save on one comparison. This is clever™ code, and if Coverity doesn't understand it, the next programmer reading the code likely won't, either. Fix by receiving the result of asBmpDigit() unchanged and explicitly checking for ≥ 0 and < 10. Optimizing these two into a single unsigned comparison is something that the compiler will do automatically, not something the programmer needs to bother about. Even GCC 8.1, even at -O1, turns this into a single cmp <reg>, 9 ja <target> Amends 4931fe9b02f68d59a3a68f4eaf5cf74695686add. Coverity-Id: 474086 Pick-to: 6.10 6.9 6.8 Change-Id: I3df36eb3f545ca0689f2008d45693176f96bfb73 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/widgets/doc/snippets/qtablewidget-using/main.cpp')
0 files changed, 0 insertions, 0 deletions