diff --git a/Makefile.common b/Makefile.common index 22197bde..08701953 100644 --- a/Makefile.common +++ b/Makefile.common @@ -12,10 +12,8 @@ DEFINE_PATHS = \ AM_CPPFLAGS = \ $(CODE_COVERAGE_CPPFLAGS) \ $(DEFINE_PATHS) \ - -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libkeymap \ - -I$(top_srcdir)/src/libkbdfile \ - -I$(top_srcdir)/src/libkfont + -I$(top_srcdir)/src/include \ + -I$(top_srcdir)/src/libcommon AM_CFLAGS = $(CODE_COVERAGE_CFLAGS) LDADD = $(CODE_COVERAGE_LIBS) diff --git a/src/chvt.c b/src/chvt.c index f3322b23..aa2326a4 100644 --- a/src/chvt.c +++ b/src/chvt.c @@ -18,7 +18,7 @@ #include "libcommon.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] N\n"), get_progname()); @@ -30,9 +30,7 @@ usage(int rc, const struct kbd_help *options) } static void -sighandler(int sig __attribute__((unused)), - siginfo_t *si __attribute__((unused)), - void *uc __attribute__((unused))) +sighandler(int sig KBD_ATTR_UNUSED, siginfo_t *si KBD_ATTR_UNUSED, void *uc KBD_ATTR_UNUSED) { return; } diff --git a/src/clrunimap.c b/src/clrunimap.c index 430cf0be..ff2fd37d 100644 --- a/src/clrunimap.c +++ b/src/clrunimap.c @@ -11,8 +11,9 @@ #include #include +#include + #include "libcommon.h" -#include "kfont.h" int main(int argc, char *argv[]) { diff --git a/src/deallocvt.c b/src/deallocvt.c index 48f58d5b..8c9f4d5b 100644 --- a/src/deallocvt.c +++ b/src/deallocvt.c @@ -18,7 +18,7 @@ #include "libcommon.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] [N ...]\n"), get_progname()); diff --git a/src/dumpkeys.c b/src/dumpkeys.c index ccf5bb59..7ce44624 100644 --- a/src/dumpkeys.c +++ b/src/dumpkeys.c @@ -17,14 +17,14 @@ #include #include #include -#include "ksyms.h" -#include "modifiers.h" + +#include #include "libcommon.h" static int fd; -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/fgconsole.c b/src/fgconsole.c index 754af252..56fbe1ef 100644 --- a/src/fgconsole.c +++ b/src/fgconsole.c @@ -15,7 +15,7 @@ #include "libcommon.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/getkeycodes.c b/src/getkeycodes.c index ff39d760..211f62b5 100644 --- a/src/getkeycodes.c +++ b/src/getkeycodes.c @@ -17,7 +17,7 @@ #include "libcommon.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/getunimap.c b/src/getunimap.c index 2ba0eb74..c87a9b69 100644 --- a/src/getunimap.c +++ b/src/getunimap.c @@ -11,8 +11,9 @@ #include #include +#include + #include "libcommon.h" -#include "kfont.h" #ifndef USE_LIBC /* There is such function in libc5 but it doesn't work for me [libc 5.4.13] */ @@ -28,7 +29,7 @@ ud_compar(const void *u1, const void *u2) return (int)fp1 - (int)fp2; } -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/compat/linux-kd.h b/src/include/compat/linux-kd.h similarity index 100% rename from src/compat/linux-kd.h rename to src/include/compat/linux-kd.h diff --git a/src/compat/linux-keyboard.h b/src/include/compat/linux-keyboard.h similarity index 100% rename from src/compat/linux-keyboard.h rename to src/include/compat/linux-keyboard.h diff --git a/src/compat/linux-limits.h b/src/include/compat/linux-limits.h similarity index 100% rename from src/compat/linux-limits.h rename to src/include/compat/linux-limits.h diff --git a/src/include/kbd/compiler_attributes.h b/src/include/kbd/compiler_attributes.h new file mode 100644 index 00000000..f8ba8e03 --- /dev/null +++ b/src/include/kbd/compiler_attributes.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _KBD_COMMON_COMPILER_ATTRIBUTES_H_ +#define _KBD_COMMON_COMPILER_ATTRIBUTES_H_ + +/* + * Compilers that lack __has_attribute may object to + * #if defined __has_attribute && __has_attribute (...) + * even though they do not need to evaluate the right-hand side of the &&. + */ +#ifndef __has_attribute +# define __has_attribute(x) 0 +#endif + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-format-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#format + */ +#define KBD_ATTR_PRINTF(a, b) __attribute__((__format__(printf, a, b))) +#define KBD_ATTR_SCANF(a, b) __attribute__((__format__(scanf, a, b))) + +/* + * Optional: only supported since gcc >= 8 + * Optional: not supported by clang + * Optional: not supported by icc + * + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-nonstring-variable-attribute + */ +#if __has_attribute(__nonstring__) +# define KBD_ATTR_NONSTRING __attribute__((__nonstring__)) +#else +# define KBD_ATTR_NONSTRING +#endif + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-nonnull-function-attribute + */ +#if __has_attribute(nonnull) +#define KBD_ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) +#else +#define KBD_ATTR_NONNULL +#endif + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noreturn-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#noreturn + * clang: https://clang.llvm.org/docs/AttributeReference.html#id1 + */ +#define KBD_ATTR_NORETURN __attribute__((__noreturn__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-unused-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-unused-type-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-unused-variable-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Label-Attributes.html#index-unused-label-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#maybe-unused-unused + */ +#define KBD_ATTR_UNUSED __attribute__((__unused__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-used-function-attribute + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-used-variable-attribute + */ +#define KBD_ATTR_USED __attribute__((__used__)) + +/* + * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-warn_005funused_005fresult-function-attribute + * clang: https://clang.llvm.org/docs/AttributeReference.html#nodiscard-warn-unused-result + */ +#define KBD_ATTR_MUST_CHECK __attribute__((__warn_unused_result__)) + +#endif /* _KBD _COMMON_COMPILER_ATTRIBUTES_H_ */ diff --git a/src/libkbdfile/kbdfile.h b/src/include/kbd/kbdfile.h similarity index 80% rename from src/libkbdfile/kbdfile.h rename to src/include/kbd/kbdfile.h index 9b9e031f..962c23b0 100644 --- a/src/libkbdfile/kbdfile.h +++ b/src/include/kbd/kbdfile.h @@ -1,19 +1,19 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later /** * @file kbdfile.h * @brief Functions for search, open and close a file objects. */ -#ifndef _KBDFILE_H_ -#define _KBDFILE_H_ +#ifndef _KBD_LIBKBDFILE_KBDFILE_H_ +#define _KBD_LIBKBDFILE_KBDFILE_H_ #include #include #include -#ifndef __GNUC__ -#define __attribute__(x) /*NOTHING*/ -#endif +#include -typedef void (*kbdfile_logger_t)(void *, int, const char *, int, const char *, const char *, va_list) __attribute__((format(printf, 6, 0))); +typedef void (*kbdfile_logger_t)(void *, int, const char *, int, const char *, const char *, va_list) + KBD_ATTR_PRINTF(6, 0); struct kbdfile_ctx; @@ -50,9 +50,9 @@ int kbdfile_is_compressed(struct kbdfile *fp); #include void -__attribute__((format(printf, 6, 7))) kbdfile_log(struct kbdfile_ctx *ctx, int priority, - const char *file, int line, const char *fn, - const char *fmt, ...); + const char *file, int line, const char *fn, + const char *fmt, ...) + KBD_ATTR_PRINTF(6, 7); -#endif /* _KBDFILE_H_ */ +#endif /* _KBD_LIBKBDFILE_KBDFILE_H_ */ diff --git a/src/libkeymap/keymap/array.h b/src/include/kbd/keymap/array.h similarity index 60% rename from src/libkeymap/keymap/array.h rename to src/include/kbd/keymap/array.h index f8dbe0f6..de5536be 100644 --- a/src/libkeymap/keymap/array.h +++ b/src/include/kbd/keymap/array.h @@ -1,18 +1,21 @@ -#ifndef LK_ARRAY_H -#define LK_ARRAY_H +// SPDX-License-Identifier: LGPL-2.0-or-later +#ifndef _KBD_LIBKEYMAP_ARRAY_H_ +#define _KBD_LIBKEYMAP_ARRAY_H_ #include #include +#include + /** * @brief Basic structure for array implementation. * @details The array is designed to store an arbitrary number of similar items. */ struct lk_array { - char *array; /**< Data pointer. */ - ssize_t memb; /**< One element size. */ - ssize_t count; /**< Number of elements. */ - ssize_t total; /**< Total number of allocated elements. */ + char *array KBD_ATTR_NONSTRING; /**< Data pointer. */ + ssize_t memb; /**< One element size. */ + ssize_t count; /**< Number of elements. */ + ssize_t total; /**< Total number of allocated elements. */ }; int lk_array_init(struct lk_array *a, ssize_t memb, ssize_t size); @@ -29,4 +32,4 @@ void *lk_array_get_ptr(struct lk_array *a, ssize_t i); int lk_array_unset(struct lk_array *a, ssize_t i); int lk_array_exists(struct lk_array *a, ssize_t i); -#endif /* LK_ARRAY_H */ +#endif /* _KBD_LIBKEYMAP_ARRAY_H_ */ diff --git a/src/libkeymap/keymap/charset.h b/src/include/kbd/keymap/charset.h similarity index 77% rename from src/libkeymap/keymap/charset.h rename to src/include/kbd/keymap/charset.h index 9b160c49..52ee326b 100644 --- a/src/libkeymap/keymap/charset.h +++ b/src/include/kbd/keymap/charset.h @@ -1,11 +1,14 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later /** * @file charset.h * @brief Functions for charset manipulation. */ -#ifndef LK_CHARSET_H -#define LK_CHARSET_H +#ifndef _KBD_LIBKEYMAP_CHARSET_H_ +#define _KBD_LIBKEYMAP_CHARSET_H_ -#include +#include + +#include /** Prints into the FILE a list of supported charsets. * @param fp is a stream. @@ -29,4 +32,4 @@ const char *lk_get_charset(struct lk_ctx *ctx); */ int lk_set_charset(struct lk_ctx *ctx, const char *name); -#endif /* LK_CHARSET_H */ +#endif /* _KBD_LIBKEYMAP_CHARSET_H_ */ diff --git a/src/libkeymap/keymap/common.h b/src/include/kbd/keymap/common.h similarity index 88% rename from src/libkeymap/keymap/common.h rename to src/include/kbd/keymap/common.h index 70f963a9..084c61e8 100644 --- a/src/libkeymap/keymap/common.h +++ b/src/include/kbd/keymap/common.h @@ -1,15 +1,18 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later /** * @file common.h * @brief Functions for initialization and release of resources as well * as functions to handle parameters. */ -#ifndef LK_COMMON_H -#define LK_COMMON_H +#ifndef _KBD_LIBKEYMAP_COMMON_H_ +#define _KBD_LIBKEYMAP_COMMON_H_ #include -#include -#include +#include + +#include +#include /** Initializes the structures necessary to read and/or parse keymap. * @@ -71,4 +74,4 @@ void *lk_get_log_data(struct lk_ctx *ctx); lk_keywords lk_get_keywords(struct lk_ctx *ctx); int lk_set_keywords(struct lk_ctx *ctx, lk_keywords keywords); -#endif /* LK_COMMON_H */ +#endif /* _KBD_LIBKEYMAP_COMMON_H_ */ diff --git a/src/libkeymap/keymap/context.h b/src/include/kbd/keymap/context.h similarity index 85% rename from src/libkeymap/keymap/context.h rename to src/include/kbd/keymap/context.h index 36c4a0f3..d3654794 100644 --- a/src/libkeymap/keymap/context.h +++ b/src/include/kbd/keymap/context.h @@ -1,14 +1,17 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later /** * @file context.h * @brief Header contains flags, keywords and context structure. */ - -#ifndef LK_CONTEXT_H -#define LK_CONTEXT_H +#ifndef _KBD_LIBKEYMAP_CONTEXT_H_ +#define _KBD_LIBKEYMAP_CONTEXT_H_ #include #include -#include + +#include + +#include /** * @brief Parser flags that are set outside the library. @@ -53,4 +56,4 @@ struct lk_ctx; int lk_convert_code(struct lk_ctx *ctx, int code, int direction); int lk_add_capslock(struct lk_ctx *ctx, int code); -#endif /* LK_CONTEXT_H */ +#endif /* _KBD_LIBKEYMAP_CONTEXT_H_ */ diff --git a/src/libkeymap/keymap/dump.h b/src/include/kbd/keymap/dump.h similarity index 70% rename from src/libkeymap/keymap/dump.h rename to src/include/kbd/keymap/dump.h index c7fd808c..21fdf149 100644 --- a/src/libkeymap/keymap/dump.h +++ b/src/include/kbd/keymap/dump.h @@ -1,18 +1,16 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later /** * @file dump.h * @brief Functions for keymap output. */ -#ifndef LK_DUMP_H -#define LK_DUMP_H +#ifndef _KBD_LIBKEYMAP_DUMP_H_ +#define _KBD_LIBKEYMAP_DUMP_H_ #include -#include +#include -#ifndef __GNUC__ -#undef __attribute__ -#define __attribute__(x) /*NOTHING*/ -#endif +#include /** * @brief Flags controlling the output keymap. @@ -47,7 +45,8 @@ struct kmapinfo { * * @return 0 on success, -1 on error. */ -int lk_dump_bkeymap(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1))); +int lk_dump_bkeymap(struct lk_ctx *ctx, FILE *fd) + KBD_ATTR_NONNULL(1); /** * Outputs a keymap in C format. @@ -56,7 +55,8 @@ int lk_dump_bkeymap(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1))); * * @return 0 on success, -1 on error. */ -int lk_dump_ctable(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1, 2))); +int lk_dump_ctable(struct lk_ctx *ctx, FILE *fd) + KBD_ATTR_NONNULL(1, 2); /** * Outputs whole keymap. This is a high-level function that calls @ref lk_dump_keys, @@ -66,7 +66,8 @@ int lk_dump_ctable(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1, 2))); * @param table specifies the output format of the keycode table. * @param numeric indicates whether to output the keycodes in numerical form. */ -void lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) __attribute__((nonnull(1, 2))); +void lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) + KBD_ATTR_NONNULL(1, 2); /** * Outputs keycodes. @@ -75,28 +76,32 @@ void lk_dump_keymap(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char num * @param table specifies the output format of the keycode table. * @param numeric indicates whether to output the keycodes in numerical form. */ -void lk_dump_keys(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) __attribute__((nonnull(1, 2))); +void lk_dump_keys(struct lk_ctx *ctx, FILE *fd, lk_table_shape table, char numeric) + KBD_ATTR_NONNULL(1, 2); /** * Outputs 'keymaps' line. * @param ctx is a keymap library context. * @param fd is a FILE pointer for output. */ -void lk_dump_keymaps(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1, 2))); +void lk_dump_keymaps(struct lk_ctx *ctx, FILE *fd) + KBD_ATTR_NONNULL(1, 2); /** * Outputs function keys. * @param ctx is a keymap library context. * @param fd is a FILE pointer for output. */ -void lk_dump_funcs(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1, 2))); +void lk_dump_funcs(struct lk_ctx *ctx, FILE *fd) + KBD_ATTR_NONNULL(1, 2); /** * Outputs accent table. * @param ctx is a keymap library context. * @param fd is a FILE pointer for output. */ -void lk_dump_diacs(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1, 2))); +void lk_dump_diacs(struct lk_ctx *ctx, FILE *fd) + KBD_ATTR_NONNULL(1, 2); /** * Converts a number to a string representation of the character. @@ -105,9 +110,11 @@ void lk_dump_diacs(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1, 2))); * * @return a string representation of the code. */ -char *lk_code_to_ksym(struct lk_ctx *ctx, int code) __attribute__((nonnull(1))); +char *lk_code_to_ksym(struct lk_ctx *ctx, int code) + KBD_ATTR_NONNULL(1); -char *lk_get_sym(struct lk_ctx *ctx, int ktype, int index) __attribute__((nonnull(1))); +char *lk_get_sym(struct lk_ctx *ctx, int ktype, int index) + KBD_ATTR_NONNULL(1); /** * Converts a string to a numeric representation of the character. @@ -116,10 +123,16 @@ char *lk_get_sym(struct lk_ctx *ctx, int ktype, int index) __attribute__((nonnul * * @return a unicode representation of the code. */ -int lk_ksym_to_unicode(struct lk_ctx *ctx, const char *code) __attribute__((nonnull(1, 2))); +int lk_ksym_to_unicode(struct lk_ctx *ctx, const char *code) + KBD_ATTR_NONNULL(1, 2); -int lk_get_kmapinfo(struct lk_ctx *ctx, struct kmapinfo *res) __attribute__((nonnull(1, 2))); -void lk_dump_summary(struct lk_ctx *ctx, FILE *fd, int console) __attribute__((nonnull(1, 2))); -void lk_dump_symbols(struct lk_ctx *ctx, FILE *fd) __attribute__((nonnull(1, 2))); +int lk_get_kmapinfo(struct lk_ctx *ctx, struct kmapinfo *res) + KBD_ATTR_NONNULL(1, 2); -#endif /* LK_DUMP_H */ +void lk_dump_summary(struct lk_ctx *ctx, FILE *fd, int console) + KBD_ATTR_NONNULL(1, 2); + +void lk_dump_symbols(struct lk_ctx *ctx, FILE *fd) + KBD_ATTR_NONNULL(1, 2); + +#endif /* _KBD_LIBKEYMAP_DUMP_H_ */ diff --git a/src/libkeymap/keymap/kernel.h b/src/include/kbd/keymap/kernel.h similarity index 63% rename from src/libkeymap/keymap/kernel.h rename to src/include/kbd/keymap/kernel.h index a110f799..762e2cdc 100644 --- a/src/libkeymap/keymap/kernel.h +++ b/src/include/kbd/keymap/kernel.h @@ -1,16 +1,14 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later /** * @file kernel.h * @brief Functions for loading objects into the kernel. */ -#ifndef LK_KERNEL_H -#define LK_KERNEL_H +#ifndef _KBD_LIBKEYMAP_KERNEL_H_ +#define _KBD_LIBKEYMAP_KERNEL_H_ -#include +#include -#ifndef __GNUC__ -#undef __attribute__ -#define __attribute__(x) /*NOTHING*/ -#endif +#include /** * Loads keymap into the kernel. This is a high-level function that calls @@ -20,7 +18,8 @@ * * @return 0 on success, -1 on error. */ -int lk_kernel_keymap(struct lk_ctx *ctx, int console) __attribute__((nonnull(1))); +int lk_kernel_keymap(struct lk_ctx *ctx, int console) + KBD_ATTR_NONNULL(1); /** * Loads keycodes into the kernel. @@ -29,7 +28,8 @@ int lk_kernel_keymap(struct lk_ctx *ctx, int console) __attribute__((nonnull(1)) * * @return 0 on success, -1 on error. */ -int lk_kernel_keys(struct lk_ctx *ctx, int console) __attribute__((nonnull(1))); +int lk_kernel_keys(struct lk_ctx *ctx, int console) + KBD_ATTR_NONNULL(1); /** * Loads function keys into the kernel. @@ -38,7 +38,8 @@ int lk_kernel_keys(struct lk_ctx *ctx, int console) __attribute__((nonnull(1))); * * @return 0 on success, -1 on error. */ -int lk_kernel_funcs(struct lk_ctx *ctx, int console) __attribute__((nonnull(1))); +int lk_kernel_funcs(struct lk_ctx *ctx, int console) + KBD_ATTR_NONNULL(1); /** * Loads accent table into the kernel. @@ -47,6 +48,7 @@ int lk_kernel_funcs(struct lk_ctx *ctx, int console) __attribute__((nonnull(1))) * * @return 0 on success, -1 on error. */ -int lk_kernel_diacrs(struct lk_ctx *ctx, int console) __attribute__((nonnull(1))); +int lk_kernel_diacrs(struct lk_ctx *ctx, int console) + KBD_ATTR_NONNULL(1); -#endif /* LK_KERNEL_H */ +#endif /* _KBD_LIBKEYMAP_KERNEL_H_ */ diff --git a/src/include/kbd/keymap/kmap.h b/src/include/kbd/keymap/kmap.h new file mode 100644 index 00000000..d8f7d1df --- /dev/null +++ b/src/include/kbd/keymap/kmap.h @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later +/** + * @file kmap.h + * @brief Functions for keymaps manipulation (add/delete keys). + */ +#ifndef _KBD_LIBKEYMAP_KMAP_H_ +#define _KBD_LIBKEYMAP_KMAP_H_ + +#include + +#include + +int lk_add_map(struct lk_ctx *ctx, int k_table) + KBD_ATTR_NONNULL(1); + +int lk_map_exists(struct lk_ctx *ctx, int k_table) + KBD_ATTR_NONNULL(1); + +int lk_get_keys_total(struct lk_ctx *ctx, int k_table) + KBD_ATTR_NONNULL(1); + +int lk_add_key(struct lk_ctx *ctx, int k_table, int k_index, int keycode) + KBD_ATTR_NONNULL(1); + +int lk_del_key(struct lk_ctx *ctx, int k_table, int k_index) + KBD_ATTR_NONNULL(1); + +int lk_get_key(struct lk_ctx *ctx, int k_table, int k_index) + KBD_ATTR_NONNULL(1); + +int lk_key_exists(struct lk_ctx *ctx, int k_table, int k_index) + KBD_ATTR_NONNULL(1); + +/* Functions for key string manipulations */ +int lk_get_func(struct lk_ctx *ctx, struct kbsentry *kbs) + KBD_ATTR_NONNULL(1, 2); + +int lk_add_func(struct lk_ctx *ctx, struct kbsentry *kbs) + KBD_ATTR_NONNULL(1, 2); + +int lk_del_func(struct lk_ctx *ctx, int index) + KBD_ATTR_NONNULL(1); + +int lk_func_exists(struct lk_ctx *ctx, int index) + KBD_ATTR_NONNULL(1); + +/* Functions for manipulations with diacritical table */ +int lk_get_diacr(struct lk_ctx *ctx, int index, struct lk_kbdiacr *dcr) + KBD_ATTR_NONNULL(1, 3); + +int lk_add_diacr(struct lk_ctx *ctx, int index, struct lk_kbdiacr *dcr) + KBD_ATTR_NONNULL(1, 3); + +int lk_del_diacr(struct lk_ctx *ctx, int index) + KBD_ATTR_NONNULL(1); + +int lk_diacr_exists(struct lk_ctx *ctx, int index) + KBD_ATTR_NONNULL(1); + +int lk_append_diacr(struct lk_ctx *ctx, struct lk_kbdiacr *dcr) + KBD_ATTR_NONNULL(1, 2); + +int lk_append_compose(struct lk_ctx *ctx, struct lk_kbdiacr *dcr) + KBD_ATTR_NONNULL(1, 2); + +int lk_add_constants(struct lk_ctx *ctx) KBD_ATTR_NONNULL(1); + +#include + +int lk_parse_keymap(struct lk_ctx *ctx, struct kbdfile *f) + KBD_ATTR_NONNULL(1, 2); + +int lk_load_keymap(struct lk_ctx *ctx, int fd, int kbd_mode) + KBD_ATTR_NONNULL(1); + +#endif /* _KBD_LIBKEYMAP_KMAP_H_ */ diff --git a/src/libkeymap/keymap/logging.h b/src/include/kbd/keymap/logging.h similarity index 52% rename from src/libkeymap/keymap/logging.h rename to src/include/kbd/keymap/logging.h index c10d0023..78c141ca 100644 --- a/src/libkeymap/keymap/logging.h +++ b/src/include/kbd/keymap/logging.h @@ -1,21 +1,20 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later /** * @file logging.h * @brief Functions for logging. */ -#ifndef LK_LOGGING_H -#define LK_LOGGING_H +#ifndef _KBD_LIBKEYMAP_LOGGING_H_ +#define _KBD_LIBKEYMAP_LOGGING_H_ #include -#include -#ifndef __GNUC__ -#undef __attribute__ -#define __attribute__(x) /*NOTHING*/ -#endif +#include + +#include typedef void (*lk_logger_t)(void *, int, const char *, int, const char *, const char *, va_list) - __attribute__((nonnull(1))) - __attribute__((format(printf, 6, 0))); + KBD_ATTR_PRINTF(6, 0) + KBD_ATTR_NONNULL(1); /** * Logging function which uses @ref lk_ctx::log_fn "log_fn" and @@ -25,9 +24,9 @@ typedef void (*lk_logger_t)(void *, int, const char *, int, const char *, const */ void lk_log(struct lk_ctx *ctx, int priority, - const char *file, int line, const char *fn, - const char *fmt, ...) - __attribute__((format(printf, 6, 7))) - __attribute__((nonnull(1))); + const char *file, int line, const char *fn, + const char *fmt, ...) + KBD_ATTR_PRINTF(6, 7) + KBD_ATTR_NONNULL(1); -#endif /* LK_LOGGING_H */ +#endif /* _KBD_LIBKEYMAP_LOGGING_H_ */ diff --git a/src/libkfont/kfont.h b/src/include/kbd/kfont.h similarity index 87% rename from src/libkfont/kfont.h rename to src/include/kbd/kfont.h index 1f51b6d9..67ad9170 100644 --- a/src/libkfont/kfont.h +++ b/src/include/kbd/kfont.h @@ -4,13 +4,10 @@ * * Originally written by Andries Brouwer */ -#ifndef _KFONT_H_ -#define _KFONT_H_ +#ifndef _KBD_LIBKFONT_KFONT_H_ +#define _KBD_LIBKFONT_KFONT_H_ -#ifndef __GNUC__ -#undef __attribute__ -#define __attribute__(x) /*NOTHING*/ -#endif +#include /* * Format of a psf font file: @@ -55,9 +52,9 @@ #define PSF1_STARTSEQ 0xFFFE struct psf1_header { - unsigned char magic[2]; /* Magic number */ - unsigned char mode; /* PSF font mode */ - unsigned char charsize; /* Character size */ + unsigned char magic[2] KBD_ATTR_NONSTRING; /* Magic number */ + unsigned char mode; /* PSF font mode */ + unsigned char charsize; /* Character size */ }; /* @@ -78,7 +75,7 @@ struct psf1_header { #define PSF2_MAGIC3 0x86 struct psf2_header { - unsigned char magic[4]; + unsigned char magic[4] KBD_ATTR_NONSTRING; unsigned int version; unsigned int headersize; /* offset of bitmaps in file */ unsigned int flags; @@ -119,8 +116,8 @@ void kfont_free(struct kfont_context *ctx); typedef void (*kfont_logger_t)(struct kfont_context *, int, const char *, int, const char *, const char *, va_list) - __attribute__((nonnull(1))) - __attribute__((format(printf, 6, 0))); + KBD_ATTR_PRINTF(6, 0) + KBD_ATTR_NONNULL(1); enum kfont_option { kfont_force, @@ -128,40 +125,40 @@ enum kfont_option { }; int kfont_get_verbosity(struct kfont_context *ctx) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); void kfont_inc_verbosity(struct kfont_context *ctx) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); void kfont_set_logger(struct kfont_context *ctx, kfont_logger_t fn) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); void kfont_set_option(struct kfont_context *ctx, enum kfont_option opt) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); void kfont_unset_option(struct kfont_context *ctx, enum kfont_option opt) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* mapscrn.c */ int kfont_load_consolemap(struct kfont_context *ctx, int consolefd, const char *filename) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); int kfont_save_consolemap(struct kfont_context *ctx, int consolefd, const char *filename) - __attribute__((nonnull(1,3))); + KBD_ATTR_NONNULL(1, 3); /* loadunimap.c */ /* save humanly readable */ int kfont_save_unicodemap(struct kfont_context *ctx, int consolefd, const char *filename) - __attribute__((nonnull(1,3))); + KBD_ATTR_NONNULL(1, 3); int kfont_load_unicodemap(struct kfont_context *ctx, int consolefd, const char *filename) - __attribute__((nonnull(1,3))); + KBD_ATTR_NONNULL(1, 3); /* kdfontop.c */ @@ -173,7 +170,7 @@ int kfont_load_unicodemap(struct kfont_context *ctx, int consolefd, int kfont_get_font(struct kfont_context *ctx, int consolefd, unsigned char *buf, unsigned int *count, unsigned int *width, unsigned int *height, unsigned int *vpitch) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* * Load kernel font of width WIDTH and pointsize HEIGHT from BUF @@ -183,55 +180,55 @@ int kfont_get_font(struct kfont_context *ctx, int consolefd, unsigned char *buf, int kfont_put_font(struct kfont_context *ctx, int consolefd, unsigned char *buf, unsigned int count, unsigned int width, unsigned int height, unsigned int vpitch) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* * Find the size of the kernel font. */ unsigned int kfont_get_fontsize(struct kfont_context *ctx, int consolefd) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* * Restore font (doesn't work). */ int kfont_restore_font(struct kfont_context *ctx, int fd) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* kdmapop.c */ int kfont_get_uniscrnmap(struct kfont_context *ctx, int consolefd, unsigned short *map) - __attribute__((nonnull(1,3))); + KBD_ATTR_NONNULL(1, 3); int kfont_put_uniscrnmap(struct kfont_context *ctx, int consolefd, unsigned short *map) - __attribute__((nonnull(1,3))); + KBD_ATTR_NONNULL(1, 3); #include int kfont_get_unicodemap(struct kfont_context *ctx, int consolefd, struct unimapdesc *ud) - __attribute__((nonnull(1,3))); + KBD_ATTR_NONNULL(1, 3); int kfont_put_unicodemap(struct kfont_context *ctx, int consolefd, struct unimapinit *ui, struct unimapdesc *ud) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* setfont.c */ int kfont_save_font(struct kfont_context *ctx, int consolefd, const char *filename, int with_unicodemap) - __attribute__((nonnull(1,3))); + KBD_ATTR_NONNULL(1, 3); int kfont_load_font(struct kfont_context *ctx, int consolefd, const char *filename, unsigned int iunit, unsigned int hwunit, int no_m, int no_u) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); int kfont_load_fonts(struct kfont_context *ctx, int consolefd, const char *const *files, int filect, unsigned int iunit, unsigned int hwunit, int no_m, int no_u) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); void kfont_activatemap(int fd); void kfont_disactivatemap(int fd); @@ -273,24 +270,24 @@ int kfont_read_psffont(struct kfont_context *ctx, unsigned int *fontwidthp, unsigned int *fontheightp, unsigned int *fontlenp, unsigned int fontpos0, struct unicode_list **uclistheadsp) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); int kfont_write_psffont(struct kfont_context *ctx, FILE *ofil, unsigned char *fontbuf, unsigned int width, unsigned int height, unsigned int fontlen, int psftype, struct unicode_list *uclistheads) - __attribute__((nonnull(1,2,3))); + KBD_ATTR_NONNULL(1, 2, 3); /* psfxtable.c */ int kfont_read_unicodetable(struct kfont_context *ctx, FILE *file, unsigned int fontlen, struct unicode_list **uclistheads) - __attribute__((nonnull(1,2,4))); + KBD_ATTR_NONNULL(1, 2, 4); int kfont_write_unicodetable(struct kfont_context *ctx, FILE *file, unsigned int fontlen, struct unicode_list *uclistheads) - __attribute__((nonnull(1,2,4))); + KBD_ATTR_NONNULL(1, 2, 4); -#endif /* _KFONT_H_ */ +#endif /* _KBD_LIBKFONT_KFONT_H_ */ diff --git a/src/include/kbdfile.h b/src/include/kbdfile.h new file mode 100644 index 00000000..9f2c55c4 --- /dev/null +++ b/src/include/kbdfile.h @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later +#ifndef _KBD_LIBKBDFILE_H_ +#define _KBD_LIBKBDFILE_H_ + +#include + +#endif /* _KBD_LIBKBDFILE_H_ */ diff --git a/src/include/keymap.h b/src/include/keymap.h new file mode 100644 index 00000000..37c16a0d --- /dev/null +++ b/src/include/keymap.h @@ -0,0 +1,13 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later +#ifndef _KBD_LIBKEYMAP_H_ +#define _KBD_LIBKEYMAP_H_ + +#include +#include +#include +#include +#include +#include +#include + +#endif /* _KBD_LIBKEYMAP_H_ */ diff --git a/src/include/kfont.h b/src/include/kfont.h new file mode 100644 index 00000000..a4eb8fb3 --- /dev/null +++ b/src/include/kfont.h @@ -0,0 +1,7 @@ +// SPDX-License-Identifier: LGPL-2.0-or-later +#ifndef _KBD_LIBKFONT_H_ +#define _KBD_LIBKFONT_H_ + +#include + +#endif /* _KBD_LIBKFONT_H_ */ diff --git a/src/kbd_mode.c b/src/kbd_mode.c index 13074fb9..79ca39d6 100644 --- a/src/kbd_mode.c +++ b/src/kbd_mode.c @@ -19,7 +19,7 @@ #include "libcommon.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/kbdinfo.c b/src/kbdinfo.c index 3c338162..7f55fc24 100644 --- a/src/kbdinfo.c +++ b/src/kbdinfo.c @@ -15,7 +15,7 @@ static const char *action = NULL; static const char *value = NULL; -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, diff --git a/src/kbdrate.c b/src/kbdrate.c index 4a746a3d..c31eaf56 100644 --- a/src/kbdrate.c +++ b/src/kbdrate.c @@ -229,7 +229,7 @@ KIOCSRATE_ioctl_ok(double rate, int delay, int silent) #endif /* KIOCSRATE */ static void -sigalrmhandler(int sig __attribute__((unused))) +sigalrmhandler(int sig KBD_ATTR_UNUSED) { kbd_warning(0, "Failed waiting for kbd controller!\n"); raise(SIGINT); @@ -315,7 +315,7 @@ static double rate = 10.9; /* Default rate */ static int delay = 250; /* Default delay */ #endif -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/libcommon/libcommon.h b/src/libcommon/libcommon.h index 5a61354e..3f79fb05 100644 --- a/src/libcommon/libcommon.h +++ b/src/libcommon/libcommon.h @@ -1,9 +1,7 @@ #ifndef _LIBCOMMON_H_ #define _LIBCOMMON_H_ -#ifndef __GNUC__ -#define __attribute__(x) /*NOTHING*/ -#endif +#include #ifndef LOCALEDIR #define LOCALEDIR "/usr/share/locale" @@ -48,21 +46,19 @@ extern const char *progname; const char *get_progname(void); void set_progname(const char *name); -void -__attribute__((noreturn)) -print_version_and_exit(void); +void print_version_and_exit(void) + KBD_ATTR_NORETURN; void print_options(const struct kbd_help *options); void print_report_bugs(void); // error.c -void -__attribute__((format(printf, 2, 3))) -kbd_warning(const int errnum, const char *fmt, ...); +void kbd_warning(const int errnum, const char *fmt, ...) + KBD_ATTR_PRINTF(2, 3); void -__attribute__((noreturn)) -__attribute__((format(printf, 3, 4))) -kbd_error(const int exitnum, const int errnum, const char *fmt, ...); +kbd_error(const int exitnum, const int errnum, const char *fmt, ...) + KBD_ATTR_PRINTF(3, 4) + KBD_ATTR_NORETURN; #endif /* _LIBCOMMON_H_ */ diff --git a/src/libkbdfile/Makefile.am b/src/libkbdfile/Makefile.am index 7cdb5264..c3bc7f69 100644 --- a/src/libkbdfile/Makefile.am +++ b/src/libkbdfile/Makefile.am @@ -1,9 +1,12 @@ include $(top_srcdir)/Makefile.common +AM_CPPFLAGS += -I$(srcdir) LDADD += $(top_builddir)/src/libcommon/libcommon.a headers = \ - kbdfile.h + ../include/kbd/compiler_attributes.h \ + ../include/kbdfile.h \ + ../include/kbd/kbdfile.h libkbdfile_la_SOURCES = \ $(headers) \ diff --git a/src/libkbdfile/init.c b/src/libkbdfile/init.c index 835ed90a..d9ebb867 100644 --- a/src/libkbdfile/init.c +++ b/src/libkbdfile/init.c @@ -22,19 +22,13 @@ kbdfile_log(struct kbdfile_ctx *ctx, int priority, va_end(args); } -#ifndef DEBUG -#define log_unused __attribute__((unused)) -#else -#define log_unused -#endif - -static void __attribute__((format(printf, 6, 0))) +static void KBD_ATTR_PRINTF(6, 0) log_file(void *data, - int priority log_unused, - const char *file log_unused, - const int line log_unused, - const char *fn log_unused, - const char *format, va_list args) + int priority KBD_ATTR_UNUSED, + const char *file KBD_ATTR_UNUSED, + const int line KBD_ATTR_UNUSED, + const char *fn KBD_ATTR_UNUSED, + const char *format, va_list args) { FILE *fp = data; #ifdef DEBUG @@ -76,8 +70,6 @@ log_file(void *data, fprintf(fp, "\n"); } -#undef log_unused - kbdfile_logger_t kbdfile_get_log_fn(struct kbdfile_ctx *ctx) { diff --git a/src/libkeymap/Makefile.am b/src/libkeymap/Makefile.am index 2a578d15..097ea5c4 100644 --- a/src/libkeymap/Makefile.am +++ b/src/libkeymap/Makefile.am @@ -8,15 +8,18 @@ LK_REVISION = 0 LK_AGE = 0 headers = \ - keymap.h \ - keymap/array.h \ - keymap/context.h \ - keymap/charset.h \ - keymap/common.h \ - keymap/dump.h \ - keymap/kernel.h \ - keymap/kmap.h \ - keymap/logging.h + ../include/kbd/compiler_attributes.h \ + ../include/keymap.h \ + ../include/kbd/keymap/array.h \ + ../include/kbd/keymap/context.h \ + ../include/kbd/keymap/charset.h \ + ../include/kbd/keymap/common.h \ + ../include/kbd/keymap/dump.h \ + ../include/kbd/keymap/kernel.h \ + ../include/kbd/keymap/kmap.h \ + ../include/kbd/keymap/logging.h + +AM_CPPFLAGS += -I$(srcdir) SYMS = \ syms.latin1.h/8859-1/160 \ diff --git a/src/libkeymap/array.c b/src/libkeymap/array.c index e4fb0d47..0cf7da01 100644 --- a/src/libkeymap/array.c +++ b/src/libkeymap/array.c @@ -6,7 +6,7 @@ #include #include -#include +#include int lk_array_init(struct lk_array *a, ssize_t memb, ssize_t size) diff --git a/src/libkeymap/common.c b/src/libkeymap/common.c index c515e01b..261c2e51 100644 --- a/src/libkeymap/common.c +++ b/src/libkeymap/common.c @@ -22,18 +22,12 @@ lk_log(struct lk_ctx *ctx, int priority, va_end(args); } -#ifndef DEBUG -#define log_unused __attribute__((unused)) -#else -#define log_unused -#endif - -static void __attribute__((format(printf, 6, 0))) +static void KBD_ATTR_PRINTF(6, 0) log_file(void *data, - int priority log_unused, - const char *file log_unused, - const int line log_unused, - const char *fn log_unused, + int priority KBD_ATTR_UNUSED, + const char *file KBD_ATTR_UNUSED, + const int line KBD_ATTR_UNUSED, + const char *fn KBD_ATTR_UNUSED, const char *format, va_list args) { FILE *fp = data; @@ -76,8 +70,6 @@ log_file(void *data, fprintf(fp, "\n"); } -#undef log_unused - int lk_set_log_fn(struct lk_ctx *ctx, lk_logger_t log_fn, const void *data) { if (!ctx) diff --git a/src/libkeymap/keymap.h b/src/libkeymap/keymap.h deleted file mode 100644 index 7fad5cb5..00000000 --- a/src/libkeymap/keymap.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef LK_KEYMAP_H -#define LK_KEYMAP_H - -#include -#include -#include -#include -#include -#include -#include - -#endif /* LK_KEYMAP_H */ diff --git a/src/libkeymap/keymap/kmap.h b/src/libkeymap/keymap/kmap.h deleted file mode 100644 index 46b93edd..00000000 --- a/src/libkeymap/keymap/kmap.h +++ /dev/null @@ -1,46 +0,0 @@ -/** - * @file kmap.h - * @brief Functions for keymaps manipulation (add/delete keys). - */ -#ifndef LK_KMAP_H -#define LK_KMAP_H - -#include - -#ifndef __GNUC__ -#undef __attribute__ -#define __attribute__(x) /*NOTHING*/ -#endif - -int lk_add_map(struct lk_ctx *ctx, int k_table) __attribute__((nonnull(1))); -int lk_map_exists(struct lk_ctx *ctx, int k_table) __attribute__((nonnull(1))); - -int lk_get_keys_total(struct lk_ctx *ctx, int k_table) __attribute__((nonnull(1))); - -int lk_add_key(struct lk_ctx *ctx, int k_table, int k_index, int keycode) __attribute__((nonnull(1))); -int lk_del_key(struct lk_ctx *ctx, int k_table, int k_index) __attribute__((nonnull(1))); -int lk_get_key(struct lk_ctx *ctx, int k_table, int k_index) __attribute__((nonnull(1))); -int lk_key_exists(struct lk_ctx *ctx, int k_table, int k_index) __attribute__((nonnull(1))); - -/* Functions for key string manipulations */ -int lk_get_func(struct lk_ctx *ctx, struct kbsentry *kbs) __attribute__((nonnull(1, 2))); -int lk_add_func(struct lk_ctx *ctx, struct kbsentry *kbs) __attribute__((nonnull(1, 2))); -int lk_del_func(struct lk_ctx *ctx, int index) __attribute__((nonnull(1))); -int lk_func_exists(struct lk_ctx *ctx, int index) __attribute__((nonnull(1))); - -/* Functions for manipulations with diacritical table */ -int lk_get_diacr(struct lk_ctx *ctx, int index, struct lk_kbdiacr *dcr) __attribute__((nonnull(1, 3))); -int lk_add_diacr(struct lk_ctx *ctx, int index, struct lk_kbdiacr *dcr) __attribute__((nonnull(1, 3))); -int lk_del_diacr(struct lk_ctx *ctx, int index) __attribute__((nonnull(1))); -int lk_diacr_exists(struct lk_ctx *ctx, int index) __attribute__((nonnull(1))); -int lk_append_diacr(struct lk_ctx *ctx, struct lk_kbdiacr *dcr) __attribute__((nonnull(1, 2))); -int lk_append_compose(struct lk_ctx *ctx, struct lk_kbdiacr *dcr) __attribute__((nonnull(1, 2))); - -int lk_add_constants(struct lk_ctx *ctx) __attribute__((nonnull(1))); - -#include - -int lk_parse_keymap(struct lk_ctx *ctx, struct kbdfile *f) __attribute__((nonnull(1, 2))); -int lk_load_keymap(struct lk_ctx *ctx, int fd, int kbd_mode) __attribute__((nonnull(1))); - -#endif /* LK_KMAP_H */ diff --git a/src/libkeymap/parser.y b/src/libkeymap/parser.y index d9a465ee..1c3cd69e 100644 --- a/src/libkeymap/parser.y +++ b/src/libkeymap/parser.y @@ -68,7 +68,7 @@ struct strdata { %{ static int -yyerror(yyscan_t scanner __attribute__ ((unused)), +yyerror(yyscan_t scanner KBD_ATTR_UNUSED, struct lk_ctx *ctx, const char *s) { ERR(ctx, "%s", s); diff --git a/src/libkfont/Makefile.am b/src/libkfont/Makefile.am index 73acd93f..2cc8cf18 100644 --- a/src/libkfont/Makefile.am +++ b/src/libkfont/Makefile.am @@ -7,6 +7,7 @@ include $(top_srcdir)/Makefile.common CLEANFILES = libkfont.pc EXTRA_DIST = libkfont.pc.gen libkfont.map +AM_CPPFLAGS += -I$(srcdir) LDADD += $(top_builddir)/src/libcommon/libcommon.a KFONT_CURRENT = 2 @@ -17,8 +18,14 @@ KFONT_SHAREDLIB = libkfont.so KFONT_SONAME = $(KFONT_SHAREDLIB).$(KFONT_CURRENT) KFONT_MAPFILE = $(top_srcdir)/src/libkfont/libkfont.map +headers = \ + ../include/kbd/compiler_attributes.h \ + ../include/kfont.h \ + ../include/kbd/kfont.h + libkfont_la_SOURCES = \ - kfont.h kfontP.h \ + $(headers) \ + kfontP.h \ psffontop.c \ psfxtable.c \ context.c \ @@ -37,7 +44,7 @@ if BUILD_LIBKFONT pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = libkfont.pc -nobase_include_HEADERS = kfont.h +nobase_include_HEADERS = $(headers) lib_LTLIBRARIES = libkfont.la else noinst_LTLIBRARIES = libkfont.la diff --git a/src/libkfont/kfontP.h b/src/libkfont/kfontP.h index 0a46e5d5..4c5be8f1 100644 --- a/src/libkfont/kfontP.h +++ b/src/libkfont/kfontP.h @@ -5,7 +5,7 @@ #ifndef _KFONT_PRIVATE_H_ #define _KFONT_PRIVATE_H_ -#include "kfont.h" +#include struct kfont_context { const char *progname; @@ -29,8 +29,8 @@ struct kfont_context { void logger(struct kfont_context *ctx, int priority, const char *file, int line, const char *fn, const char *fmt, ...) - __attribute__((format(printf, 6, 7))) - __attribute__((nonnull(1))); + KBD_ATTR_PRINTF(6, 7) + KBD_ATTR_NONNULL(1); #include @@ -41,8 +41,8 @@ void logger(struct kfont_context *ctx, int priority, const char *file, void log_stderr(struct kfont_context *ctx, int priority, const char *file, const int line, const char *fn, const char *format, va_list args) - __attribute__((format(printf, 6, 0))) - __attribute__((nonnull(1))); + KBD_ATTR_PRINTF(6, 0) + KBD_ATTR_NONNULL(1); /* unicode.c */ @@ -66,7 +66,7 @@ void clear_uni_entry(struct unicode_list *up); int appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp, unsigned int ct, int utf8) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* kdfontop.c */ @@ -77,7 +77,7 @@ int appendunicodemap(struct kfont_context *ctx, int fd, FILE *fp, */ int getfont(struct kfont_context *ctx, int fd, unsigned char *buf, unsigned int *count, unsigned int *width, unsigned int *height) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* * Load kernel font of width WIDTH and pointsize HEIGHT from BUF @@ -86,7 +86,7 @@ int getfont(struct kfont_context *ctx, int fd, unsigned char *buf, */ int putfont(struct kfont_context *ctx, int fd, unsigned char *buf, unsigned int count, unsigned int width, unsigned int height) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* * Find the maximum height of nonblank pixels @@ -94,15 +94,15 @@ int putfont(struct kfont_context *ctx, int fd, unsigned char *buf, */ unsigned int font_charheight(unsigned char *buf, unsigned int count, unsigned int width) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* kdmapop.c */ int getscrnmap(struct kfont_context *ctx, int fd, unsigned char *map) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); int loadscrnmap(struct kfont_context *ctx, int fd, unsigned char *map) - __attribute__((nonnull(1))); + KBD_ATTR_NONNULL(1); /* psffontop.c */ diff --git a/src/loadkeys.c b/src/loadkeys.c index c3b20acb..643fe827 100644 --- a/src/loadkeys.c +++ b/src/loadkeys.c @@ -20,9 +20,9 @@ #include #include -#include "libcommon.h" +#include -#include "keymap.h" +#include "libcommon.h" static const char *const dirpath1[] = { DATADIR "/" KEYMAPDIR "/**", @@ -36,7 +36,7 @@ static const char *const suffixes[] = { NULL }; -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] [mapfile...]\n"), get_progname()); diff --git a/src/loadunimap.c b/src/loadunimap.c index 32d6c4de..9a22f54f 100644 --- a/src/loadunimap.c +++ b/src/loadunimap.c @@ -17,10 +17,11 @@ #include #include +#include + #include "libcommon.h" -#include "kfont.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/mapscrn.c b/src/mapscrn.c index a25221e1..1f7b6b99 100644 --- a/src/mapscrn.c +++ b/src/mapscrn.c @@ -15,10 +15,11 @@ #include #include +#include + #include "libcommon.h" -#include "kfont.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] [map-file]\n"), get_progname()); diff --git a/src/openvt.c b/src/openvt.c index 6ae0dfb4..52053a92 100644 --- a/src/openvt.c +++ b/src/openvt.c @@ -44,7 +44,7 @@ #error vt device name must be defined #endif -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] -- command\n"), get_progname()); @@ -154,9 +154,7 @@ open_vt(char *vtname, int force) } static void -sighandler(int sig __attribute__((unused)), - siginfo_t *si __attribute__((unused)), - void *uc __attribute__((unused))) +sighandler(int sig KBD_ATTR_UNUSED, siginfo_t *si KBD_ATTR_UNUSED, void *uc KBD_ATTR_UNUSED) { return; } diff --git a/src/outpsfheader.c b/src/outpsfheader.c index 9bf63685..38a9c50d 100644 --- a/src/outpsfheader.c +++ b/src/outpsfheader.c @@ -6,10 +6,11 @@ #include /* exit */ #include +#include + #include "libcommon.h" -#include "kfont.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(void) { fprintf(stderr, "call: outpsfheader psftype fontsize charsize hastable\n"); diff --git a/src/psfxtable.c b/src/psfxtable.c index 63221c44..361dc64e 100644 --- a/src/psfxtable.c +++ b/src/psfxtable.c @@ -20,8 +20,9 @@ #include #include +#include + #include "libcommon.h" -#include "kfont.h" /* * call: psfxtable -i infont -o outfont -it intable -ot outtable diff --git a/src/readpsfheader.c b/src/readpsfheader.c index e1fda7a1..9af4e375 100644 --- a/src/readpsfheader.c +++ b/src/readpsfheader.c @@ -4,10 +4,11 @@ #include #include /* exit */ +#include + #include "libcommon.h" -#include "kfont.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(void) { fprintf(stderr, "usage: readpsfheader font.psf\n"); diff --git a/src/resizecons.c b/src/resizecons.c index 5e82dfc3..8886eabb 100644 --- a/src/resizecons.c +++ b/src/resizecons.c @@ -89,7 +89,7 @@ #define MODE_RESTORETEXTMODE 0 #define MODE_VGALINES 1 -static void usage(void) __attribute__((noreturn)); +static void usage(void) KBD_ATTR_NORETURN; /* VGA textmode register tweaking. */ static void vga_init_io(void); @@ -368,7 +368,7 @@ int main(int argc, char **argv) return EXIT_SUCCESS; } -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(void) { fprintf(stderr, diff --git a/src/setfont.c b/src/setfont.c index 25ab6680..16ab4fb4 100644 --- a/src/setfont.c +++ b/src/setfont.c @@ -10,10 +10,11 @@ #include #include +#include + #include "libcommon.h" -#include "kfont.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int retcode, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] [newfont...]\n"), get_progname()); diff --git a/src/setkeycodes.c b/src/setkeycodes.c index bc835fe7..09737502 100644 --- a/src/setkeycodes.c +++ b/src/setkeycodes.c @@ -20,7 +20,7 @@ #include "libcommon.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] scancode keycode ...\n"), get_progname()); diff --git a/src/setleds.c b/src/setleds.c index 6527acbb..6aeaf2a1 100644 --- a/src/setleds.c +++ b/src/setleds.c @@ -25,7 +25,7 @@ #define BITMASK_UNSET(x, mask) ((x) & BITWISE_NOT(mask)) #define BITMASK_SET(x, mask) ((x) | (mask)) -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] [[+|-][ num | caps | scroll %s]]\n"), @@ -123,14 +123,8 @@ getflags(unsigned char *flags) static int sunkbdfd = -1; -#ifndef KIOCGLED -#define arg_state __attribute__((unused)) -#else -#define arg_state -#endif - static void -sungetleds(arg_state unsigned char *cur_leds) +sungetleds(unsigned char *cur_leds KBD_ATTR_UNUSED) { #ifdef KIOCGLED if (ioctl(sunkbdfd, KIOCGLED, cur_leds)) { @@ -142,14 +136,8 @@ sungetleds(arg_state unsigned char *cur_leds) #endif } -#ifndef KIOCSLED -#define arg_state __attribute__((unused)) -#else -#define arg_state -#endif - static void -sunsetleds(arg_state unsigned char *cur_leds) +sunsetleds(unsigned char *cur_leds KBD_ATTR_UNUSED) { #ifdef KIOCSLED if (ioctl(sunkbdfd, KIOCSLED, cur_leds)) { diff --git a/src/setmetamode.c b/src/setmetamode.c index e09b971f..666581f9 100644 --- a/src/setmetamode.c +++ b/src/setmetamode.c @@ -19,7 +19,7 @@ #include "libcommon.h" -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] [argument]\n"), get_progname()); diff --git a/src/setvtrgb.c b/src/setvtrgb.c index 4f6c39c9..138e8d28 100644 --- a/src/setvtrgb.c +++ b/src/setvtrgb.c @@ -36,7 +36,7 @@ static unsigned char vga_colors[] = { 0xff, 0xff, 0xff, }; -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...] [vga|FILE|-]\n"), get_progname()); diff --git a/src/showconsolefont.c b/src/showconsolefont.c index 83165ab8..d97808ab 100644 --- a/src/showconsolefont.c +++ b/src/showconsolefont.c @@ -12,8 +12,9 @@ #include #include +#include + #include "libcommon.h" -#include "kfont.h" /* * Showing the font is nontrivial mostly because testing whether @@ -28,7 +29,7 @@ static int fd = 0; static int have_obuf = 0; static int have_ounimap = 0; -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN leave(struct kfont_context *ctx, int n) { if (have_obuf && kfont_put_uniscrnmap(ctx, fd, obuf)) { @@ -95,7 +96,7 @@ setnewunicodemap(struct kfont_context *ctx, unsigned int *list, int cnt) leave(ctx, EXIT_FAILURE); } -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/showkey.c b/src/showkey.c index 2a31dfb8..9d6bdaeb 100644 --- a/src/showkey.c +++ b/src/showkey.c @@ -68,7 +68,7 @@ clean_up(void) close(fd); } -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN die(int x) { printf(_("caught signal %d, cleaning up...\n"), x); @@ -76,14 +76,14 @@ die(int x) exit(EXIT_FAILURE); } -static void __attribute__((noreturn)) -watch_dog(int x __attribute__((unused))) +static void KBD_ATTR_NORETURN +watch_dog(int x KBD_ATTR_UNUSED) { clean_up(); exit(EXIT_SUCCESS); } -static void __attribute__((noreturn)) +static void KBD_ATTR_NORETURN usage(int rc, const struct kbd_help *options) { fprintf(stderr, _("Usage: %s [option...]\n"), get_progname()); diff --git a/src/spawn_command.c b/src/spawn_command.c index a7b391da..0e6e0865 100644 --- a/src/spawn_command.c +++ b/src/spawn_command.c @@ -32,7 +32,7 @@ #endif static void -sighup(int n __attribute__((unused))) +sighup(int n KBD_ATTR_UNUSED) { if (system(COMMAND) == -1) { kbd_error(EXIT_FAILURE, errno, "system"); @@ -40,7 +40,7 @@ sighup(int n __attribute__((unused))) signal(SIGHUP, sighup); } -int main(int argc __attribute__((unused)), char *argv[]) +int main(int argc KBD_ATTR_UNUSED, char *argv[]) { int fd; diff --git a/src/vlock/parse.c b/src/vlock/parse.c index f4dc0b9b..30f11c05 100644 --- a/src/vlock/parse.c +++ b/src/vlock/parse.c @@ -45,7 +45,7 @@ locked_name(void) return o_lock_all ? "console" : (is_vt ? "VC" : "tty"); } -static void __attribute__((__noreturn__)) +static void KBD_ATTR_NORETURN show_usage(void) { fprintf(stderr, @@ -54,7 +54,7 @@ show_usage(void) exit(EX_USAGE); } -static void __attribute__((__noreturn__)) +static void KBD_ATTR_NORETURN show_help(void) { const char *name = get_progname(); diff --git a/src/vlock/vt.c b/src/vlock/vt.c index c2575494..e8bc5da5 100644 --- a/src/vlock/vt.c +++ b/src/vlock/vt.c @@ -50,7 +50,7 @@ int is_vt; * the VC (with a ALT-Fn key or via VT_ACTIVATE). */ static void -release_vt(__attribute__((unused)) int signo) +release_vt(int signo KBD_ATTR_UNUSED) { /* * Kernel is not allowed to switch. @@ -61,7 +61,7 @@ release_vt(__attribute__((unused)) int signo) /* This is called whenever a user switches to that VC. */ static void -acquire_vt(__attribute__((unused)) int signo) +acquire_vt(int signo KBD_ATTR_UNUSED) { /* * This call is not currently required under Linux, diff --git a/tests/helpers/Makefile.am b/tests/helpers/Makefile.am index 054317b5..1febcb36 100644 --- a/tests/helpers/Makefile.am +++ b/tests/helpers/Makefile.am @@ -2,9 +2,9 @@ NULL = AM_CPPFLAGS = \ $(CODE_COVERAGE_CPPFLAGS) \ + -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libkeymap \ - -I$(top_srcdir)/src/libkbdfile + -I$(top_srcdir)/src/libkeymap AM_CFLAGS = $(CHECK_CFLAGS) $(CODE_COVERAGE_CFLAGS) diff --git a/tests/helpers/libkeymap-bkeymap.c b/tests/helpers/libkeymap-bkeymap.c index 96c521b1..e336dd49 100644 --- a/tests/helpers/libkeymap-bkeymap.c +++ b/tests/helpers/libkeymap-bkeymap.c @@ -5,7 +5,7 @@ #include "libcommon.h" -int main(int __attribute__((unused)) argc, char **argv) +int main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/helpers/libkeymap-dumpkeys.c b/tests/helpers/libkeymap-dumpkeys.c index 861048cb..9cd55da4 100644 --- a/tests/helpers/libkeymap-dumpkeys.c +++ b/tests/helpers/libkeymap-dumpkeys.c @@ -6,7 +6,7 @@ #include "libcommon.h" -int main(int __attribute__((unused)) argc, char **argv) +int main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/helpers/libkeymap-mktable.c b/tests/helpers/libkeymap-mktable.c index 704e37df..bbe8fa8d 100644 --- a/tests/helpers/libkeymap-mktable.c +++ b/tests/helpers/libkeymap-mktable.c @@ -6,7 +6,7 @@ #include "libcommon.h" -int main(int __attribute__((unused)) argc, char **argv) +int main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/helpers/libkeymap-showmaps.c b/tests/helpers/libkeymap-showmaps.c index 02639b90..14e2b0de 100644 --- a/tests/helpers/libkeymap-showmaps.c +++ b/tests/helpers/libkeymap-showmaps.c @@ -6,7 +6,7 @@ #include "libcommon.h" #include "contextP.h" -int main(int __attribute__((unused)) argc, char **argv) +int main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/Makefile.am b/tests/libkbdfile/Makefile.am index bc76e18f..6a3ac7e6 100644 --- a/tests/libkbdfile/Makefile.am +++ b/tests/libkbdfile/Makefile.am @@ -2,8 +2,8 @@ NULL = AM_CPPFLAGS = \ $(CODE_COVERAGE_CPPFLAGS) \ + -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libkbdfile \ -DTESTDIR=\"$(realpath $(top_srcdir))/tests\" AM_CFLAGS = $(CHECK_CFLAGS) $(CODE_COVERAGE_CFLAGS) diff --git a/tests/libkbdfile/libkbdfile-test01.c b/tests/libkbdfile/libkbdfile-test01.c index f836a623..1da225a3 100644 --- a/tests/libkbdfile/libkbdfile-test01.c +++ b/tests/libkbdfile/libkbdfile-test01.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test02.c b/tests/libkbdfile/libkbdfile-test02.c index 6dddaff0..337abba9 100644 --- a/tests/libkbdfile/libkbdfile-test02.c +++ b/tests/libkbdfile/libkbdfile-test02.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test03.c b/tests/libkbdfile/libkbdfile-test03.c index afe42721..ace65ed1 100644 --- a/tests/libkbdfile/libkbdfile-test03.c +++ b/tests/libkbdfile/libkbdfile-test03.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); struct kbdfile *fp = kbdfile_new(NULL); diff --git a/tests/libkbdfile/libkbdfile-test04.c b/tests/libkbdfile/libkbdfile-test04.c index b0ebaa0f..e77c0362 100644 --- a/tests/libkbdfile/libkbdfile-test04.c +++ b/tests/libkbdfile/libkbdfile-test04.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test05.c b/tests/libkbdfile/libkbdfile-test05.c index 9e07841c..64eb4817 100644 --- a/tests/libkbdfile/libkbdfile-test05.c +++ b/tests/libkbdfile/libkbdfile-test05.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); struct kbdfile *fp = kbdfile_new(NULL); diff --git a/tests/libkbdfile/libkbdfile-test06.c b/tests/libkbdfile/libkbdfile-test06.c index 4e5d1ce7..bbb4120d 100644 --- a/tests/libkbdfile/libkbdfile-test06.c +++ b/tests/libkbdfile/libkbdfile-test06.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test07.c b/tests/libkbdfile/libkbdfile-test07.c index de3d667b..9674b818 100644 --- a/tests/libkbdfile/libkbdfile-test07.c +++ b/tests/libkbdfile/libkbdfile-test07.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test08.c b/tests/libkbdfile/libkbdfile-test08.c index 387be43f..3193931e 100644 --- a/tests/libkbdfile/libkbdfile-test08.c +++ b/tests/libkbdfile/libkbdfile-test08.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); struct kbdfile *fp = kbdfile_new(NULL); diff --git a/tests/libkbdfile/libkbdfile-test09.c b/tests/libkbdfile/libkbdfile-test09.c index 7d6a97e9..effe3dfa 100644 --- a/tests/libkbdfile/libkbdfile-test09.c +++ b/tests/libkbdfile/libkbdfile-test09.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test10.c b/tests/libkbdfile/libkbdfile-test10.c index b2108966..e8d08aea 100644 --- a/tests/libkbdfile/libkbdfile-test10.c +++ b/tests/libkbdfile/libkbdfile-test10.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test11.c b/tests/libkbdfile/libkbdfile-test11.c index 29435d8a..2d21251d 100644 --- a/tests/libkbdfile/libkbdfile-test11.c +++ b/tests/libkbdfile/libkbdfile-test11.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test12.c b/tests/libkbdfile/libkbdfile-test12.c index abe7175a..01f1fc2e 100644 --- a/tests/libkbdfile/libkbdfile-test12.c +++ b/tests/libkbdfile/libkbdfile-test12.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkbdfile/libkbdfile-test13.c b/tests/libkbdfile/libkbdfile-test13.c index 8182227b..6611ef26 100644 --- a/tests/libkbdfile/libkbdfile-test13.c +++ b/tests/libkbdfile/libkbdfile-test13.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/Makefile.am b/tests/libkeymap/Makefile.am index 0a6d7e41..d461016d 100644 --- a/tests/libkeymap/Makefile.am +++ b/tests/libkeymap/Makefile.am @@ -2,9 +2,8 @@ NULL = AM_CPPFLAGS = \ $(CODE_COVERAGE_CPPFLAGS) \ + -I$(top_srcdir)/src/include \ -I$(top_srcdir)/src/libcommon \ - -I$(top_srcdir)/src/libkbdfile \ - -I$(top_srcdir)/src/libkeymap \ -DTESTDIR=\"$(realpath $(top_srcdir))/tests\" AM_CFLAGS = $(CHECK_CFLAGS) $(CODE_COVERAGE_CFLAGS) diff --git a/tests/libkeymap/libkeymap-test01.c b/tests/libkeymap/libkeymap-test01.c index 9fec3d6c..feda827e 100644 --- a/tests/libkeymap/libkeymap-test01.c +++ b/tests/libkeymap/libkeymap-test01.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test02.c b/tests/libkeymap/libkeymap-test02.c index a780983e..241ce6dd 100644 --- a/tests/libkeymap/libkeymap-test02.c +++ b/tests/libkeymap/libkeymap-test02.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test03.c b/tests/libkeymap/libkeymap-test03.c index 93c30eff..9c63baf6 100644 --- a/tests/libkeymap/libkeymap-test03.c +++ b/tests/libkeymap/libkeymap-test03.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test04.c b/tests/libkeymap/libkeymap-test04.c index 7722ea09..f51227cb 100644 --- a/tests/libkeymap/libkeymap-test04.c +++ b/tests/libkeymap/libkeymap-test04.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test05.c b/tests/libkeymap/libkeymap-test05.c index ab65a7f2..cb52dc78 100644 --- a/tests/libkeymap/libkeymap-test05.c +++ b/tests/libkeymap/libkeymap-test05.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test06.c b/tests/libkeymap/libkeymap-test06.c index 63d06aa7..02f56b0c 100644 --- a/tests/libkeymap/libkeymap-test06.c +++ b/tests/libkeymap/libkeymap-test06.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test07.c b/tests/libkeymap/libkeymap-test07.c index 4ac6e222..ca7c8aa7 100644 --- a/tests/libkeymap/libkeymap-test07.c +++ b/tests/libkeymap/libkeymap-test07.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test08.c b/tests/libkeymap/libkeymap-test08.c index bb905a12..08b29e76 100644 --- a/tests/libkeymap/libkeymap-test08.c +++ b/tests/libkeymap/libkeymap-test08.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test09.c b/tests/libkeymap/libkeymap-test09.c index 4c78a775..d7abec28 100644 --- a/tests/libkeymap/libkeymap-test09.c +++ b/tests/libkeymap/libkeymap-test09.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test10.c b/tests/libkeymap/libkeymap-test10.c index d9c4beea..23bda32a 100644 --- a/tests/libkeymap/libkeymap-test10.c +++ b/tests/libkeymap/libkeymap-test10.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test11.c b/tests/libkeymap/libkeymap-test11.c index 67f696a3..2f7cfd34 100644 --- a/tests/libkeymap/libkeymap-test11.c +++ b/tests/libkeymap/libkeymap-test11.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test12.c b/tests/libkeymap/libkeymap-test12.c index da4e6bec..eefbd347 100644 --- a/tests/libkeymap/libkeymap-test12.c +++ b/tests/libkeymap/libkeymap-test12.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test13.c b/tests/libkeymap/libkeymap-test13.c index d3df5602..e136d960 100644 --- a/tests/libkeymap/libkeymap-test13.c +++ b/tests/libkeymap/libkeymap-test13.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test14.c b/tests/libkeymap/libkeymap-test14.c index af237c94..3602a137 100644 --- a/tests/libkeymap/libkeymap-test14.c +++ b/tests/libkeymap/libkeymap-test14.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test15.c b/tests/libkeymap/libkeymap-test15.c index 28fdf632..422c3abe 100644 --- a/tests/libkeymap/libkeymap-test15.c +++ b/tests/libkeymap/libkeymap-test15.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test16.c b/tests/libkeymap/libkeymap-test16.c index 61c51907..1b88ba24 100644 --- a/tests/libkeymap/libkeymap-test16.c +++ b/tests/libkeymap/libkeymap-test16.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test17.c b/tests/libkeymap/libkeymap-test17.c index af540407..0d5980b0 100644 --- a/tests/libkeymap/libkeymap-test17.c +++ b/tests/libkeymap/libkeymap-test17.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]); diff --git a/tests/libkeymap/libkeymap-test18.c b/tests/libkeymap/libkeymap-test18.c index 2656b79b..92528a37 100644 --- a/tests/libkeymap/libkeymap-test18.c +++ b/tests/libkeymap/libkeymap-test18.c @@ -7,7 +7,7 @@ #include "libcommon.h" int -main(int __attribute__((unused)) argc, char **argv) +main(int argc KBD_ATTR_UNUSED, char **argv) { set_progname(argv[0]);