X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fcommon%2Fserial.c;h=80b6f22cd2a37e2be1edae8e1344956343397863;hb=f020a99773d1431ee58090e9515dc19b10e7463f;hp=b3e8af0f76144f40f1528aee6ab3b7acddd06532;hpb=2f3aab0ee9797700238656218208a6ab17a607b3;p=libsigrok.git diff --git a/hardware/common/serial.c b/hardware/common/serial.c index b3e8af0f..80b6f22c 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -30,12 +30,12 @@ #endif #include #include -#include -#include +#include "sigrok.h" +#include "sigrok-internal.h" // FIXME: Must be moved, or rather passed as function argument. #ifdef _WIN32 -HANDLE hdl; +static HANDLE hdl; #endif const char *serial_port_glob[] = { @@ -163,7 +163,12 @@ void *serial_backup_params(int fd) #else struct termios *term; - term = malloc(sizeof(struct termios)); + /* TODO: 'term' is never g_free()'d? */ + if (!(term = g_try_malloc(sizeof(struct termios)))) { + sr_err("serial: %s: term malloc failed", __func__); + return NULL; + } + tcgetattr(fd, term); return term; @@ -243,7 +248,7 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits, case 115200: baud = B115200; break; -#if 0 +#ifndef __APPLE__ case 460800: baud = B460800; break;