criu: introduce clang-format to format source code

This is another attempt to introduce a tool to format CRIU's source
code. This time it is based on clang-format.

The .clang-format file is taken from the linux kernel git tree (5.13).

I removed all comments from lines which state that it requires at least
clang-format 4 or 5. For this resulting file at least clang-format 11
is required. See scripts/fetch-clang-format.sh for all the changes
done to the Linux kernel .clang-format file.

Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:
Adrian Reber 2021-06-26 17:19:43 +00:00 committed by Andrei Vagin
parent cc2317ea48
commit 1e26f170ca
3 changed files with 589 additions and 1 deletions

View file

@ -202,7 +202,7 @@ criu-deps += include/common/asm
#
# Configure variables.
export CONFIG_HEADER := include/common/config.h
ifeq ($(filter tags etags cscope clean mrproper,$(MAKECMDGOALS)),)
ifeq ($(filter tags etags cscope clean lint indent fetch-clang-format help mrproper,$(MAKECMDGOALS)),)
include Makefile.config
else
# To clean all files, enable make/build options here
@ -398,6 +398,8 @@ help:
@echo ' test - Run zdtm test-suite'
@echo ' gcov - Make code coverage report'
@echo ' unittest - Run unit tests'
@echo ' lint - Run code linters'
@echo ' indent - Indent C code'
.PHONY: help
lint:
@ -429,6 +431,14 @@ codecov:
bash <(curl -s https://codecov.io/bash)
.PHONY: codecov
fetch-clang-format: .FORCE
$(E) ".clang-format"
$(Q) scripts/fetch-clang-format.sh
indent:
find . -name '*.[ch]' -type f -print0 | xargs --null --max-args 128 --max-procs 4 clang-format -i
.PHONY: indent
include Makefile.install
.DEFAULT_GOAL := all