[PATCH] MSP430: Fix message in sbrk.c printing binary character

Jozef Lawrynowicz jozef.l@mittosystems.com
Thu Sep 3 10:23:30 GMT 2020


The call to write() in sbrk.c was using the wrong value for the length
argument, causing the NUL terminating character of the string to be
printed.

If the patch is acceptable, I would appreciate if someone would commit
it for me, as I do not have write access.

Thanks,
Jozef
-------------- next part --------------
>From 36c92acd1d6f4bbce4dccf837bbd249b838cd908 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Wed, 2 Sep 2020 16:16:55 +0100
Subject: [PATCH] MSP430: Fix message in sbrk.c printing binary character

The call to write() in sbrk.c was using the wrong value for the length
argument, causing the NUL terminating character of the string to be
printed.

---
 libgloss/msp430/sbrk.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libgloss/msp430/sbrk.c b/libgloss/msp430/sbrk.c
index bbc3fb5ba..8e4339f6e 100644
--- a/libgloss/msp430/sbrk.c
+++ b/libgloss/msp430/sbrk.c
@@ -24,8 +24,8 @@ _sbrk (int adj)
 
   if (heap + adj > sp)
     {
-#define MESSAGE "Heap and stack collision\n"
-      write (1, MESSAGE, sizeof MESSAGE);
+      const char * const msg = "Heap and stack collision\n";
+      write (1, msg, sizeof (msg) - 1);
       abort ();
     }
 
-- 
2.28.0



More information about the Newlib mailing list