Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switch to unsigned-char buffer. Closes #1.

  • Loading branch information...
commit 6e0138f476603c63ccaa5ab1c5a9fa268dc1bae0 1 parent 6de6938
Tony Garnock-Jones tonyg authored
Showing with 11 additions and 11 deletions.
  1. +11 −11 c_src/serial.c
22 c_src/serial.c
View
@@ -236,7 +236,7 @@ void set_tty_speed(int fd, speed_t new_ispeed, speed_t new_ospeed)
* Desc: returns the size of a two_byte_header message (from Erlang).
*/
-int get_tbh_size(char buf[])
+int get_tbh_size(unsigned char buf[])
{
return (((int) buf[0]) << 8) + ((int) buf[1]);
}
@@ -246,10 +246,10 @@ int get_tbh_size(char buf[])
* Desc: sets the first two bytes of the buffer to its size
*/
-void set_tbh_size(char buf[], int size)
+void set_tbh_size(unsigned char buf[], int size)
{
- buf[1] = (char) (size & 0xff);
- buf[0] = (char) ((size >> 8) & 0xff);
+ buf[1] = (unsigned char) (size & 0xff);
+ buf[0] = (unsigned char) ((size >> 8) & 0xff);
return;
}
@@ -259,7 +259,7 @@ void set_tbh_size(char buf[], int size)
* at the beginning.
*/
-void tbh_write(int fd, char buf[], int buffsize)
+void tbh_write(int fd, unsigned char buf[], int buffsize)
{
char header_buf[TBHSIZE];
@@ -283,7 +283,7 @@ void tbh_write(int fd, char buf[], int buffsize)
*
*/
-int tbh_read(int fd, char buf[], int buffsize)
+int tbh_read(int fd, unsigned char buf[], int buffsize)
{
int remaining, msgsize;
@@ -310,7 +310,7 @@ int tbh_read(int fd, char buf[], int buffsize)
* Returns: The number of bytes read, or 0 if stream closed.
*/
-int read_at_least(int fd, char buf[], int nr)
+int read_at_least(int fd, unsigned char buf[], int nr)
{
int remaining = nr;
int nr_read = 0;
@@ -339,7 +339,7 @@ int read_at_least(int fd, char buf[], int nr)
*/
void write_to_tty(int ttyfd, int fillfd, int totalsize, int buffsize,
- char buf[], int buffmaxsize)
+ unsigned char buf[], int buffmaxsize)
{
write(ttyfd,buf,buffsize);
totalsize -= buffsize;
@@ -463,7 +463,7 @@ main(int argc, char *argv[])
{
fd_set readfds; /* file descriptor bit field for select */
int maxfd; /* max file descriptor for select */
- char buf[MAXLENGTH]; /* buffer for transfer between serial-user */
+ unsigned char buf[MAXLENGTH]; /* buffer for transfer between serial-user */
int escapes; /* number of consecutive escapes in cbreak */
/* Set up initial bit field for select */
@@ -605,7 +605,7 @@ main(int argc, char *argv[])
case OPEN: /******************************/
Debug("received OPEN ");
/* Terminate string */
- buf[nr_read] = (char) 0;
+ buf[nr_read] = '\0';
strcpy(ttyname,&buf[HEADERSIZE]);
open:
@@ -644,7 +644,7 @@ main(int argc, char *argv[])
in_speed = get_speed(atoi(&buf[HEADERSIZE]));
/* Null-terminate string */
- buf[nr_read] = (char) 0;
+ buf[nr_read] = '\0';
/* Find start of second speed */
for(off=HEADERSIZE ;
Please sign in to comment.
Something went wrong with that request. Please try again.