Use size_t when dealing with strings and strlen. (Alexandre)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4232
This commit is contained in:
parent
747190b04e
commit
f74067c2b0
2 changed files with 10 additions and 9 deletions
|
@ -41,7 +41,7 @@ bool SERIAL_open(const char* portname, COMPORT* port) {
|
|||
|
||||
// open the port in NT object space (recommended by Microsoft)
|
||||
// allows the user to open COM10+ and custom port names.
|
||||
int len = strlen(portname);
|
||||
size_t len = strlen(portname);
|
||||
if(len > 240) {
|
||||
SetLastError(ERROR_BUFFER_OVERFLOW);
|
||||
free(cp);
|
||||
|
@ -125,7 +125,7 @@ void SERIAL_close(COMPORT port) {
|
|||
free(port);
|
||||
}
|
||||
|
||||
void SERIAL_getErrorString(char* buffer, int length) {
|
||||
void SERIAL_getErrorString(char* buffer, size_t length) {
|
||||
int error = GetLastError();
|
||||
if(length < 50) return;
|
||||
memset(buffer,0,length);
|
||||
|
@ -141,7 +141,7 @@ void SERIAL_getErrorString(char* buffer, int length) {
|
|||
const char* err5text = "The specified port is already in use.\n";
|
||||
const char* err2text = "The specified port does not exist.\n";
|
||||
|
||||
int sysmsg_offset = 0;
|
||||
size_t sysmsg_offset = 0;
|
||||
|
||||
if(error == 5) {
|
||||
sysmsg_offset = strlen(err5text);
|
||||
|
@ -287,7 +287,7 @@ bool SERIAL_open(const char* portname, COMPORT* port) {
|
|||
|
||||
cp->breakstatus=false;
|
||||
|
||||
int len = strlen(portname);
|
||||
size_t len = strlen(portname);
|
||||
if(len > 240) {
|
||||
///////////////////////////////////SetLastError(ERROR_BUFFER_OVERFLOW);
|
||||
return false;
|
||||
|
@ -299,7 +299,7 @@ bool SERIAL_open(const char* portname, COMPORT* port) {
|
|||
if (cp->porthandle < 0) goto cleanup_error;
|
||||
|
||||
result = tcgetattr(cp->porthandle,&cp->backup);
|
||||
if (result==-1) goto cleanup_error;
|
||||
if (result == -1) goto cleanup_error;
|
||||
|
||||
// get port settings
|
||||
termios termInfo;
|
||||
|
@ -334,7 +334,7 @@ void SERIAL_close(COMPORT port) {
|
|||
free(port);
|
||||
}
|
||||
|
||||
void SERIAL_getErrorString(char* buffer, int length) {
|
||||
void SERIAL_getErrorString(char* buffer, size_t length) {
|
||||
int error = errno;
|
||||
if(length < 50) return;
|
||||
memset(buffer,0,length);
|
||||
|
@ -344,7 +344,7 @@ void SERIAL_getErrorString(char* buffer, int length) {
|
|||
const char* err5text = "The specified port is already in use.\n";
|
||||
const char* err2text = "The specified port does not exist.\n";
|
||||
|
||||
int sysmsg_offset = 0;
|
||||
size_t sysmsg_offset = 0;
|
||||
|
||||
if(error == EBUSY) {
|
||||
sysmsg_offset = strlen(err5text);
|
||||
|
@ -548,7 +548,7 @@ cleanup_error:
|
|||
return false;
|
||||
}
|
||||
|
||||
void SERIAL_getErrorString(char* buffer, int length) {
|
||||
void SERIAL_getErrorString(char* buffer, size_t length) {
|
||||
sprintf(buffer, "TODO: error handling is not fun");
|
||||
}
|
||||
void SERIAL_close(COMPORT port) {
|
||||
|
|
|
@ -16,12 +16,13 @@
|
|||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
typedef struct _COMPORT *COMPORT;
|
||||
|
||||
bool SERIAL_open(const char* portname, COMPORT* port);
|
||||
void SERIAL_close(COMPORT port);
|
||||
void SERIAL_getErrorString(char* buffer, int length);
|
||||
void SERIAL_getErrorString(char* buffer, size_t length);
|
||||
|
||||
#define SERIAL_1STOP 1
|
||||
#define SERIAL_2STOP 2
|
||||
|
|
Loading…
Add table
Reference in a new issue