MISRA changes
diff --git a/src/packages/xdc/runtime/Error.c b/src/packages/xdc/runtime/Error.c
index fc7b583..708f64d 100644
--- a/src/packages/xdc/runtime/Error.c
+++ b/src/packages/xdc/runtime/Error.c
@@ -1,5 +1,5 @@
/* --COPYRIGHT--,ESD
- * Copyright (c) 2008-2019 Texas Instruments Incorporated
+ * Copyright (c) 2008-2020 Texas Instruments Incorporated
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License
* v. 1.0 which accompanies this distribution. The Eclipse Public License is
@@ -182,8 +182,10 @@
for(;;) {
}
}
- else if (eb != &xdc_runtime_Error_IgnoreBlock) {
- eb->id = id;
+ else {
+ if (eb != &xdc_runtime_Error_IgnoreBlock) {
+ eb->id = id;
+ }
}
}
diff --git a/src/packages/xdc/runtime/Text.c b/src/packages/xdc/runtime/Text.c
index 2c4bec3..84e02df 100644
--- a/src/packages/xdc/runtime/Text.c
+++ b/src/packages/xdc/runtime/Text.c
@@ -163,12 +163,13 @@
/* -1 conversion to UInt is well defined so -1-res will result in a
* practically infinite output.
*/
- res += Text_xprintf(bufp, (UInt)len - (UInt)res, "%p", lab->handle);
+ res += Text_xprintf(bufp, (SizeT)len - (SizeT)res, "%p", lab->handle);
}
if (lab->named == TRUE
&& (len < 0 || (len - res) >= (5 + (Int)strlen(lab->iname))) ) {
- res += Text_xprintf(bufp, (UInt)len - (UInt)res, "('%s')", lab->iname);
+ res += Text_xprintf(bufp, (SizeT)len - (SizeT)res, "('%s')",
+ lab->iname);
}
return (res);
@@ -238,10 +239,14 @@
res = (UShort)Text_putMod(site->mod, bufp, (Int)max);
}
- if ((UInt)(max - res) > 0U) {
+ /* The call to putMod() above guarantees that max >= res. Also, UShort casts
+ * are not needed, but Klocwork emits
+ * MISRA.ETYPE.COMP.CAST.EXPL.WIDER.2012 without them.
+ */
+ if ((UShort)(max - res) > (UShort)0) {
/* Don't output this if there's no mod */
if (site->mod != 0U) {
- res += (UShort)Text_xprintf(bufp, (UInt)max - (UInt)res, ": ");
+ res += (UShort)Text_xprintf(bufp, (SizeT)max - (SizeT)res, ": ");
}
if (site->line == 0) {
@@ -251,15 +256,18 @@
if (site->file != (CString)NULL
&& ((UShort)(max - res) >= (strlen(site->file) + 5U))) {
res += (UShort)
- Text_xprintf(bufp, (UInt)max - (UInt)res, "\"%s\", ",
+ Text_xprintf(bufp, (SizeT)max - (SizeT)res, "\"%s\", ",
site->file);
}
/* 7 + 1 = length of "line : " including '\0', 10 = max decimal digits
- in 32-bit number */
- if ((UInt)(max - res) >= (8U + 10U)) {
+ * in 32-bit number.
+ * UShort casts are not needed, but Klocwork emits
+ * MISRA.ETYPE.COMP.CAST.EXPL.WIDER.2012 without them.
+ */
+ if ((UShort)(max - res) >= (UShort)(7 + 1 + 10)) {
res += (UShort)
- Text_xprintf(bufp, (UInt)max - (UInt)res, "line %d: ",
+ Text_xprintf(bufp, (SizeT)max - (SizeT)res, "line %d: ",
site->line);
}
}