Commit 213fd4ad authored by matt mooney's avatar matt mooney Committed by Greg Kroah-Hartman

staging: usbip: userspace: usbip_common.h: cleanup log macros

Provide better abstraction for easier modification, and align the
macros for readability. Remove notice() because it is not used.
Signed-off-by: default avatarmatt mooney <mfm@muteddisk.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 9a20542f
...@@ -58,51 +58,49 @@ extern int usbip_use_syslog; ...@@ -58,51 +58,49 @@ extern int usbip_use_syslog;
extern int usbip_use_stderr; extern int usbip_use_stderr;
extern int usbip_use_debug ; extern int usbip_use_debug ;
#define err(fmt, args...) do { \ #define PROGNAME "usbip"
if (usbip_use_syslog) { \
syslog(LOG_ERR, "usbip err: %13s:%4d (%-12s) " fmt "\n", \ #define pr_fmt(fmt) "%s: %s: " fmt "\n", PROGNAME
__FILE__, __LINE__, __FUNCTION__, ##args); \ #define dbg_fmt(fmt) pr_fmt("%s:%d:[%s] " fmt), "debug", \
} \ __FILE__, __LINE__, __FUNCTION__
if (usbip_use_stderr) { \
fprintf(stderr, "usbip err: %13s:%4d (%-12s) " fmt "\n", \ #define err(fmt, args...) \
__FILE__, __LINE__, __FUNCTION__, ##args); \ do { \
} \ if (usbip_use_syslog) { \
} while (0) syslog(LOG_ERR, pr_fmt(fmt), "error", ##args); \
} \
#define notice(fmt, args...) do { \ if (usbip_use_stderr) { \
if (usbip_use_syslog) { \ fprintf(stderr, pr_fmt(fmt), "error", ##args); \
syslog(LOG_DEBUG, "usbip: " fmt, ##args); \ } \
} \ } while (0)
if (usbip_use_stderr) { \
fprintf(stderr, "usbip: " fmt "\n", ##args); \ #define info(fmt, args...) \
} \ do { \
} while (0) if (usbip_use_syslog) { \
syslog(LOG_INFO, pr_fmt(fmt), "info", ##args); \
#define info(fmt, args...) do { \ } \
if (usbip_use_syslog) { \ if (usbip_use_stderr) { \
syslog(LOG_DEBUG, fmt, ##args); \ fprintf(stderr, pr_fmt(fmt), "info", ##args); \
} \ } \
if (usbip_use_stderr) { \ } while (0)
fprintf(stderr, fmt "\n", ##args); \
} \ #define dbg(fmt, args...) \
} while (0) do { \
if (usbip_use_debug) { \
#define dbg(fmt, args...) do { \ if (usbip_use_syslog) { \
if (usbip_use_debug) { \ syslog(LOG_DEBUG, dbg_fmt(fmt), ##args); \
if (usbip_use_syslog) { \ } \
syslog(LOG_DEBUG, "usbip dbg: %13s:%4d (%-12s) " fmt, \ if (usbip_use_stderr) { \
__FILE__, __LINE__, __FUNCTION__, ##args); \ fprintf(stderr, dbg_fmt(fmt), ##args); \
} \ } \
if (usbip_use_stderr) { \ } \
fprintf(stderr, "usbip dbg: %13s:%4d (%-12s) " fmt "\n", \ } while (0)
__FILE__, __LINE__, __FUNCTION__, ##args); \
} \ #define BUG() \
} \ do { \
} while (0) err("sorry, it's a bug!"); \
abort(); \
} while (0)
#define BUG() do { err("sorry, it's a bug"); abort(); } while (0)
struct usbip_usb_interface { struct usbip_usb_interface {
uint8_t bInterfaceClass; uint8_t bInterfaceClass;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment