From: Lucas De Marchi Date: Wed, 18 Jul 2012 13:19:48 +0000 (-0300) Subject: Use #pragma once instead of #ifndef X-Git-Tag: v10~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e8fd8fec236062e94e9486c64e482b780988f9bf;p=thirdparty%2Fkmod.git Use #pragma once instead of #ifndef Only the public header maintains #ifndef in the header, together with pragma. The other ones contain only pragma. As reported by Shawn Landden on systemd mailing list this is compatible with all major compilers and gcc has this since version 3.3. --- diff --git a/libkmod/libkmod-array.h b/libkmod/libkmod-array.h index 6400993b..dd2ba552 100644 --- a/libkmod/libkmod-array.h +++ b/libkmod/libkmod-array.h @@ -1,5 +1,4 @@ -#ifndef _LIBKMOD_ARRAY_H_ -#define _LIBKMOD_ARRAY_H_ +#pragma once /* * Declaration of struct array is in header because we may want to embed the @@ -19,5 +18,3 @@ void array_pop(struct array *array); void array_free_array(struct array *array); void array_sort(struct array *array, int (*cmp)(const void *a, const void *b)); int array_remove_at(struct array *array, unsigned int pos); - -#endif diff --git a/libkmod/libkmod-hash.h b/libkmod/libkmod-hash.h index 8f20b8f4..ca0af057 100644 --- a/libkmod/libkmod-hash.h +++ b/libkmod/libkmod-hash.h @@ -1,5 +1,4 @@ -#ifndef _LIBKMOD_HASH_H_ -#define _LIBKMOD_HASH_H_ +#pragma once #include @@ -21,5 +20,3 @@ unsigned int hash_get_count(const struct hash *hash); void hash_iter_init(const struct hash *hash, struct hash_iter *iter); bool hash_iter_next(struct hash_iter *iter, const char **key, const void **value); - -#endif diff --git a/libkmod/libkmod-index.h b/libkmod/libkmod-index.h index dd3a7626..6eb77b93 100644 --- a/libkmod/libkmod-index.h +++ b/libkmod/libkmod-index.h @@ -18,8 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _LIBKMOD_INDEX_H -#define _LIBKMOD_INDEX_H +#pragma once #include @@ -127,5 +126,3 @@ void index_mm_close(struct index_mm *index); char *index_mm_search(struct index_mm *idx, const char *key); struct index_value *index_mm_searchwild(struct index_mm *idx, const char *key); void index_mm_dump(struct index_mm *idx, int fd, const char *prefix); - -#endif diff --git a/libkmod/libkmod-private.h b/libkmod/libkmod-private.h index 7c2602d9..90618540 100644 --- a/libkmod/libkmod-private.h +++ b/libkmod/libkmod-private.h @@ -1,5 +1,4 @@ -#ifndef _LIBKMOD_PRIVATE_H_ -#define _LIBKMOD_PRIVATE_H_ +#pragma once #include #include @@ -170,5 +169,3 @@ int kmod_elf_get_section(const struct kmod_elf *elf, const char *section, const /* util functions */ #include "libkmod-util.h" - -#endif diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h index 7130ae02..5fe3e02e 100644 --- a/libkmod/libkmod-util.h +++ b/libkmod/libkmod-util.h @@ -1,6 +1,4 @@ -#ifndef _LIBKMOD_UTIL_H_ -#define _LIBKMOD_UTIL_H_ - +#pragma once #include "macro.h" #include @@ -42,5 +40,3 @@ do { \ } *__p = (typeof(__p)) (ptr); \ __p->__v = (val); \ } while(0) - -#endif diff --git a/libkmod/libkmod.h b/libkmod/libkmod.h index f907e1d8..2f813a85 100644 --- a/libkmod/libkmod.h +++ b/libkmod/libkmod.h @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#pragma once #ifndef _LIBKMOD_H_ #define _LIBKMOD_H_ diff --git a/libkmod/macro.h b/libkmod/macro.h index e5c9763c..689c57ab 100644 --- a/libkmod/macro.h +++ b/libkmod/macro.h @@ -17,9 +17,7 @@ * 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_MACRO_H_ -#define _LIBKMOD_MACRO_H_ +#pragma once #include @@ -82,5 +80,3 @@ #define _printf_format_(a,b) __attribute__((format (printf, a, b))) #define _unused_ __attribute__((unused)) #define _always_inline_ __inline__ __attribute__((always_inline)) - -#endif diff --git a/testsuite/mkdir.h b/testsuite/mkdir.h index 2530bd71..35f6a1d1 100644 --- a/testsuite/mkdir.h +++ b/testsuite/mkdir.h @@ -16,12 +16,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _LIBKMOD_TESTSUITE_MKDIR_ -#define _LIBKMOD_TESTSUITE_MKDIR_ +#pragma once #include #include int mkdir_p(const char *path, mode_t mode); - -#endif diff --git a/testsuite/stripped-module.h b/testsuite/stripped-module.h index 19862f3c..83986b2c 100644 --- a/testsuite/stripped-module.h +++ b/testsuite/stripped-module.h @@ -1,5 +1,4 @@ -#ifndef _TESTSUITE_STRIPPED_MODULE_H -#define _TESTSUITE_STRIPPED_MODULE_H +#pragma once enum module_state { @@ -28,5 +27,3 @@ struct module /* padding */ #define MODULE_NAME_OFFSET_64 4 + 4 + 2 * 8 #define MODULE_NAME_OFFSET_32 4 + 2 * 4 - -#endif diff --git a/testsuite/testsuite.h b/testsuite/testsuite.h index 16660545..1f8eb6ea 100644 --- a/testsuite/testsuite.h +++ b/testsuite/testsuite.h @@ -16,8 +16,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef _LIBKMOD_TESTSUITE_ -#define _LIBKMOD_TESTSUITE_ +#pragma once #include #include @@ -144,6 +143,4 @@ int test_run(const struct test *t); exit(EXIT_SUCCESS); \ } \ -#endif - #define __noreturn __attribute__((noreturn)) diff --git a/tools/kmod.h b/tools/kmod.h index 8717aec0..76a3426b 100644 --- a/tools/kmod.h +++ b/tools/kmod.h @@ -17,8 +17,7 @@ * along with this program. If not, see . */ -#ifndef _KMOD_MACRO_H_ -#define _KMOD_MACRO_H_ +#pragma once #include "macro.h" @@ -36,4 +35,3 @@ extern const struct kmod_cmd kmod_cmd_compat_modprobe; extern const struct kmod_cmd kmod_cmd_compat_depmod; extern const struct kmod_cmd kmod_cmd_list; -#endif