diff --git a/Makefile b/Makefile index 1f5aed156..4b13a8d42 100644 --- a/Makefile +++ b/Makefile @@ -411,6 +411,8 @@ lint: ! git --no-pager grep -E '^\s*\<(pr_perror|fail)\>.*%m' # Do not use errno with pr_perror or fail ! git --no-pager grep -E '^\s*\<(pr_perror|fail)\>\(".*".*errno' + # No EOL whitespace for C files + ! git --no-pager grep -E '\s+$$' \*.c \*.h .PHONY: lint codecov: SHELL := $(shell which bash) diff --git a/compel/arch/mips/src/lib/cpu.c b/compel/arch/mips/src/lib/cpu.c index 4b071cd16..b9f07a041 100755 --- a/compel/arch/mips/src/lib/cpu.c +++ b/compel/arch/mips/src/lib/cpu.c @@ -17,11 +17,11 @@ void compel_set_cpu_cap(compel_cpuinfo_t *c, unsigned int feature){ } void compel_clear_cpu_cap(compel_cpuinfo_t *c, unsigned int feature){ } int compel_test_cpu_cap(compel_cpuinfo_t *c, unsigned int feature) -{ +{ return 0; } -int compel_cpuid(compel_cpuinfo_t *c){ +int compel_cpuid(compel_cpuinfo_t *c){ return 0; } @@ -31,6 +31,6 @@ bool compel_cpu_has_feature(unsigned int feature) compel_cpuid(&rt_info); rt_info_done = true; } - + return compel_test_cpu_cap(&rt_info, feature); } diff --git a/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h b/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h index 07f3936a9..c711bf346 100755 --- a/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h +++ b/compel/arch/mips/src/lib/include/uapi/asm/infect-types.h @@ -41,8 +41,8 @@ typedef struct { #define MIPS_a0 regs[4] //arguments a0-a3 #define MIPS_t0 regs[8] //temporaries t0-t7 -#define MIPS_v0 regs[2] -#define MIPS_v1 regs[3] +#define MIPS_v0 regs[2] +#define MIPS_v1 regs[3] #define MIPS_sp regs[29] #define MIPS_ra regs[31] @@ -59,10 +59,10 @@ static inline bool user_regs_native(user_regs_struct_t *pregs) #define compel_arch_get_tls_task(ctl, tls) #define compel_arch_get_tls_thread(tctl, tls) -#define REG_RES(regs) ((regs).MIPS_v0) -#define REG_IP(regs) ((regs).cp0_epc) +#define REG_RES(regs) ((regs).MIPS_v0) +#define REG_IP(regs) ((regs).cp0_epc) #define REG_SP(regs) ((regs).MIPS_sp) -#define REG_SYSCALL_NR(regs) ((regs).MIPS_v0) +#define REG_SYSCALL_NR(regs) ((regs).MIPS_v0) //#define __NR(syscall, compat) ((compat) ? __NR32_##syscall : __NR_##syscall) #define __NR(syscall, compat) __NR_##syscall diff --git a/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h b/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h index ed6a959fc..75869c55f 100755 --- a/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h +++ b/compel/arch/mips/src/lib/include/uapi/asm/sigframe.h @@ -36,8 +36,8 @@ struct rt_sigframe { #define RT_SIGFRAME_UC(rt_sigframe) (&rt_sigframe->rs_uc) #define RT_SIGFRAME_UC_SIGMASK(rt_sigframe) ((k_rtsigset_t *)(void *)&rt_sigframe->rs_uc.uc_sigmask) -#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)0x00) -#define RT_SIGFRAME_FPU(rt_sigframe) +#define RT_SIGFRAME_REGIP(rt_sigframe) ((long unsigned int)0x00) +#define RT_SIGFRAME_FPU(rt_sigframe) #define RT_SIGFRAME_HAS_FPU(rt_sigframe) 1 diff --git a/compel/arch/mips/src/lib/infect.c b/compel/arch/mips/src/lib/infect.c index 0c8067f88..29cd511c9 100755 --- a/compel/arch/mips/src/lib/infect.c +++ b/compel/arch/mips/src/lib/infect.c @@ -217,7 +217,7 @@ void *remote_mmap(struct parasite_ctl *ctl, * regs must be inited when calling this function from original context */ void parasite_setup_regs(unsigned long new_ip, void *stack, user_regs_struct_t *regs) -{ +{ regs->cp0_epc = new_ip; if (stack){ /* regs[29] is sp */ @@ -286,7 +286,7 @@ void compel_relocs_apply_mips(void *mem, void *vbase, struct parasite_blob_desc * mips rebasing :load time relocation * parasite.built-in.o and restorer.built-in.o is ELF 64-bit LSB relocatable for mips. * so we have to relocate some type for R_MIPS_26 R_MIPS_HIGHEST R_MIPS_HIGHER R_MIPS_HI16 and R_MIPS_LO16 in there. - * for mips64el .if toload/store data or jump instruct ,need to relocation R_TYPE + * for mips64el .if toload/store data or jump instruct ,need to relocation R_TYPE */ for (i = 0, j = 0; i < nr_relocs; i++) { if (elf_relocs[i].type & COMPEL_TYPE_MIPS_26) { diff --git a/compel/src/lib/handle-elf.c b/compel/src/lib/handle-elf.c index 2d643ce43..9a972bee6 100644 --- a/compel/src/lib/handle-elf.c +++ b/compel/src/lib/handle-elf.c @@ -201,7 +201,7 @@ int __handle_elf(void *mem, size_t size) } #endif } - + /* Calculate section addresses with proper alignment. * Note: some but not all linkers precalculate this information. */ diff --git a/criu/arch/mips/crtools.c b/criu/arch/mips/crtools.c index 329ae8edb..0e40428aa 100755 --- a/criu/arch/mips/crtools.c +++ b/criu/arch/mips/crtools.c @@ -65,14 +65,14 @@ int save_task_regs(void *x, user_regs_struct_t *regs, user_fpregs_struct_t *fpre core->ti_mips->gpregs->r29 = regs->regs[29]; core->ti_mips->gpregs->r30 = regs->regs[30]; core->ti_mips->gpregs->r31 = regs->regs[31]; - + core->ti_mips->gpregs->lo = regs->lo; core->ti_mips->gpregs->hi = regs->hi; core->ti_mips->gpregs->cp0_epc = regs->cp0_epc; core->ti_mips->gpregs->cp0_badvaddr = regs->cp0_badvaddr; core->ti_mips->gpregs->cp0_status = regs->cp0_status; core->ti_mips->gpregs->cp0_cause = regs->cp0_cause; - + core->ti_mips->fpregs->r0 = fpregs->regs[0]; core->ti_mips->fpregs->r1 = fpregs->regs[1]; core->ti_mips->fpregs->r2 = fpregs->regs[2]; @@ -107,7 +107,7 @@ int save_task_regs(void *x, user_regs_struct_t *regs, user_fpregs_struct_t *fpre core->ti_mips->fpregs->r31 = fpregs->regs[31]; core->ti_mips->fpregs->fpu_fcr31 = fpregs->fpu_fcr31; core->ti_mips->fpregs->fpu_id = fpregs->fpu_id; - + return 0; } @@ -142,7 +142,7 @@ int arch_alloc_thread_info(CoreEntry *core) user_mips_fpregs_entry__init(fpregs); ti_mips->fpregs = fpregs; - + return 0; err: return -1; @@ -155,7 +155,7 @@ void arch_free_thread_info(CoreEntry *core) if (core->ti_mips->gpregs) xfree(core->ti_mips->gpregs); - + if (core->ti_mips->fpregs) xfree(core->ti_mips->fpregs); diff --git a/criu/arch/mips/include/asm/restorer.h b/criu/arch/mips/include/asm/restorer.h index d916377f4..4223b3196 100755 --- a/criu/arch/mips/include/asm/restorer.h +++ b/criu/arch/mips/include/asm/restorer.h @@ -7,13 +7,13 @@ #include #include -static inline void restore_tls(tls_t *ptls) { - asm volatile( - "move $4, %0 \n" - "li $2, "__stringify(__NR_set_thread_area)" \n" - "syscall \n" - : - : "r"(*ptls) +static inline void restore_tls(tls_t *ptls) { + asm volatile( + "move $4, %0 \n" + "li $2, "__stringify(__NR_set_thread_area)" \n" + "syscall \n" + : + : "r"(*ptls) : "$4","$2","memory"); } static inline int arch_compat_rt_sigaction(void *stack, int sig, void *act) diff --git a/criu/bpfmap.c b/criu/bpfmap.c index dfa0ab96f..9a133f8bc 100644 --- a/criu/bpfmap.c +++ b/criu/bpfmap.c @@ -72,7 +72,7 @@ int restore_bpfmap_data(int map_fd, uint32_t map_id, struct bpfmap_data_rst **bp .flags = 0, ); - for (map_data = bpf_hash_table[map_id & BPFMAP_DATA_HASH_MASK]; map_data != NULL; + for (map_data = bpf_hash_table[map_id & BPFMAP_DATA_HASH_MASK]; map_data != NULL; map_data = map_data->next) { if (map_data->bde->map_id == map_id) @@ -143,11 +143,11 @@ int dump_one_bpfmap_data(BpfmapFileEntry *bpf, int lfd, const struct fd_parms *p * by userspace if it's dealing with percpu maps. 'count' will contain the * number of keys/values successfully retrieved. Note that 'count' is an * input/output variable and it can contain a lower value after a call. - * + * * If there's no more entries to retrieve, ENOENT will be returned. If error * is ENOENT, count might be > 0 in case it copied some values but there were * no more entries to retrieve. - * + * * Note that if the return code is an error and not -EFAULT, * count indicates the number of elements successfully processed. */ @@ -270,7 +270,7 @@ static int dump_one_bpfmap(int lfd, u32 id, const struct fd_parms *p) } return ret; - + } const struct fdtype_ops bpfmap_dump_ops = { diff --git a/criu/files-reg.c b/criu/files-reg.c index f4f41193b..7d42d435e 100644 --- a/criu/files-reg.c +++ b/criu/files-reg.c @@ -1544,7 +1544,7 @@ static int get_build_id(const int fd, const struct stat *fd_status, ret = get_build_id_32(start_addr, build_id, fd, mapped_size); if (buf[EI_CLASS] == ELFCLASS64) ret = get_build_id_64(start_addr, build_id, fd, mapped_size); - + munmap(start_addr, mapped_size); return ret; } @@ -2065,7 +2065,7 @@ int open_path(struct file_desc *d, tmp = inherit_fd_lookup_id(rfi->rfe->name); if (tmp >= 0) { inh_fd = tmp; - /* + /* * PROC_SELF isn't used, because only service * descriptors can be used here. */ diff --git a/criu/include/bpfmap.h b/criu/include/bpfmap.h index ad065dfc6..2d83f44d2 100644 --- a/criu/include/bpfmap.h +++ b/criu/include/bpfmap.h @@ -30,4 +30,4 @@ extern const struct fdtype_ops bpfmap_dump_ops; extern struct collect_image_info bpfmap_cinfo; extern struct collect_image_info bpfmap_data_cinfo; -#endif /* __CR_BPFMAP_H__ */ +#endif /* __CR_BPFMAP_H__ */ diff --git a/criu/proc_parse.c b/criu/proc_parse.c index 7b0b32e2e..cb47d6fdd 100644 --- a/criu/proc_parse.c +++ b/criu/proc_parse.c @@ -1694,7 +1694,7 @@ static int parse_bpfmap(struct bfd *f, char *str, BpfmapFileEntry *bpf) { /* * Format is: - * + * * uint32_t map_type * uint32_t key_size * uint32_t value_size @@ -1718,7 +1718,7 @@ static int parse_bpfmap(struct bfd *f, char *str, BpfmapFileEntry *bpf) size_t n = sizeof(map) / sizeof(bpfmap_fmt); int i; - + for (i = 0; i < n; i++) { if (sscanf(str, map[i].fmt, map[i].value) != 1) return -1; diff --git a/include/common/arch/mips/asm/linkage.h b/include/common/arch/mips/asm/linkage.h index 8f2426889..87bfcffa8 100644 --- a/include/common/arch/mips/asm/linkage.h +++ b/include/common/arch/mips/asm/linkage.h @@ -6,7 +6,7 @@ #define v0 $2 #define v1 $3 -#define a0 $4 +#define a0 $4 #define a1 $5 #define a2 $6 #define a3 $7 @@ -18,7 +18,7 @@ #define t1 $13 #define t2 $14 #define t3 $15 - + #define s0 $16 /* callee saved */ #define s1 $17 #define s2 $18 diff --git a/include/common/compiler.h b/include/common/compiler.h index 1d431a529..f19292989 100644 --- a/include/common/compiler.h +++ b/include/common/compiler.h @@ -44,7 +44,7 @@ #define __aligned(x) __attribute__((aligned(x))) /* - * Macro to define stack alignment. + * Macro to define stack alignment. * aarch64 requires stack to be aligned to 16 bytes. */ #define __stack_aligned__ __attribute__((aligned(16))) diff --git a/soccr/soccr.h b/soccr/soccr.h index 2c34e169b..e3cfb7955 100644 --- a/soccr/soccr.h +++ b/soccr/soccr.h @@ -96,7 +96,7 @@ struct libsoccr_sk_data { * from the kernel and is required for restore. Not present data * is zeroified by the library. * - * Ideally the caller should carry the whole _data structure between + * Ideally the caller should carry the whole _data structure between * calls, but for optimization purposes it may analyze the flags * field and drop the unneeded bits. */ @@ -213,14 +213,14 @@ union libsoccr_addr *libsoccr_get_addr(struct libsoccr_sk *sk, int self, unsigne /* * Set a pointer on the send/recv queue data. - * If flags have SOCCR_MEM_EXCL, the buffer is stolen by the library and is + * If flags have SOCCR_MEM_EXCL, the buffer is stolen by the library and is * free()-ed after libsoccr_resume(). */ int libsoccr_set_queue_bytes(struct libsoccr_sk *sk, int queue_id, char *bytes, unsigned flags); /* * Set a pointer on the libsoccr_addr for src/dst. - * If flags have SOCCR_MEM_EXCL, the buffer is stolen by the library and is + * If flags have SOCCR_MEM_EXCL, the buffer is stolen by the library and is * fre()-ed after libsoccr_resume(). */ int libsoccr_set_addr(struct libsoccr_sk *sk, int self, union libsoccr_addr *, unsigned flags); diff --git a/test/others/pipes/pipe.c b/test/others/pipes/pipe.c index 33ec60e7f..d693f4b02 100644 --- a/test/others/pipes/pipe.c +++ b/test/others/pipes/pipe.c @@ -10,7 +10,7 @@ * Also note that changing the log file during restore has nothing to do * with the pipe. It's just a nice feature for cases where it's desirable * to have a restored process use a different file then the original one. - * + * * The parent process spawns a child that will write messages to its * parent through a pipe. After a couple of messages, parent invokes * criu to checkpoint the child. Since the child exits after checkpoint, @@ -377,7 +377,7 @@ void chld_handler(int signum) if (pid == child_pid) { if (!qflag) { printf("%s %s exited with status %d\n", who(0), - who(pid), status); + who(pid), status); } /* if child exited successfully, we're done */ if (status == 0) @@ -528,7 +528,7 @@ char *pipe_name(int fd) } /* - * Use two buffers to support two calls to + * Use two buffers to support two calls to * this function in a printf argument list. */ char *who(pid_t pid) diff --git a/test/zdtm/lib/bpfmap_zdtm.c b/test/zdtm/lib/bpfmap_zdtm.c index 35d82ac63..73a79b3f5 100644 --- a/test/zdtm/lib/bpfmap_zdtm.c +++ b/test/zdtm/lib/bpfmap_zdtm.c @@ -123,4 +123,4 @@ int cmp_bpfmap_fdinfo(struct bpfmap_fdinfo_obj *old, struct bpfmap_fdinfo_obj *n return -1; return 0; -} \ No newline at end of file +} diff --git a/test/zdtm/static/bpf_array.c b/test/zdtm/static/bpf_array.c index 6f4827413..ca7796bdf 100644 --- a/test/zdtm/static/bpf_array.c +++ b/test/zdtm/static/bpf_array.c @@ -77,13 +77,13 @@ int main(int argc, char **argv) .flags = 0, ); - keys = mmap(NULL, max_entries * sizeof(int), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - values = mmap(NULL, max_entries * sizeof(int), + keys = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - visited = mmap(NULL, max_entries * sizeof(int), + values = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - + visited = mmap(NULL, max_entries * sizeof(int), + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); + if ((keys == MAP_FAILED) || (values == MAP_FAILED) || (visited == MAP_FAILED)) { pr_perror("Can't mmap()"); goto err; @@ -133,7 +133,7 @@ int main(int argc, char **argv) pr_perror("Could not parse new map fdinfo from procfs"); goto err; } - + if (cmp_bpf_map_info(&old_map_info, &new_map_info)) { pr_err("bpf_map_info mismatch\n"); goto err; @@ -167,7 +167,7 @@ err: munmap(keys, max_entries * sizeof(int)); munmap(values, max_entries * sizeof(int)); munmap(visited, max_entries * sizeof(int)); - + fail(); return 1; -} \ No newline at end of file +} diff --git a/test/zdtm/static/bpf_hash.c b/test/zdtm/static/bpf_hash.c index ad983dcbb..4054140b8 100644 --- a/test/zdtm/static/bpf_hash.c +++ b/test/zdtm/static/bpf_hash.c @@ -34,7 +34,7 @@ static int map_batch_verify(int *visited, uint32_t max_entries, int *keys, int * { memset(visited, 0, max_entries * sizeof(*visited)); for (int i = 0; i < max_entries; i++) { - + if (keys[i] + 1 != values[i]) { pr_err("Key/value checking error: i=%d, key=%d, value=%d\n", i, keys[i], values[i]); return -1; @@ -76,13 +76,13 @@ int main(int argc, char **argv) .flags = 0, ); - keys = mmap(NULL, max_entries * sizeof(int), - PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - values = mmap(NULL, max_entries * sizeof(int), + keys = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - visited = mmap(NULL, max_entries * sizeof(int), + values = mmap(NULL, max_entries * sizeof(int), PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); - + visited = mmap(NULL, max_entries * sizeof(int), + PROT_READ | PROT_WRITE, MAP_SHARED | MAP_ANONYMOUS, 0, 0); + if ((keys == MAP_FAILED) || (values == MAP_FAILED) || (visited == MAP_FAILED)) { pr_perror("Can't mmap()"); goto err; @@ -132,7 +132,7 @@ int main(int argc, char **argv) pr_perror("Could not parse new map fdinfo from procfs"); goto err; } - + if (cmp_bpf_map_info(&old_map_info, &new_map_info)) { pr_err("bpf_map_info mismatch\n"); goto err; @@ -166,7 +166,7 @@ err: munmap(keys, max_entries * sizeof(int)); munmap(values, max_entries * sizeof(int)); munmap(visited, max_entries * sizeof(int)); - + fail(); return 1; -} \ No newline at end of file +} diff --git a/test/zdtm/static/child_subreaper_existing_child.c b/test/zdtm/static/child_subreaper_existing_child.c index 8291aba08..bc0047480 100644 --- a/test/zdtm/static/child_subreaper_existing_child.c +++ b/test/zdtm/static/child_subreaper_existing_child.c @@ -76,18 +76,18 @@ int subreaper(void) pr_perror("Wrong exit status for HELPER: %d", status); return 1; } - + /* Give control to ORPHAN so it can check its parent */ futex_set_and_wake(&sh->fstate, TEST_CHECK); futex_wait_until(&sh->fstate, TEST_EXIT); - + /* Cleanup: reap the ORPHAN */ wait(&status); if (!WIFEXITED(status) || WEXITSTATUS(status)) { pr_perror("Wrong exit status for ORPHAN: %d", status); return 1; } - + return 0; } diff --git a/test/zdtm/static/sockets03.c b/test/zdtm/static/sockets03.c index ce668b7f8..cbc46ca27 100644 --- a/test/zdtm/static/sockets03.c +++ b/test/zdtm/static/sockets03.c @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) int ret; test_init(argc, argv); - + signal(SIGPIPE, SIG_IGN); cwd = get_current_dir_name();