Skip to content

Commit 2dbd902

Browse files
SerialImp.c:RXTXPort(open) - avoid noop fcntl() and pointless assignments
The file is already opened with O_RDWR | O_NOCTTY | O_NONBLOCK. * O_RDWR cannot be changed on linux with F_SETFL - https://man7.org/linux/man-pages/man2/F_GETFL.2const.html * The last page lists explicitly what can be changed by F_SETFL and O_NOCTTY is not mentioned. * O_NONBLOCK is already set when opening the file * FD_CLOEXEC is supposed to be set with F_SETFD - https://man7.org/linux/man-pages/man2/F_SETFD.2const.html * remove pointless assignments
1 parent b1da316 commit 2dbd902

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/main/c/src/SerialImp.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -713,17 +713,12 @@ JNIEXPORT jint JNICALL RXTXPort(open)(
713713
See tty(4) ("man 4 tty") and ioctl(2) ("man 2 ioctl") for details.
714714
*/
715715
#if defined(__linux__)
716-
int ret;
717716
//report_error("\nnative open(): Setting ownership flags");
718-
ret= fcntl(fd,F_SETOWN,getpid());
717+
fcntl(fd,F_SETOWN,getpid());
719718
//report_error( strerror(errno) );
720719

721720
//report_error("\nnativec(): Forcing unlock flags");
722-
ret = fcntl(fd,F_UNLCK);
723-
//report_error( strerror(errno) );
724-
725-
//report_error("\nnative open(): Setting read/write flags");
726-
ret= fcntl(fd,F_SETFL,O_CLOEXEC|O_RDWR|O_NONBLOCK);
721+
fcntl(fd,F_UNLCK);
727722
//report_error( strerror(errno) );
728723
#endif
729724
if (fd >= 0 && (ioctl(fd, TIOCEXCL) == -1))

0 commit comments

Comments
 (0)