This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] [MSP430] Fix definition of write() to use const char * for the type of the buffer


The type of the 2nd argument to the write syscall (the buffer), should have
the const qualifier.
This patch fixes that for MSP430.

If acceptable, I would appreciate if someone could commit this for me, as I do
not have write access.

Thanks,
Jozef
>From c53aaef5e4ce488db23e929fa5c7cb6c1deb620a Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Fri, 12 Apr 2019 11:49:11 +0100
Subject: [PATCH] [MSP430] Fix definition of write() to use const char * for
 the type of the buffer

---
 libgloss/msp430/write.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libgloss/msp430/write.c b/libgloss/msp430/write.c
index 3a5a9f810..3e1086c00 100644
--- a/libgloss/msp430/write.c
+++ b/libgloss/msp430/write.c
@@ -16,7 +16,7 @@
 #include "cio.h"
 
 static int
-write_chunk (int fd, char *buf, int len)
+write_chunk (int fd, const char *buf, int len)
 {
   __CIOBUF__.length[0] = len;
   __CIOBUF__.length[1] = len >> 8;
@@ -35,10 +35,11 @@ write_chunk (int fd, char *buf, int len)
 #include <stdio.h>
 
 int
-write (int fd, char *buf, int len)
+write (int fd, const char *buf, int len)
 {
   int rv = 0;
   int c;
+  int i = 0;
 #if 0
   if (fd == 2)
     fprintf (stderr, "%.*s", buf, len);
@@ -48,12 +49,12 @@ write (int fd, char *buf, int len)
   while (len > 0)
     {
       int l = (len > CIO_BUF_SIZE) ? CIO_BUF_SIZE : len;
-      c = write_chunk (fd, buf, l);
+      c = write_chunk (fd, buf + i, l);
       if (c < 0)
 	return c;
       rv += l;
       len -= l;
-      buf += l;
+      i += l;
     }
   return rv;
 }
-- 
2.17.1


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]