From: Lucas De Marchi Date: Wed, 23 Nov 2011 14:21:29 +0000 (-0200) Subject: Add some function attributes and use them X-Git-Tag: v1~203 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f87081b4d18d7478bb76da20ae024a09817a78e8;p=thirdparty%2Fkmod.git Add some function attributes and use them --- diff --git a/libkmod/libkmod-list.c b/libkmod/libkmod-list.c index b7673c43..0c2b0d6b 100644 --- a/libkmod/libkmod-list.c +++ b/libkmod/libkmod-list.c @@ -22,7 +22,6 @@ #include "libkmod.h" #include "libkmod-private.h" -#include "libkmod-util.h" static inline struct list_node *list_node_init(struct list_node *node) { diff --git a/libkmod/libkmod-private.h b/libkmod/libkmod-private.h index 8208d94c..bcb32904 100644 --- a/libkmod/libkmod-private.h +++ b/libkmod/libkmod-private.h @@ -4,9 +4,10 @@ #include #include +#include "libkmod-util.h" #include "libkmod.h" -static inline void __attribute__((always_inline, format(printf, 2, 3))) +static __always_inline __printf_format(2, 3) void kmod_log_null(struct kmod_ctx *ctx, const char *format, ...) {} #define kmod_log_cond(ctx, prio, arg...) \ @@ -44,10 +45,10 @@ struct kmod_list { void *data; }; -struct kmod_list *kmod_list_append(struct kmod_list *list, void *data); -struct kmod_list *kmod_list_prepend(struct kmod_list *list, void *data); +struct kmod_list *kmod_list_append(struct kmod_list *list, void *data) __must_check; +struct kmod_list *kmod_list_prepend(struct kmod_list *list, void *data) __must_check; struct kmod_list *kmod_list_remove(struct kmod_list *list); struct kmod_list *kmod_list_remove_data(struct kmod_list *list, - const void *data); + const void *data) __must_check; #endif diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h index 81ccc997..19014d1d 100644 --- a/libkmod/libkmod-util.h +++ b/libkmod/libkmod-util.h @@ -1,3 +1,23 @@ +/* + * libkmod - interface to kernel module operations + * + * Copyright (C) 2011 ProFUSION embedded systems + * Copyright (C) 2011 Lucas De Marchi + * + * 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 version 2.1. + * + * 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 St, Fifth Floor, Boston, MA 02110-1301 USA + */ + #ifndef _LIBKMOD_UTIL_H_ #define _LIBKMOD_UTIL_H_ @@ -29,4 +49,10 @@ ((char *)(member_ptr) - offsetof(containing_type, member)) \ - check_types_match(*(member_ptr), ((containing_type *)0)->member)) +#define __must_check __attribute__((warn_unused_result)) +#define __printf_format(a,b) __attribute__((format (printf, a, b))) +#if !defined(__always_inline) +#define __always_inline __inline__ __attribute__((always_inline)) +#endif + #endif