summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qlocale_tools.cpp
diff options
context:
space:
mode:
authorEdward Welbourne <edward.welbourne@qt.io>2017-09-27 11:14:11 +0200
committerEdward Welbourne <edward.welbourne@qt.io>2017-10-03 08:38:17 +0000
commitee84db4c18562c5dfeb1e7cf2d9fb1fcd4490dfa (patch)
treec1edbac63021b0d9562f38d054921dbc1a582228 /src/corelib/tools/qlocale_tools.cpp
parent196f7af6e242b375e315f051c820f53ef444d1f3 (diff)
QLocaleData::longLongToString: clean up sign handling
In qlltoa we simply discarded sign, passing absolute value down to qulltoa; given that it had just one caller and did something only that caller is apt to want - violating the principle of least surprise for those who would expect it to handle sign sanely - it is better to just inline it in the one place it was used. That one place, QLocaleData::longLongToString(), handles sign separately and (for reasons I shall argue elsewhere are bogus) ignores sign for bases other than ten. When ignoring sign, it passes negative values directly to qulltoa, which caught the attention of Coverity (CID 22326). This deliberately cast (for the same bogus reasons) negatives to large unsigned. Inlining base ten's call to qlltoa() as a call to qulltoa() could now be unified into a simple (and less obviously perverse) form. Making the (contentious) cast explicit can then calm Coverity and we get a simpler implementation all round. Incorporate also Marc Mutz's fix for unary minus applied to unsigned and handling of the most negative value, suitably adapted. Change-Id: Iea02500a5dd7c6d7ac6e73656e1b11f116ae85c6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qlocale_tools.cpp')
-rw-r--r--src/corelib/tools/qlocale_tools.cpp5
1 files changed, 0 insertions, 5 deletions
diff --git a/src/corelib/tools/qlocale_tools.cpp b/src/corelib/tools/qlocale_tools.cpp
index 3e4f37501e..4d969a4723 100644
--- a/src/corelib/tools/qlocale_tools.cpp
+++ b/src/corelib/tools/qlocale_tools.cpp
@@ -456,11 +456,6 @@ QString qulltoa(qulonglong l, int base, const QChar _zero)
return QString(reinterpret_cast<QChar *>(p), 65 - (p - buff));
}
-QString qlltoa(qlonglong l, int base, const QChar zero)
-{
- return qulltoa(l < 0 ? -l : l, base, zero);
-}
-
QString &decimalForm(QChar zero, QChar decimal, QChar group,
QString &digits, int decpt, int precision,
PrecisionMode pm,