From de5b4e7dcbe080ced18c25a128f965f58ce48bc1 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Thu, 6 Sep 2018 13:23:13 +0200 Subject: [PATCH] lib: Split off logging helpers --- libfprint/drivers_api.h | 21 +------------------ libfprint/fp_internal.h | 20 +----------------- libfprint/fpi-log.h | 45 +++++++++++++++++++++++++++++++++++++++++ libfprint/meson.build | 1 + 4 files changed, 48 insertions(+), 39 deletions(-) create mode 100644 libfprint/fpi-log.h diff --git a/libfprint/drivers_api.h b/libfprint/drivers_api.h index cba678a9..bd0bdd7d 100644 --- a/libfprint/drivers_api.h +++ b/libfprint/drivers_api.h @@ -22,12 +22,6 @@ #define __DRIVERS_API_H__ #include - -#ifdef FP_COMPONENT -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "libfprint-"FP_COMPONENT -#endif - #include #include #include @@ -36,25 +30,12 @@ #include #include "fprint.h" +#include "fpi-log.h" #include "fpi-ssm.h" #include "fpi-poll.h" #include "assembling.h" #include "drivers/driver_ids.h" -#define fp_dbg g_debug -#define fp_info g_debug -#define fp_warn g_warning -#define fp_err g_warning - -#define BUG_ON(condition) G_STMT_START \ - if (condition) { \ - char *s; \ - s = g_strconcat ("BUG: (", #condition, ")", NULL); \ - g_warning ("%s: %s() %s:%d", s, G_STRFUNC, __FILE__, __LINE__); \ - g_free (s); \ - } G_STMT_END -#define BUG() BUG_ON(1) - struct fp_dev; libusb_device_handle *fpi_dev_get_usb_dev(struct fp_dev *dev); void *fpi_dev_get_user_data (struct fp_dev *dev); diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index 9aa03f27..3336cac1 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -22,37 +22,19 @@ #include -#ifdef FP_COMPONENT -#undef G_LOG_DOMAIN -#define G_LOG_DOMAIN "libfprint-"FP_COMPONENT -#endif - #include #include #include #include #include "fprint.h" +#include "fpi-log.h" #include "drivers/driver_ids.h" #define container_of(ptr, type, member) ({ \ const typeof( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) -#define fp_dbg g_debug -#define fp_info g_debug -#define fp_warn g_warning -#define fp_err g_warning - -#define BUG_ON(condition) G_STMT_START \ - if (condition) { \ - char *s; \ - s = g_strconcat ("BUG: (", #condition, ")", NULL); \ - g_warning ("%s: %s() %s:%d", s, G_STRFUNC, __FILE__, __LINE__); \ - g_free (s); \ - } G_STMT_END -#define BUG() BUG_ON(1) - enum fp_dev_state { DEV_STATE_INITIAL = 0, DEV_STATE_ERROR, diff --git a/libfprint/fpi-log.h b/libfprint/fpi-log.h new file mode 100644 index 00000000..38d720cb --- /dev/null +++ b/libfprint/fpi-log.h @@ -0,0 +1,45 @@ +/* + * Logging + * Copyright (C) 2007-2008 Daniel Drake + * Copyright (C) 2018 Bastien Nocera + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __FPI_LOG_H__ +#define __FPI_LOG_H__ + +#ifdef FP_COMPONENT +#undef G_LOG_DOMAIN +#define G_LOG_DOMAIN "libfprint-"FP_COMPONENT +#endif + +#include + +#define fp_dbg g_debug +#define fp_info g_debug +#define fp_warn g_warning +#define fp_err g_warning + +#define BUG_ON(condition) G_STMT_START \ + if (condition) { \ + char *s; \ + s = g_strconcat ("BUG: (", #condition, ")", NULL); \ + g_warning ("%s: %s() %s:%d", s, G_STRFUNC, __FILE__, __LINE__); \ + g_free (s); \ + } G_STMT_END +#define BUG() BUG_ON(1) + +#endif diff --git a/libfprint/meson.build b/libfprint/meson.build index c6d1ac9b..ceacc359 100644 --- a/libfprint/meson.build +++ b/libfprint/meson.build @@ -4,6 +4,7 @@ libfprint_sources = [ 'async.c', 'core.c', 'data.c', + 'fpi-log.h', 'fpi-ssm.c', 'fpi-ssm.h', 'fpi-poll.h',