From 07c9cf89509350b1c0bff79af78acbba1c179328 Mon Sep 17 00:00:00 2001 From: "Gilbert J. M. Forkel" Date: Sun, 6 Dec 2015 18:32:52 +0100 Subject: [PATCH 1/2] Correctly detect a device without any dives. If the dive computer has not recorded any dives yet, the profile pointer isn't valid and contains the default value 0xFFFFFFFF. There is no need to return an error in this case. --- src/mares_iconhd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mares_iconhd.c b/src/mares_iconhd.c index 93b2dfc..02a13ad 100644 --- a/src/mares_iconhd.c +++ b/src/mares_iconhd.c @@ -478,6 +478,8 @@ mares_iconhd_extract_dives (dc_device_t *abstract, const unsigned char data[], u break; } if (eop < layout->rb_profile_begin || eop >= layout->rb_profile_end) { + if (eop == 0xFFFFFFFF) + return DC_STATUS_SUCCESS; // No dives available. ERROR (context, "Ringbuffer pointer out of range (0x%08x).", eop); return DC_STATUS_DATAFORMAT; } From d516376ce768dd66433c919c9c97b5cde1c3221a Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Wed, 9 Dec 2015 20:07:22 +0100 Subject: [PATCH 2/2] Improve the support for pseudo terminals. Apparantly Fedora applies a custom patch to glibc's tcsetattr() function, which adds an extra check to verify the PARENB/CREAD/CSIZE bits in the termios c_cflag field. However, in commit 197b9f09421111e03588c94d55a72aa6ec624c63 we already discovered that for pty's, some of the termios settings make no sense at all, and therefore the Linux kernel always does: tty->termios.c_cflag &= ~(CSIZE | PARENB); tty->termios.c_cflag |= (CS8 | CREAD); Thus, instead of ignoring such nonsense termios settings, the kernel changes the termios structure to reflect what pty's actually do. The consequence is that these settings will not stick, and cause the extra check in the Fedora specific patch to fail. To workaround this problem, we ignore the error when building libdivecomputer with pty support enabled. --- src/serial_posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serial_posix.c b/src/serial_posix.c index 2b0c3fa..af4beba 100644 --- a/src/serial_posix.c +++ b/src/serial_posix.c @@ -417,7 +417,7 @@ serial_configure (serial_t *device, int baudrate, int databits, int parity, int } // Apply the new settings. - if (tcsetattr (device->fd, TCSANOW, &tty) != 0) { + if (tcsetattr (device->fd, TCSANOW, &tty) != 0 && NOPTY) { SYSERROR (device->context, errno); return -1; }