From 64690702cb0ee633211efbf83ec950063dc3149e Mon Sep 17 00:00:00 2001 From: Martin Ling Date: Sat, 23 Nov 2013 11:49:35 +0000 Subject: [PATCH] Generate debug output when returning using TRY() macro. --- serialport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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,