X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=serialport.c;h=c2946a2f08c427a7a7fe5448989f88dfedefa7cb;hb=da2ede60e441566b074d512ad70b51b5751834ae;hp=5a88b407e42eb05baddde41d5713459f21d35f4c;hpb=6c4b27a8b88f032939294346e8e04eca5fb4d0e9;p=libserialport.git diff --git a/serialport.c b/serialport.c index 5a88b40..c2946a2 100644 --- a/serialport.c +++ b/serialport.c @@ -32,7 +32,6 @@ #ifdef _WIN32 #include #include -#include #else #include #include @@ -166,10 +165,10 @@ void (*sp_debug_handler)(const char *format, ...) = sp_default_debug_handler; /* 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__) -#define DEBUG_FAIL(msg) do { \ +#define DEBUG_ERROR(err, fmt, ...) DEBUG("%s returning " #err ": " fmt, __func__, ##__VA_ARGS__) +#define DEBUG_FAIL(fmt, ...) do { \ char *errmsg = sp_last_error_message(); \ - DEBUG("%s returning SP_ERR_FAIL: " msg ": %s", __func__, errmsg); \ + DEBUG("%s returning SP_ERR_FAIL: "fmt": %s", __func__,##__VA_ARGS__,errmsg); \ sp_free_error_message(errmsg); \ } while (0); #define RETURN() do { DEBUG("%s returning", __func__); return; } while(0) @@ -184,8 +183,8 @@ void (*sp_debug_handler)(const char *format, ...) = sp_default_debug_handler; } \ } while (0) #define RETURN_OK() RETURN_CODE(SP_OK); -#define RETURN_ERROR(err, msg) do { DEBUG_ERROR(err, msg); return err; } while (0) -#define RETURN_FAIL(msg) do { DEBUG_FAIL(msg); return SP_ERR_FAIL; } while (0) +#define RETURN_ERROR(err, ...) do { DEBUG_ERROR(err, __VA_ARGS__); return err; } while (0) +#define RETURN_FAIL(...) do { DEBUG_FAIL(__VA_ARGS__); return SP_ERR_FAIL; } while (0) #define RETURN_VALUE(fmt, x) do { \ typeof(x) _x = x; \ DEBUG("%s returning " fmt, __func__, _x); \