From 147c27da52c94422796e8eb0ca3d274bc1954396 Mon Sep 17 00:00:00 2001 From: troth Date: Thu, 13 Mar 2003 19:25:27 +0000 Subject: [PATCH] * ser_posix.c, ser_win32.c, serial.h: Change baud from int to long to avoid a 16-bit int overflow. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@291 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 5 +++++ ser_posix.c | 8 ++++---- ser_win32.c | 6 ++++-- serial.h | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index f5bc20cb..61f10a5a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-03-13 Theodore A. Roth + + * ser_posix.c, ser_win32.c, serial.h: + Change baud from int to long to avoid a 16-bit int overflow. + 2003-03-12 Theodore A. Roth * Makefile.am (avrdude_SOURCES): Add avr910.[ch], serial.h and diff --git a/ser_posix.c b/ser_posix.c index b2a2ca9e..fea1c9b8 100644 --- a/ser_posix.c +++ b/ser_posix.c @@ -36,7 +36,7 @@ extern char *progname; struct baud_mapping { - int baud; + long baud; speed_t speed; }; @@ -55,7 +55,7 @@ static struct baud_mapping baud_lookup_table [] = { { 0, 0 } /* Terminator. */ }; -static speed_t serial_baud_lookup(int baud) +static speed_t serial_baud_lookup(long baud) { struct baud_mapping *map = baud_lookup_table; @@ -65,12 +65,12 @@ static speed_t serial_baud_lookup(int baud) map++; } - fprintf(stderr, "%s: serial_baud_lookup(): unknown baud rate: %d", + fprintf(stderr, "%s: serial_baud_lookup(): unknown baud rate: %ld", progname, baud); exit(1); } -static int serial_setattr(int fd, int baud) +static int serial_setattr(int fd, long baud) { int rc; struct termios termios; diff --git a/ser_win32.c b/ser_win32.c index 8ddf17fe..3b0555f2 100644 --- a/ser_win32.c +++ b/ser_win32.c @@ -20,14 +20,16 @@ /* $Id$ */ /* - * Posix serial interface for avrdude. + * Native Win32 serial interface for avrdude. */ +#include "serial.h" + extern char *progname; #if 0 -int serial_open(char * port, int baud) +int serial_open(char * port, long baud) { return fd; } diff --git a/serial.h b/serial.h index b8aaf3ff..c84c45df 100644 --- a/serial.h +++ b/serial.h @@ -32,7 +32,7 @@ #include "config.h" -extern int serial_open(char * port, int baud); +extern int serial_open(char * port, long baud); extern void serial_close(int fd); extern int serial_send(int fd, char * buf, size_t buflen);