Re: [LTP] [PATCH] hugepage15: Resolve compile time warning generating with -O0

Tarun Sahu
2023-02-13T15:30:06Z

Thanks for reviewing it, Petr.
Sent the re-based version.

Tarun Sahu <tsahu@linux.ibm.com> writes:

> Instead of turning off the optimizaton with -O0 to resolve unwanted
> behaviour of clang with goto statements, this will make use of clang
> pragma to turn off the optimization for just clang compiler. This way,
> gcc won't throw unwanted warning on turning off optimization:
> "warning: _FORTIFY_SOURCE requires compiling with optimization (-O)".
>
> Also, removed redundant header-includes.
>
> Reported-by: Petr Vorel <pvorel@suse.cz>
> Suggested-by: Cyril Hrubis <chrubis@suse.cz>
> Signed-off-by: Tarun Sahu <tsahu@linux.ibm.com>
> ---
> testcases/kernel/mem/hugetlb/hugemmap/Makefile | 1 -
> testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c | 12 ++++--------
> 2 files changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/Makefile b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> index 6f10807cd..2d651b4aa 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/Makefile
> @@ -8,5 +8,4 @@ include $(top_srcdir)/include/mk/testcases.mk
> include $(abs_srcdir)/../Makefile.inc
> include $(top_srcdir)/include/mk/generic_leaf_target.mk
>
> -hugemmap15: CFLAGS+=-O0
> hugemmap06: CFLAGS+=-pthread
> diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
> index 4730d8d18..aae234135 100644
> --- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
> +++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap15.c
> @@ -18,17 +18,13 @@
> * remap, or because the icache happens to get flushed in the interim.
> */
>
> +#if defined(__clang__)
> + #pragma clang optimize off
> +#endif
> +
> #define _GNU_SOURCE
> -#include <stdio.h>
> -#include <stdlib.h>
> #include <setjmp.h>
> -#include <unistd.h>
> #include <signal.h>
> -#include <sys/mman.h>
> -#include <ucontext.h>
> -#include <limits.h>
> -#include <sys/param.h>
> -#include <sys/types.h>
>
> #include "hugetlb.h"
>
> --
> 2.31.1
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp