X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=hardware%2Fcommon%2Fserial.c;h=80b6f22cd2a37e2be1edae8e1344956343397863;hb=357285a944b514bb4498f16b6318829516e33e1a;hp=f6efe3e26465e30d42411adcd08e7d922479701f;hpb=e46b8fb154ba90ffec9c1f805399dfa819e736f9;p=libsigrok.git diff --git a/hardware/common/serial.c b/hardware/common/serial.c index f6efe3e2..80b6f22c 100644 --- a/hardware/common/serial.c +++ b/hardware/common/serial.c @@ -23,19 +23,19 @@ #include #include #ifdef _WIN32 -#include +#include #else #include #include #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,9 +248,11 @@ int serial_set_params(int fd, int speed, int bits, int parity, int stopbits, case 115200: baud = B115200; break; +#ifndef __APPLE__ case 460800: baud = B460800; break; +#endif default: return SR_ERR; }