rsynd-2.5.1 / io.c patches

John Malmberg wb8tyw at qsl.net
Sun Jan 13 11:55:44 EST 2002


Platform: Compaq OpenVMS Alpha 7.3
Compiler: Compaq C T6.5

The following patch resolves compile problems with the IO.C module.

The (char) type was being used where (void) was more appropriate based 
on the actual use of the code.

The (char) type was also being used where the usage was actually an 
(unsigned char).

const qualifiers were added to improve compile efficiency.

EAGLE> type io.gdiff
--- ref_src:io.c        Sat Jan  5 13:27:04 2002
+++ lcl_src:io.c        Sat Jan 12 18:29:18 2002
@@ -1,3 +1,4 @@
+/* Converted by prj_src:unix_c_to_vms_c.tpu AND PRJ_SRC:IO.TPU on 
12-JAN-2002 18:29:18.32 OPENVMS_AXP */
  /* -*- c-file-style: "linux" -*-

     Copyright (C) 1996-2001 by Andrew Tridgell
@@ -49,7 +50,7 @@

  static int io_error_fd = -1;

-static void read_loop(int fd, char *buf, int len);
+static void read_loop(int fd, void *buf, int len);

  static void check_timeout(void)
  {
@@ -163,9 +164,11 @@
   * give a better explanation.  We can tell whether the connection has
   * started by looking e.g. at whether the remote version is known yet.
   */
-static int read_timeout (int fd, char *buf, int len)
+static int read_timeout (int fd, void *buf1, int len)
  {
         int n, ret=0;
+       unsigned char * buf;
+       buf = (unsigned char *)buf1;

         io_flush();

@@ -236,8 +239,10 @@

  /*! Continue trying to read len bytes - don't return until len has
    been read.   */
-static void read_loop (int fd, char *buf, int len)
+static void read_loop (int fd, void *buf1, int len)
  {
+       unsigned char * buf;
+       buf = (unsigned char *)buf1;
         while (len) {
                 int n = read_timeout(fd, buf, len);

@@ -253,11 +258,11 @@
   *
   * Never returns <= 0.
   */
-static int read_unbuffered(int fd, char *buf, int len)
+static int read_unbuffered(int fd, void *buf, int len)
  {
         static int remaining;
         int tag, ret=0;
-       char line[1024];
+       unsigned char line[1024];

         if (!io_multiplexing_in || fd != multiplex_in_fd)
                 return read_timeout(fd, buf, len);
@@ -305,10 +310,12 @@

  /* do a buffered read from fd. don't return until all N bytes
     have been read. If all N can't be read then exit with an error */
-static void readfd (int fd, char *buffer, int N)
+static void readfd (int fd, void *buffer1, int N)
  {
         int  ret;
         int total=0;
+       unsigned char * buffer;
+       buffer = (unsigned char *)buffer1;

         while (total < N) {
                 io_flush();
@@ -323,7 +330,7 @@

  int32 read_int(int f)
  {
-       char b[4];
+       unsigned char b[4];
         int32 ret;

         readfd(f,b,4);
@@ -336,7 +343,7 @@
  {
         extern int remote_version;
         int64 ret;
-       char b[8];
+       unsigned char b[8];
         ret = read_int(f);

         if ((int32)ret != (int32)0xffffffff) {
@@ -356,13 +363,15 @@
         return ret;
  }

-void read_buf(int f,char *buf,int len)
+void read_buf(int f, void *buf,int len)
  {
         readfd(f,buf,len);
  }

-void read_sbuf(int f,char *buf,int len)
+void read_sbuf(int f, void *buf1,int len)
  {
+unsigned char * buf;
+       buf = (unsigned char *)buf1;
         read_buf (f,buf,len);
         buf[len] = 0;
  }
@@ -375,12 +384,14 @@
  }

  /* write len bytes to fd */
-static void writefd_unbuffered(int fd,char *buf,int len)
+static void writefd_unbuffered(int fd, const void * buf1,int len)
  {
         int total = 0;
         fd_set w_fds, r_fds;
         int fd_count, count;
         struct timeval tv;
+unsigned char * buf;
+       buf = (unsigned char *)buf1;

         err_list_push();

@@ -469,24 +480,26 @@
  }


-static char *io_buffer;
+static unsigned char *io_buffer;
  static int io_buffer_count;

  void io_start_buffering(int fd)
  {
         if (io_buffer) return;
         multiplex_out_fd = fd;
-       io_buffer = (char *)malloc(IO_BUFFER_SIZE);
+       io_buffer = malloc(IO_BUFFER_SIZE);
         if (!io_buffer) out_of_memory("writefd");
         io_buffer_count = 0;
  }

  /* write an message to a multiplexed stream. If this fails then rsync
     exits */
-static void mplex_write(int fd, enum logcode code, char *buf, int len)
+static void mplex_write(int fd, enum logcode code, const void *buf1, 
int len)
  {
-       char buffer[4096];
+       unsigned char buffer[4096];
         int n = len;
+unsigned char * buf;
+       buf = (unsigned char *)buf1;

         SIVAL(buffer, 0, ((MPLEX_BASE + (int)code)<<24) + len);

@@ -533,8 +546,10 @@
         }
  }

-static void writefd(int fd,char *buf,int len)
+static void writefd(int fd, const void * buf1,int len)
  {
+unsigned char * buf;
+       buf = (unsigned char *)buf1;
         stats.total_written += len;

         err_list_push();
@@ -560,7 +575,7 @@

  void write_int(int f,int32 x)
  {
-       char b[4];
+       unsigned char b[4];
         SIVAL(b,0,x);
         writefd(f,b,4);
  }
@@ -573,7 +588,7 @@
  void write_longint(int f, int64 x)
  {
         extern int remote_version;
-       char b[8];
+       unsigned char b[8];

         if (remote_version < 16 || x <= 0x7FFFFFFF) {
                 write_int(f, (int)x);
@@ -587,13 +602,13 @@
         writefd(f,b,8);
  }

-void write_buf(int f,char *buf,int len)
+void write_buf(int f,const void *buf,int len)
  {
         writefd(f,buf,len);
  }

  /* write a string to the connection */
-static void write_sbuf(int f,char *buf)
+static void write_sbuf(int f,const char *buf)
  {
         write_buf(f, buf, strlen(buf));
  }
@@ -601,13 +616,15 @@

  void write_byte(int f,unsigned char c)
  {
-       write_buf(f,(char *)&c,1);
+       write_buf(f, &c,1);
  }



-int read_line(int f, char *buf, int maxlen)
+int read_line(int f, void *buf1, int maxlen)
  {
+unsigned char * buf;
+       buf = (unsigned char *)buf1;
         while (maxlen) {
                 buf[0] = 0;
                 read_buf(f, buf, 1);
@@ -664,7 +681,7 @@
  }

  /* write an message to the multiplexed error stream */
-int io_multiplex_write(enum logcode code, char *buf, int len)
+int io_multiplex_write(enum logcode code, const void *buf, int len)
  {
         if (!io_multiplexing_out) return 0;






More information about the rsync mailing list