ICU-13177 Fixing coverity issues in number formatting code.

X-SVN-Rev: 40553
This commit is contained in:
Shane Carr 2017-10-04 22:28:09 +00:00
parent 78944eae33
commit e2f537d42f
5 changed files with 17 additions and 3 deletions

View file

@ -8,6 +8,7 @@ import com.ibm.icu.util.ULocale;
public class CustomSymbolCurrency extends Currency {
private static final long serialVersionUID = 2497493016770137670L;
// TODO: Serialization methods?
private String symbol1;
private String symbol2;
@ -60,4 +61,16 @@ public class CustomSymbolCurrency extends Currency {
public String getCurrencyCode() {
return symbol2;
}
@Override
public int hashCode() {
return super.hashCode() ^ symbol1.hashCode() ^ symbol2.hashCode();
}
@Override
public boolean equals(Object other) {
return super.equals(other)
&& ((CustomSymbolCurrency)other).symbol1.equals(symbol1)
&& ((CustomSymbolCurrency)other).symbol2.equals(symbol2);
}
}

View file

@ -31,6 +31,7 @@ public final class DecimalQuantity_DualStorageBCD extends DecimalQuantity_Abstra
public DecimalQuantity_DualStorageBCD() {
setBcdToZero();
flags = 0;
}
public DecimalQuantity_DualStorageBCD(long input) {

View file

@ -120,7 +120,7 @@ public class CompactNotation extends Notation {
StandardPlural plural = quantity.getStandardPlural(rules);
String patternString = data.getPattern(magnitude, plural);
@SuppressWarnings("unused") // see #13177
@SuppressWarnings("unused") // see #13075
int numDigits = -1;
if (patternString == null) {
// Use the default (non-compact) modifier.

View file

@ -145,7 +145,7 @@ public class FormattedNumber {
NumberStringBuilder temp = new NumberStringBuilder();
int length = micros.modOuter.apply(temp, 0, 0);
length += micros.modMiddle.apply(temp, 0, length);
length += micros.modInner.apply(temp, 0, length);
/* length += */ micros.modInner.apply(temp, 0, length);
int prefixLength = micros.modOuter.getPrefixLength() + micros.modMiddle.getPrefixLength()
+ micros.modInner.getPrefixLength();
return temp.subSequence(0, prefixLength).toString();

View file

@ -349,7 +349,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
if (cc == digitStr.length()) {
// One code point in this digit.
// If it is 1 UTF-16 code unit long, set it in tmpDigits.
if (cc == 1) {
if (cc == 1 && tmpDigits != null) {
tmpDigits[i] = (char) cp;
} else {
tmpDigits = null;