mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-30 05:48:05 +00:00
style: Enforce kernel style -Wdeclaration-after-statement
Include warnings that the kernel uses during compilation: -Wdeclaration-after-statement: enforces having variables declared at the top of scopes Signed-off-by: Nicolas Viennot <Nicolas.Viennot@twosigma.com> [Generated a commit message from the pull request] Signed-off-by: Dmitry Safonov <dima@arista.com>
This commit is contained in:
parent
79559bef92
commit
8bb3c17a0f
2
Makefile
2
Makefile
@ -100,7 +100,7 @@ export PROTOUFIX DEFINES
|
||||
DEFINES += -D_FILE_OFFSET_BITS=64
|
||||
DEFINES += -D_GNU_SOURCE
|
||||
|
||||
WARNINGS := -Wall -Wformat-security
|
||||
WARNINGS := -Wall -Wformat-security -Wdeclaration-after-statement
|
||||
|
||||
CFLAGS-GCOV := --coverage -fno-exceptions -fno-inline -fprofile-update=atomic
|
||||
export CFLAGS-GCOV
|
||||
|
@ -2817,6 +2817,9 @@ int macvlan_ext_add(struct external *ext)
|
||||
static int prep_ns_sockets(struct ns_id *ns, bool for_dump)
|
||||
{
|
||||
int nsret = -1, ret;
|
||||
#ifdef CONFIG_HAS_SELINUX
|
||||
security_context_t ctx;
|
||||
#endif
|
||||
|
||||
if (ns->type != NS_CRIU) {
|
||||
pr_info("Switching to %d's net for collecting sockets\n", ns->ns_pid);
|
||||
@ -2854,7 +2857,6 @@ static int prep_ns_sockets(struct ns_id *ns, bool for_dump)
|
||||
* policies installed. For Fedora based systems this is part
|
||||
* of the container-selinux package.
|
||||
*/
|
||||
security_context_t ctx;
|
||||
|
||||
/*
|
||||
* This assumes that all processes CRIU wants to dump are labeled
|
||||
@ -3294,6 +3296,7 @@ int kerndat_link_nsid()
|
||||
}
|
||||
|
||||
if (pid == 0) {
|
||||
bool has_link_nsid;
|
||||
NetDeviceEntry nde = NET_DEVICE_ENTRY__INIT;
|
||||
struct net_link link = {
|
||||
.created = false,
|
||||
@ -3336,7 +3339,7 @@ int kerndat_link_nsid()
|
||||
exit(1);
|
||||
}
|
||||
|
||||
bool has_link_nsid = false;
|
||||
has_link_nsid = false;
|
||||
if (check_link_nsid(sk, &has_link_nsid))
|
||||
exit(1);
|
||||
|
||||
|
@ -624,17 +624,17 @@ unsigned long handle_faulty_iov(int pid, struct iovec* riov,
|
||||
unsigned long* aux_len,
|
||||
unsigned long partial_read_bytes)
|
||||
{
|
||||
struct iovec dummy;
|
||||
ssize_t bytes_read;
|
||||
unsigned long offset = 0;
|
||||
unsigned long final_read_cnt = 0;
|
||||
|
||||
/* Handling Case 2*/
|
||||
if (riov[faulty_index].iov_len == PAGE_SIZE) {
|
||||
cnt_sub(CNT_PAGES_WRITTEN, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct iovec dummy;
|
||||
ssize_t bytes_read;
|
||||
unsigned long offset = 0;
|
||||
unsigned long final_read_cnt = 0;
|
||||
|
||||
/* Handling Case 3-Part 3.2*/
|
||||
offset = (partial_read_bytes)? partial_read_bytes : PAGE_SIZE;
|
||||
|
||||
|
@ -243,10 +243,11 @@ static void parse_elf_symbols(uintptr_t mem, size_t size, Phdr_t *load,
|
||||
k = elf_hash((const unsigned char *)symbol);
|
||||
|
||||
for (j = bucket[k % nbucket]; j < nchain && j != STN_UNDEF; j = chain[j]) {
|
||||
addr = mem + dyn_symtab->d_un.d_ptr - load->p_vaddr;
|
||||
Sym_t *sym;
|
||||
char *name;
|
||||
|
||||
addr = mem + dyn_symtab->d_un.d_ptr - load->p_vaddr;
|
||||
|
||||
addr += sizeof(Sym_t)*j;
|
||||
if (__ptr_struct_oob(addr, sizeof(Sym_t), mem, size))
|
||||
continue;
|
||||
|
@ -38,6 +38,7 @@ ifeq ($(origin CC), default)
|
||||
CC := $(CROSS_COMPILE)$(HOSTCC)
|
||||
endif
|
||||
CFLAGS += -g -O2 -Wall -Werror -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0
|
||||
CFLAGS += -Wdeclaration-after-statement
|
||||
CFLAGS += $(USERCFLAGS)
|
||||
CFLAGS += -D_GNU_SOURCE
|
||||
CPPFLAGS += -iquote $(LIBDIR)/arch/$(ARCH)/include
|
||||
|
@ -12,13 +12,14 @@ const char *test_author = "Alexander Karatshov <alekskartashov@parallels.com>";
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
int a, b, c, y1, y2;
|
||||
|
||||
srand(time(0));
|
||||
|
||||
int a = rand() % 100;
|
||||
int b = rand() % 100;
|
||||
int c = rand() % 100;
|
||||
int y1 = a + b*c;
|
||||
int y2;
|
||||
a = rand() % 100;
|
||||
b = rand() % 100;
|
||||
c = rand() % 100;
|
||||
y1 = a + b*c;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
|
@ -8,10 +8,11 @@ const char *test_author = "Michał Cłapiński <mclapinski@google.com>";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int cs_before = 1, cs_after, ret;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
int cs_before = 1;
|
||||
int ret = prctl(PR_SET_CHILD_SUBREAPER, cs_before, 0, 0, 0);
|
||||
ret = prctl(PR_SET_CHILD_SUBREAPER, cs_before, 0, 0, 0);
|
||||
if (ret) {
|
||||
pr_perror("Can't set child subreaper attribute, err = %d", ret);
|
||||
exit(1);
|
||||
@ -20,7 +21,6 @@ int main(int argc, char **argv)
|
||||
test_daemon();
|
||||
test_waitsig();
|
||||
|
||||
int cs_after;
|
||||
ret = prctl(PR_GET_CHILD_SUBREAPER, (unsigned long)&cs_after, 0, 0, 0);
|
||||
if (ret) {
|
||||
pr_perror("Can't get child subreaper attribute, err = %d", ret);
|
||||
|
@ -31,6 +31,7 @@ char test_files[2][128] = {TDIR"/zdtm-test", TDIR"/zdtm-test1",};
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
FILE *configfile;
|
||||
char buf[BUFF_SIZE];
|
||||
int fd, wd, i;
|
||||
|
||||
@ -56,7 +57,7 @@ int main (int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
FILE *configfile = fopen(CONFIG_PATH, "w");
|
||||
configfile = fopen(CONFIG_PATH, "w");
|
||||
if (configfile == NULL) {
|
||||
pr_perror("Unable to create configuration file %s", CONFIG_PATH);
|
||||
goto err;
|
||||
|
@ -125,9 +125,10 @@ int main (int argc, char *argv[])
|
||||
{
|
||||
pid_t pid;
|
||||
task_waiter_t t;
|
||||
task_waiter_init(&t);
|
||||
static char buf[PATH_MAX];
|
||||
|
||||
task_waiter_init(&t);
|
||||
|
||||
if (mount(NULL, "/", NULL, MS_PRIVATE | MS_REC, NULL)) {
|
||||
pr_perror("Unable to remount /");
|
||||
return 1;
|
||||
|
@ -16,9 +16,10 @@ const char *test_author = "Cyrill Gorcunov <gorcunov@openvz.org>";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_init(argc, argv);
|
||||
unsigned char *mem;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
test_msg("Alloc huge VMA\n");
|
||||
mem = (void *)mmap(NULL, (10L << 30), PROT_READ | PROT_WRITE,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
|
@ -20,10 +20,11 @@ TEST_OPTION(dirname, string, "directory name", 1);
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char *loop, fd, dfd, fd2;
|
||||
test_init(argc, argv);
|
||||
struct stat st, stp, st2;
|
||||
char dname[PATH_MAX], dname2[PATH_MAX];
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
snprintf(dname, sizeof(dname), "%s/test_dir", dirname);
|
||||
snprintf(dname2, sizeof(dname2), "%s/test_dir2", dirname);
|
||||
|
||||
|
@ -230,8 +230,8 @@ int main(int argc, char **argv)
|
||||
|
||||
|
||||
if (pid > 0) {
|
||||
kill(pid, SIGTERM);
|
||||
int status = 1;
|
||||
kill(pid, SIGTERM);
|
||||
wait(&status);
|
||||
if (WIFEXITED(status)) {
|
||||
if (WEXITSTATUS(status) == AWK_OK)
|
||||
|
@ -119,8 +119,8 @@ int main(int argc, char **argv)
|
||||
test_waitsig();
|
||||
|
||||
if (pid > 0) {
|
||||
kill(pid, SIGTERM);
|
||||
int status = 1;
|
||||
kill(pid, SIGTERM);
|
||||
wait(&status);
|
||||
if (WIFEXITED(status)) {
|
||||
if (WEXITSTATUS(status) == AWK_OK)
|
||||
|
@ -292,8 +292,8 @@ int main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (pid > 0) {
|
||||
kill(pid, SIGTERM);
|
||||
int status = 1;
|
||||
kill(pid, SIGTERM);
|
||||
wait(&status);
|
||||
if (status)
|
||||
return 1;
|
||||
|
@ -40,12 +40,12 @@ int main(int argc, char **argv)
|
||||
while(1)
|
||||
sleep(10);
|
||||
} else {
|
||||
test_msg("child is %d\n", pid);
|
||||
|
||||
int fd, ret;
|
||||
char path[PATH_MAX];
|
||||
pid_t result;
|
||||
|
||||
test_msg("child is %d\n", pid);
|
||||
|
||||
sprintf(path, proc_path, pid);
|
||||
fd = open(path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
|
@ -133,6 +133,7 @@ int check_sockcreate_empty()
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int sk;
|
||||
char ctx[1024];
|
||||
test_init(argc, argv);
|
||||
|
||||
@ -159,7 +160,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
/* Open our test socket */
|
||||
int sk = socket(AF_INET, SOCK_STREAM, 0);
|
||||
sk = socket(AF_INET, SOCK_STREAM, 0);
|
||||
memset(ctx, 0, 1024);
|
||||
/* Read out the socket label */
|
||||
if (fgetxattr(sk, "security.selinux", ctx, 1024) == -1) {
|
||||
|
@ -61,17 +61,17 @@ void thread_sigaction(int signo, siginfo_t *info, void *context)
|
||||
|
||||
static void *thread_func(void *arg)
|
||||
{
|
||||
struct sigaction sa = {
|
||||
.sa_sigaction = thread_sigaction,
|
||||
.sa_flags = SA_RESTART | SA_ONSTACK,
|
||||
};
|
||||
|
||||
sas_state[SAS_THRD_OLD] = (stack_t) {
|
||||
.ss_size = sizeof(stack_thread) - 8,
|
||||
.ss_sp = stack_thread,
|
||||
.ss_flags = 0,
|
||||
};
|
||||
|
||||
struct sigaction sa = {
|
||||
.sa_sigaction = thread_sigaction,
|
||||
.sa_flags = SA_RESTART | SA_ONSTACK,
|
||||
};
|
||||
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
if (sigaction(SIGUSR2, &sa, NULL)) {
|
||||
@ -103,17 +103,17 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
pthread_t thread;
|
||||
|
||||
struct sigaction sa = {
|
||||
.sa_sigaction = leader_sigaction,
|
||||
.sa_flags = SA_RESTART | SA_ONSTACK,
|
||||
};
|
||||
|
||||
sas_state[SAS_MAIN_OLD] = (stack_t) {
|
||||
.ss_size = sizeof(stack_main) - 8,
|
||||
.ss_sp = stack_main,
|
||||
.ss_flags = 0,
|
||||
};
|
||||
|
||||
struct sigaction sa = {
|
||||
.sa_sigaction = leader_sigaction,
|
||||
.sa_flags = SA_RESTART | SA_ONSTACK,
|
||||
};
|
||||
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
test_init(argc, argv);
|
||||
|
@ -37,7 +37,7 @@ int main(int argc, char **argv)
|
||||
{
|
||||
int fd, fd_s, sock, sk;
|
||||
union sockaddr_inet addr;
|
||||
char cmd[4096];
|
||||
char c, cmd[4096];
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
@ -113,7 +113,7 @@ int main(int argc, char **argv)
|
||||
|
||||
fcntl(sock, F_SETFL, 0);
|
||||
|
||||
char c = 5;
|
||||
c = 5;
|
||||
if (write(sock, &c, 1) != 1) {
|
||||
fail("Unable to send data");
|
||||
return 1;
|
||||
|
@ -30,10 +30,11 @@ void create_check_pattern(char *buf, size_t count, unsigned char seed)
|
||||
|
||||
struct fiemap *read_fiemap(int fd)
|
||||
{
|
||||
test_msg("Obtaining fiemap for fd %d\n", fd);
|
||||
struct fiemap *fiemap, *tmp;
|
||||
int extents_size;
|
||||
|
||||
test_msg("Obtaining fiemap for fd %d\n", fd);
|
||||
|
||||
fiemap = malloc(sizeof(struct fiemap));
|
||||
if (fiemap == NULL) {
|
||||
pr_perror("Cannot allocate fiemap");
|
||||
|
@ -17,7 +17,6 @@ const char *test_author = "Andrew Vagin <avagin@parallels.com>";
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_init(argc, argv);
|
||||
char buf[BUF_SIZE];
|
||||
int fd;
|
||||
struct aiocb aiocb;
|
||||
@ -25,6 +24,8 @@ int main(int argc, char **argv)
|
||||
char tmpfname[256]="/tmp/file_aio.XXXXXX";
|
||||
int ret;
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
fd = mkstemp(tmpfname);
|
||||
if (fd == -1) {
|
||||
pr_perror("mkstemp() failed");
|
||||
|
@ -158,9 +158,11 @@ static void chew_some_file(int num)
|
||||
rv = SEEK_FAILED;
|
||||
goto out_exit;
|
||||
case 1:
|
||||
rv = FILE_CORRUPTED;
|
||||
{
|
||||
int fd1;
|
||||
char str[PATH_MAX];
|
||||
|
||||
rv = FILE_CORRUPTED;
|
||||
// create standard file
|
||||
sprintf(str, "standard_%s.%d", filename, num);
|
||||
fd1 = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0666);
|
||||
@ -168,6 +170,7 @@ static void chew_some_file(int num)
|
||||
pr_perror("can't write %s", str);
|
||||
close(fd1);
|
||||
goto out_exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
rv = SUCCESS;
|
||||
|
@ -348,6 +348,7 @@ static int proc11_func(task_waiter_t *setup_waiter)
|
||||
void *mem3_old = mem3;
|
||||
size_t mem3_size_old = mem3_size;
|
||||
uint32_t crc_epoch = 0;
|
||||
uint8_t *proc1_mem3;
|
||||
|
||||
pstree->proc11 = getpid();
|
||||
xmunmap(mem3, MEM3_START_CUT);
|
||||
@ -382,7 +383,7 @@ static int proc11_func(task_waiter_t *setup_waiter)
|
||||
chk_proc_mem_eq(pstree->proc11, mem3, mem3_size,
|
||||
pstree->proc112, mem3, mem3_size + MEM3_END_CUT);
|
||||
|
||||
uint8_t *proc1_mem3 = mmap_proc_mem(pstree->proc1,
|
||||
proc1_mem3 = mmap_proc_mem(pstree->proc1,
|
||||
(unsigned long)mem3_old, mem3_size_old);
|
||||
check_mem_eq(mem3, mem3_size, proc1_mem3 + MEM3_START_CUT, mem3_size);
|
||||
xmunmap(proc1_mem3, mem3_size_old);
|
||||
@ -489,16 +490,17 @@ static void sigchld_hand(int signo, siginfo_t *info, void *ucontext)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
test_init(argc, argv);
|
||||
|
||||
pstree = (struct pstree *)mmap_ashmem(PAGE_SIZE);
|
||||
test_sync = (struct test_sync *)mmap_ashmem(sizeof(*test_sync));
|
||||
|
||||
struct sigaction sa = {
|
||||
.sa_sigaction = sigchld_hand,
|
||||
.sa_flags = SA_RESTART | SA_SIGINFO | SA_NOCLDSTOP
|
||||
};
|
||||
sigemptyset(&sa.sa_mask);
|
||||
|
||||
test_init(argc, argv);
|
||||
|
||||
pstree = (struct pstree *)mmap_ashmem(PAGE_SIZE);
|
||||
test_sync = (struct test_sync *)mmap_ashmem(sizeof(*test_sync));
|
||||
|
||||
if (sigaction(SIGCHLD, &sa, NULL)) {
|
||||
pr_perror("SIGCHLD handler setup");
|
||||
exit(1);
|
||||
|
Loading…
x
Reference in New Issue
Block a user