diff --git a/src/serialport_linux.cpp b/src/serialport_linux.cpp index 4ee4602012..c87f6a5b58 100755 --- a/src/serialport_linux.cpp +++ b/src/serialport_linux.cpp @@ -8,7 +8,7 @@ int linuxSetCustomBaudRate(const int fd, const unsigned int baudrate) { struct termios2 t; - if(ioctl(fd, TCGETS2, &t)) { + if (ioctl(fd, TCGETS2, &t)) { return -1; } @@ -16,7 +16,7 @@ int linuxSetCustomBaudRate(const int fd, const unsigned int baudrate) { t.c_cflag |= BOTHER; t.c_ospeed = t.c_ispeed = baudrate; - if(ioctl(fd, TCSETS2, &t)) { + if (ioctl(fd, TCSETS2, &t)) { return -2; } @@ -27,11 +27,11 @@ int linuxSetCustomBaudRate(const int fd, const unsigned int baudrate) { int linuxGetSystemBaudRate(const int fd, int* const outbaud) { struct termios2 t; - if(ioctl(fd, TCGETS2, &t)) { + if (ioctl(fd, TCGETS2, &t)) { return -1; } - *outbaud = (int)t.c_ospeed; + *outbaud = static_cast(t.c_ospeed); return 0; } diff --git a/src/serialport_linux.h b/src/serialport_linux.h index 0388ac3210..1a7b98c9c5 100755 --- a/src/serialport_linux.h +++ b/src/serialport_linux.h @@ -1,8 +1,8 @@ -#ifndef CUSTOM_BAUDRATE_H -#define CUSTOM_BAUDRATE_H +#ifndef SRC_SERIALPORT_LINUX_H_ +#define SRC_SERIALPORT_LINUX_H_ int linuxSetCustomBaudRate(const int fd, const unsigned int baudrate); int linuxGetSystemBaudRate(const int fd, int* const outbaud); -#endif +#endif // SRC_SERIALPORT_LINUX_H_ diff --git a/src/serialport_unix.cpp b/src/serialport_unix.cpp index 43e7f741d1..b8979959e6 100644 --- a/src/serialport_unix.cpp +++ b/src/serialport_unix.cpp @@ -114,10 +114,12 @@ int setBaudRate(ConnectionOptionsBaton *data) { int err = linuxSetCustomBaudRate(fd, data->baudRate); if (err == -1) { - snprintf(data->errorString, sizeof(data->errorString), "Error: %s || while retrieving termios2 info", strerror(errno)); + snprintf(data->errorString, sizeof(data->errorString), + "Error: %s || while retrieving termios2 info", strerror(errno)); return -1; - } else if(err == -2) { - snprintf(data->errorString, sizeof(data->errorString), "Error: %s || while setting custom baud rate of %d", strerror(errno), data->baudRate); + } else if (err == -2) { + snprintf(data->errorString, sizeof(data->errorString), + "Error: %s || while setting custom baud rate of %d", strerror(errno), data->baudRate); return -1; } @@ -373,7 +375,7 @@ void EIO_GetBaudRate(uv_work_t* req) { } #endif - // TODO implement on mac + // TODO(Fumon) implement on mac #if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4) snprintf(data->errorString, sizeof(data->errorString), "Error: System baud rate check not implemented on darwin"); return; diff --git a/src/serialport_win.cpp b/src/serialport_win.cpp index 3786e5e2b9..f2276bdafc 100644 --- a/src/serialport_win.cpp +++ b/src/serialport_win.cpp @@ -178,7 +178,7 @@ void EIO_Open(uv_work_t* req) { PurgeComm(file, PURGE_RXCLEAR); PurgeComm(file, PURGE_TXCLEAR); - data->result = static_cast(file); + data->result = (int)file; // NOLINT } void EIO_Update(uv_work_t* req) { @@ -268,7 +268,7 @@ void EIO_GetBaudRate(uv_work_t* req) { return; } - data->baudRate = (int)dcb.BaudRate; + data->baudRate = static_cast(dcb.BaudRate); } bool IsClosingHandle(int fd) { @@ -613,7 +613,7 @@ NAN_METHOD(List) { void EIO_List(uv_work_t* req) { ListBaton* data = static_cast(req->data); - GUID *guidDev = reinterpret_cast(& GUID_DEVCLASS_PORTS); + GUID *guidDev = (GUID*)& GUID_DEVCLASS_PORTS; // NOLINT HDEVINFO hDevInfo = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_PROFILE); SP_DEVINFO_DATA deviceInfoData;