Skip to content

Commit

Permalink
Make linter happier.
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanSanchez committed Feb 27, 2018
1 parent 7ab7094 commit 40592eb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/serialport_linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
int linuxSetCustomBaudRate(const int fd, const unsigned int baudrate) {
struct termios2 t;

if(ioctl(fd, TCGETS2, &t)) {
if (ioctl(fd, TCGETS2, &t)) {
return -1;
}

t.c_cflag &= ~CBAUD;
t.c_cflag |= BOTHER;
t.c_ospeed = t.c_ispeed = baudrate;

if(ioctl(fd, TCSETS2, &t)) {
if (ioctl(fd, TCSETS2, &t)) {
return -2;
}

Expand All @@ -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<int>(t.c_ospeed);

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions src/serialport_linux.h
Original file line number Diff line number Diff line change
@@ -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_

10 changes: 6 additions & 4 deletions src/serialport_unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/serialport_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ void EIO_Open(uv_work_t* req) {
PurgeComm(file, PURGE_RXCLEAR);
PurgeComm(file, PURGE_TXCLEAR);

data->result = static_cast<int>(file);
data->result = (int)file; // NOLINT
}

void EIO_Update(uv_work_t* req) {
Expand Down Expand Up @@ -268,7 +268,7 @@ void EIO_GetBaudRate(uv_work_t* req) {
return;
}

data->baudRate = (int)dcb.BaudRate;
data->baudRate = static_cast<int>(dcb.BaudRate);
}

bool IsClosingHandle(int fd) {
Expand Down Expand Up @@ -613,7 +613,7 @@ NAN_METHOD(List) {
void EIO_List(uv_work_t* req) {
ListBaton* data = static_cast<ListBaton*>(req->data);

GUID *guidDev = reinterpret_cast<GUID*>(& GUID_DEVCLASS_PORTS);
GUID *guidDev = (GUID*)& GUID_DEVCLASS_PORTS; // NOLINT
HDEVINFO hDevInfo = SetupDiGetClassDevs(guidDev, NULL, NULL, DIGCF_PRESENT | DIGCF_PROFILE);
SP_DEVINFO_DATA deviceInfoData;

Expand Down

0 comments on commit 40592eb

Please sign in to comment.