Skip to content

Commit 3fdb582

Browse files
author
noasakurajin
committed
removing no longer needed c headers
1 parent 80e3fd5 commit 3fdb582

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

‎meson.build‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,12 @@ unix_c_headers = [
2121
'sys/ioctl.h',
2222
'unistd.h',
2323
'fcntl.h',
24-
'sys/types.h',
25-
'sys/stat.h',
2624
'limits.h',
27-
'stdio.h',
28-
'string.h',
2925
]
3026

3127
# All the headers required to compile the lib on windows
3228
windows_c_headers = [
3329
'windows.h',
34-
'stdio.h',
35-
'string.h',
3630
]
3731

3832
# All the required c++ headers, there are needed across all operating systems
@@ -98,10 +92,11 @@ if get_option('build_sample')
9892
sample_src = [
9993
'interfaceTest'
10094
]
95+
10196
if host_machine.system() == 'windows'
102-
message('No sample for windows exists yet! Feel free to open a merge request to add one.')
97+
message('No sample specific for windows exists yet! Feel free to open a merge request to add one.')
10398
else
104-
sample_src += 'sample_linux'
99+
message('No sample specific for unix exists yet! Feel free to open a merge request to add one.')
105100
endif
106101

107102
foreach sample_program : sample_src

‎src/rs232_linux.cc‎

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@
1212

1313
#include "rs232.hpp"
1414

15-
#include "stdio.h"
16-
#include "string.h"
17-
18-
1915
#include <sys/ioctl.h>
2016
#include <unistd.h>
2117
#include <fcntl.h>
22-
#include <sys/types.h>
23-
#include <sys/stat.h>
2418
#include <limits.h>
2519

2620
sakurajin::RS232::RS232(const std::string& deviceName, Baudrate baudrate) : devname(deviceName), available(false){
@@ -30,7 +24,7 @@ sakurajin::RS232::RS232(const std::string& deviceName, Baudrate baudrate) : devn
3024

3125
port = open(devname.c_str(), O_RDWR | O_NOCTTY | O_NDELAY);
3226
if(port == -1){
33-
perror("unable to open comport ");
27+
std::cerr << "unable to open comport "<< std::endl ;
3428
return;
3529
}
3630

@@ -41,9 +35,7 @@ sakurajin::RS232::RS232(const std::string& deviceName, Baudrate baudrate) : devn
4135
return;
4236
}
4337

44-
struct termios nps;
45-
46-
memset(&nps, 0, sizeof(nps)); /* clear the new struct */
38+
struct termios nps{};
4739

4840
nps.c_cflag = baudr | CS8 | CLOCAL | CREAD;
4941
nps.c_iflag = IGNPAR;
@@ -67,11 +59,14 @@ int sakurajin::RS232::Read(unsigned char *buf, int size){
6759
return -1;
6860
}
6961

62+
int limit =
7063
#ifndef __STRICT_ANSI__ /* __STRICT_ANSI__ is defined when the -ansi option is used for gcc */
71-
if(size > SSIZE_MAX) size = (int)SSIZE_MAX; /* SSIZE_MAX is defined in limits.h */
64+
(int)SSIZE_MAX; /* SSIZE_MAX is defined in limits.h */
7265
#else
73-
if(size>4096) size = 4096;
66+
4096;
7467
#endif
68+
69+
size = std::clamp(size, 0, limit);
7570

7671
return read(port, buf, size);
7772
}

0 commit comments

Comments
 (0)