Commit 8109b9b6bf934a39e73c90fb804e2d5af02391d1

Authored by aurel32
1 parent 49237acd

[PATCH] usb-serial: Fix data corruption with usb serial emulation

* Remove the unused send_buf variable and its constant.

* Fix a math error
  The variables recv_ptr and recv_used are not large enough to hold
  the constant 384, which causes data corruption when the pointer is
  reset with: s->recv_ptr = (s->recv_ptr + len) % RECV_BUF;

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5242 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 2 additions and 4 deletions
hw/usb-serial.c
@@ -22,7 +22,6 @@ do { printf(&quot;usb-serial: &quot; fmt , ##args); } while (0) @@ -22,7 +22,6 @@ do { printf(&quot;usb-serial: &quot; fmt , ##args); } while (0)
22 #endif 22 #endif
23 23
24 #define RECV_BUF 384 24 #define RECV_BUF 384
25 -#define SEND_BUF 128 // Not used for now  
26 25
27 /* Commands */ 26 /* Commands */
28 #define FTDI_RESET 0 27 #define FTDI_RESET 0
@@ -94,9 +93,8 @@ typedef struct { @@ -94,9 +93,8 @@ typedef struct {
94 uint16_t vendorid; 93 uint16_t vendorid;
95 uint16_t productid; 94 uint16_t productid;
96 uint8_t recv_buf[RECV_BUF]; 95 uint8_t recv_buf[RECV_BUF];
97 - uint8_t recv_ptr;  
98 - uint8_t recv_used;  
99 - uint8_t send_buf[SEND_BUF]; 96 + uint16_t recv_ptr;
  97 + uint16_t recv_used;
100 uint8_t event_chr; 98 uint8_t event_chr;
101 uint8_t error_chr; 99 uint8_t error_chr;
102 uint8_t event_trigger; 100 uint8_t event_trigger;