[PATCH v2 2/2] erofs-utils: Make erofs-utils more C++ friendly

Gao Xiang hsiangkao at linux.alibaba.com
Tue Nov 30 16:23:03 AEDT 2021


On Mon, Nov 29, 2021 at 07:25:46PM -0800, Kelvin Zhang wrote:
> 1. Add extern "C" wrappers to headers, so that they can be included from
> C++
> 2. Add const keyworkds to certain pointer type params
> 
> Change-Id: Ica96c5626de7cc511ffa9a73e0e5ddf7601a7451
> Signed-off-by: Kelvin Zhang <zhangkelvin at google.com>
> ---
>  include/erofs/blobchunk.h      | 10 ++++++++++
>  include/erofs/block_list.h     | 10 ++++++++++
>  include/erofs/cache.h          |  9 +++++++++
>  include/erofs/compress.h       |  9 +++++++++
>  include/erofs/compress_hints.h | 10 ++++++++++
>  include/erofs/config.h         | 20 +++++++++-----------
>  include/erofs/decompress.h     |  9 +++++++++
>  include/erofs/defs.h           | 20 ++++++++++++++++++++
>  include/erofs/err.h            |  9 +++++++++
>  include/erofs/exclude.h        | 10 ++++++++++
>  include/erofs/flex-array.h     |  9 +++++++++
>  include/erofs/hashmap.h        |  9 +++++++++
>  include/erofs/hashtable.h      |  9 +++++++++
>  include/erofs/inode.h          |  9 +++++++++
>  include/erofs/internal.h       |  9 +++++++++
>  include/erofs/io.h             | 11 +++++++++++
>  include/erofs/list.h           | 10 ++++++++++
>  include/erofs/print.h          |  9 +++++++++
>  include/erofs/trace.h          |  9 +++++++++
>  include/erofs/xattr.h          |  9 +++++++++
>  include/erofs_fs.h             |  9 +++++++++
>  lib/config.c                   | 12 ++++++++++++
>  lib/inode.c                    |  7 +++++++
>  lib/xattr.c                    | 12 ++++++++++++
>  mkfs/main.c                    |  7 +++++++
>  25 files changed, 245 insertions(+), 11 deletions(-)
> 

...

> diff --git a/include/erofs/config.h b/include/erofs/config.h
> index 2040dc6..6ba1a30 100644
> --- a/include/erofs/config.h
> +++ b/include/erofs/config.h
> @@ -7,20 +7,14 @@
>  #ifndef __EROFS_CONFIG_H
>  #define __EROFS_CONFIG_H
>  
> +#ifdef __cplusplus
> +extern "C"
> +{
> +#endif
> +
>  #include "defs.h"
>  #include "err.h"
>  
> -#ifdef HAVE_LIBSELINUX
> -#include <selinux/selinux.h>
> -#include <selinux/label.h>
> -#endif
> -
> -#ifdef WITH_ANDROID
> -#include <selinux/android.h>
> -#include <private/android_filesystem_config.h>
> -#include <private/canned_fs_config.h>
> -#include <private/fs_config.h>
> -#endif
>  

Out of curiousity, why do we move these headers to each source files?

Thanks,
Gao Xiang


More information about the Linux-erofs mailing list