public inbox for newlib-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Fix definition of write() to use const char * for the type of the buffer
@ 2019-04-15 12:22 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-04-15 12:22 UTC (permalink / raw)
  To: newlib-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a2e81650d159d539d078194fa88f297b4fde77e5

commit a2e81650d159d539d078194fa88f297b4fde77e5
Author: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date:   Fri Apr 12 11:49:11 2019 +0100

    Fix definition of write() to use const char * for the type of the buffer

Diff:
---
 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 3a5a9f8..3e1086c 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;
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-15 12:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-15 12:22 [newlib-cygwin] Fix definition of write() to use const char * for the type of the buffer Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).