[LTP] [PATCH v7 01/16] Add SAFE_STATX macro

Cyril Hrubis chrubis@suse.cz
Wed Oct 9 11:12:15 CEST 2024


Hi!
> +LTP_DEFINE_STATX_STRUCT(statx_fallback);
> +
> +#ifdef HAVE_STRUCT_STATX
> +typedef struct statx ltp_statx_;
> +#else
> +LTP_DEFINE_STATX_STRUCT(statx);
> +
> +typedef struct statx_fallback ltp_statx_;
>  #endif

Do we need these typedefs at all? We end up with statx structure defined
in all cases anyways, so we can just use that in the union instead and
we can do just:

LTP_DEFINE_STATX_STRUCT(statx_fallback);

#ifndef HAVE_STRUCT_STATX
LTP_DEFINE_STATX_STRUCT(statx);
#endif

struct ltp_statx {
	union {
		struct statx buf;
		struct statx_fallback fallback;
	};
};

Which will create exactly the same result with less complexity (note
that if there is no system statx definition the statx and statx_fallback
structures are identical).

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list