diff --git a/doc/meson.build b/doc/meson.build index 8324708..37d515d 100644 --- a/doc/meson.build +++ b/doc/meson.build @@ -6,6 +6,7 @@ private_headers = [ 'aeslib.h', 'assembling.h', 'fp_internal.h', + 'nbis-helpers.h', 'fpi-async.h', 'fpi-data.h', diff --git a/libfprint/fp_internal.h b/libfprint/fp_internal.h index d985738..5c89e18 100644 --- a/libfprint/fp_internal.h +++ b/libfprint/fp_internal.h @@ -27,6 +27,7 @@ #include #include +#include "nbis-helpers.h" #include "fprint.h" #include "fpi-dev.h" #include "fpi-core.h" diff --git a/libfprint/meson.build b/libfprint/meson.build index ce761ba..abd0005 100644 --- a/libfprint/meson.build +++ b/libfprint/meson.build @@ -1,5 +1,6 @@ libfprint_sources = [ 'fp_internal.h', + 'nbis-helpers.h', 'drivers_api.h', 'fpi-async.c', 'fpi-async.h', diff --git a/libfprint/nbis-helpers.h b/libfprint/nbis-helpers.h new file mode 100644 index 0000000..eab861e --- /dev/null +++ b/libfprint/nbis-helpers.h @@ -0,0 +1,33 @@ +/* + * Helpers to use within the NBIS copy/paste library + * 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 + */ + +#include + +#define ASSERT_SIZE_MUL(a,b) \ + { \ + gsize dest; \ + g_assert(g_size_checked_mul(&dest, a, b)); \ + } + +#define ASSERT_INT_MUL(a, b) \ + { \ + gsize dest; \ + g_assert(g_size_checked_mul(&dest, a, b)); \ + g_assert(dest < G_MAXINT); \ + }