From: Martin Ling Date: Sat, 23 Nov 2013 11:49:35 +0000 (+0000) Subject: Generate debug output when returning using TRY() macro. X-Git-Tag: libserialport-0.1.0~62 X-Git-Url: https://sigrok.org/gitweb/?a=commitdiff_plain;h=64690702cb0ee633211efbf83ec950063dc3149e;p=libserialport.git Generate debug output when returning using TRY() macro. --- diff --git a/serialport.c b/serialport.c index 047c805..05aff3a 100644 --- a/serialport.c +++ b/serialport.c @@ -108,8 +108,6 @@ void (*sp_debug_handler)(const char *format, ...) = sp_default_debug_handler; #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define NUM_STD_BAUDRATES ARRAY_SIZE(std_baudrates) -#define TRY(x) do { int ret = x; if (ret != SP_OK) return ret; } while (0) - /* Debug output macros. */ #define DEBUG(fmt, ...) do { if (sp_debug_handler) sp_debug_handler(fmt ".\n", ##__VA_ARGS__); } while (0) #define DEBUG_ERROR(err, msg) DEBUG("%s returning " #err ": " msg, __func__) @@ -137,6 +135,8 @@ void (*sp_debug_handler)(const char *format, ...) = sp_default_debug_handler; #define SET_FAIL(val, msg) do { DEBUG_FAIL(msg); val = err; } while (0) #define TRACE(fmt, ...) DEBUG("%s(" fmt ") called", __func__, ##__VA_ARGS__) +#define TRY(x) do { int ret = x; if (ret != SP_OK) RETURN_CODEVAL(ret); } while (0) + /* Helper functions. */ static struct sp_port **list_append(struct sp_port **list, const char *portname); static enum sp_return get_config(struct sp_port *port, struct port_data *data,