MISRA-related changes
diff --git a/src/packages/xdc/runtime/Memory.c b/src/packages/xdc/runtime/Memory.c
index 20b4bf8..bfed880 100644
--- a/src/packages/xdc/runtime/Memory.c
+++ b/src/packages/xdc/runtime/Memory.c
@@ -1,19 +1,19 @@
/* --COPYRIGHT--,ESD
- * Copyright (c) 2008 Texas Instruments. All rights reserved.
- * This program and the accompanying materials are made available under the
+ * Copyright (c) 2008-2017 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
* available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse
- * Distribution License is available at
+ * Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Texas Instruments - initial implementation
* --/COPYRIGHT--*/
/*
- * ======== Memory.c ========
+ * ======== Memory.c ========
*/
-
+
#include <xdc/std.h>
#include <xdc/runtime/Error.h>
#include <xdc/runtime/IHeap.h>
@@ -34,14 +34,14 @@
{
Ptr block;
Bool prior = Error_check(eb);
-
+
/* if align == 0, use default alignment */
if (align == 0) {
align = Memory_getMaxDefaultTypeAlign();
}
/* allocate using a non-NULL appropriate heap */
- block = Memory_HeapProxy_alloc(heap ? heap : Memory_defaultHeapInstance,
+ block = Memory_HeapProxy_alloc(heap ? heap : Memory_defaultHeapInstance,
size, align, eb);
/* if the allocator returned NULL and either
@@ -61,7 +61,7 @@
Ptr Memory_calloc(IHeap_Handle heap, SizeT size, SizeT align, Error_Block *eb)
{
/* Call valloc with a value of zero */
- return (Memory_valloc(heap, size, align, 0, eb));
+ return (Memory_valloc(heap, size, align, '\0', eb));
}
/*
@@ -90,12 +90,12 @@
}
/*
- * ======== Memory_query ========
+ * ======== Memory_query ========
*/
Bool Memory_query(IHeap_Handle heap, Int qual)
{
Bool flag = FALSE;
-
+
switch (qual) {
case Memory_Q_BLOCKING:
flag = Memory_HeapProxy_isBlocking(
@@ -104,14 +104,14 @@
default:
break;
}
-
+
return (flag);
}
/*
* ======== Memory_valloc ========
*/
-Ptr Memory_valloc(IHeap_Handle heap, SizeT size, SizeT align, Char value,
+Ptr Memory_valloc(IHeap_Handle heap, SizeT size, SizeT align, Char value,
Error_Block *eb)
{
Ptr block = Memory_alloc(heap, size, align, eb);
diff --git a/src/packages/xdc/runtime/System.c b/src/packages/xdc/runtime/System.c
index 5afadbe..c47486d 100644
--- a/src/packages/xdc/runtime/System.c
+++ b/src/packages/xdc/runtime/System.c
@@ -1,10 +1,10 @@
/* --COPYRIGHT--,ESD
- * Copyright (c) 2008 Texas Instruments. All rights reserved.
- * This program and the accompanying materials are made available under the
+ * Copyright (c) 2008-2017 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
* available at http://www.eclipse.org/legal/epl-v10.html and the Eclipse
- * Distribution License is available at
+ * Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
@@ -47,7 +47,7 @@
/*
* ======== vaRef ========
* Return the address of a VaList (aka va_list)
- *
+ *
* If va_list is an array type, taking the address of the va_list va simply
* returns va itself. Moreover, when such a va_list is passed to a
* function, C implicitly passes the address rather than the va_list array
@@ -105,7 +105,7 @@
{
IArg key;
Bool status = TRUE;
-
+
key = Gate_enterSystem();
if (module->numAtexitHandlers < System_maxAtexitHandlers) {
@@ -117,7 +117,7 @@
}
Gate_leaveSystem(key);
-
+
return (status);
}
@@ -214,7 +214,7 @@
*/
Int System_avprintf(CString fmt, VaList va)
{
- return (System_SupportProxy_ready()
+ return ((System_SupportProxy_ready() != 0u)
? System_doPrint(NULL, (SizeT)-1, fmt, vaRef(va), TRUE) : -1);
}
@@ -292,10 +292,10 @@
*
* If buf == NULL, characters are sent to System_SupportProxy_putch();
* otherwise, they are written into buf. Atmost `n` - 1 characters are written
- * excluding '\0'.
+ * excluding '\0'.
*
- * The return value is the number of characters that would have
- * been written had `n` been sufficiently large, not counting the terminating
+ * The return value is the number of characters that would have
+ * been written had `n` been sufficiently large, not counting the terminating
* '\0' character.
*/
Int System_doPrint(Char *buf, SizeT n, CString fmt, VaList *pva, Bool aFlag)
@@ -305,7 +305,7 @@
Char c;
Int res;
Char outbuf[OUTMAX];
-
+
/* vars passed to System_extendFxn. Also keep track in while loop */
struct System_ParseData parse;
@@ -372,7 +372,7 @@
if (parse.precis < 0) {
parse.precis = 0;
}
-
+
c = *fmt++;
}
else {
@@ -387,7 +387,7 @@
if (parse.zpad) {
parse.zpad = parse.width;
}
-
+
/* check for presence of l flag (e.g., %ld) */
if (c == 'l' || c == 'L') {
parse.lFlag = TRUE;
@@ -407,7 +407,7 @@
parse.aFlag ? (IntMax)va_arg(*pva, IArg) :
parse.lFlag ? (IntMax)va_arg(*pva, long int) :
(IntMax)va_arg(*pva, int);
-
+
if (parse.precis > parse.zpad) {
parse.zpad = parse.precis;
}
@@ -480,7 +480,7 @@
/* compute number of characters left in field */
parse.width -= parse.len;
- if (!parse.lJust) {
+ if (parse.lJust == 0) {
/* pad with blanks on left */
while (--parse.width >= 0) {
System_putchar(&buf, ' ', &n);
@@ -549,8 +549,8 @@
/* compute digits in number from right to left */
do {
- *(--ptr) = "0123456789abcdef"[(Int)(n % base)];
- n = n / base;
+ *(--ptr) = "0123456789abcdef"[n % (UInt)base];
+ n = n / (UInt)base;
++i;
} while (n);
@@ -573,9 +573,9 @@
*
* Write character `c` to the buffer and, if the buffer pointer is
* non-NULL, update the buffer pointer.
- *
- * Keeps track of the number of characters written into the buffer by
- * modifying bufsize `n`. Atmost, `n` - 1 characters are written.
+ *
+ * Keeps track of the number of characters written into the buffer by
+ * modifying bufsize `n`. Atmost, `n` - 1 characters are written.
*/
Void System_putchar(Char **bufp, Char c, SizeT *n)
{
@@ -583,7 +583,7 @@
if ((*n) <= 1) {
return;
}
-
+
/* decrement n to keep track of the number of chars written */
(*n)--;