mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-22 09:58:09 +00:00
criu: end pr_(err|warn|msg|info|debug) with \n
Unlike pr_perror, pr_err and other macros do not append \n to the message being printed, so the caller needs to take care of it. Sometimes it was not done, so let's add this manually. To make sure it won't happen again, add a line to Makefile under the linter target to check for such missing \n. NOTE this check is only done for part of such cases (where the pr_* statement fits in one line and there's no comment after), but it's better than nothing. Add comments after pr_msg and pr_info statements where we deliberately don't add \n, so that the above check ignores them. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
96b7178bab
commit
f10425e053
2
Makefile
2
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'
|
||||
# End pr_(err|warn|msg|info|debug) with \n
|
||||
! git --no-pager grep -En '^\s*\<pr_(err|warn|msg|info|debug)\>.*);$$' | grep -v '\\n'
|
||||
# No EOL whitespace for C files
|
||||
! git --no-pager grep -E '\s+$$' \*.c \*.h
|
||||
.PHONY: lint
|
||||
|
@ -187,7 +187,7 @@ static int next_config(char **argv, char ***_argv, bool no_default_config,
|
||||
break;
|
||||
home_dir = getenv("HOME");
|
||||
if (!home_dir) {
|
||||
pr_info("Unable to get $HOME directory, local configuration file will not be used.");
|
||||
pr_info("Unable to get $HOME directory, local configuration file will not be used.\n");
|
||||
} else {
|
||||
snprintf(local_filepath, PATH_MAX, "%s/%s%s",
|
||||
home_dir, USER_CONFIG_DIR, DEFAULT_CONFIG_FILENAME);
|
||||
@ -755,7 +755,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
|
||||
break;
|
||||
case 1065:
|
||||
if (!add_fsname_auto(optarg)) {
|
||||
pr_err("Failed while parsing --enable-fs option: %s", optarg);
|
||||
pr_err("Failed while parsing --enable-fs option: %s\n", optarg);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
@ -767,7 +767,7 @@ int parse_options(int argc, char **argv, bool *usage_error,
|
||||
break;
|
||||
case 1070:
|
||||
if (irmap_scan_path_add(optarg)) {
|
||||
pr_err("Failed while parsing --irmap-scan-path option: %s", optarg);
|
||||
pr_err("Failed while parsing --irmap-scan-path option: %s\n", optarg);
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
|
@ -1528,10 +1528,10 @@ void pr_check_features(const char *offset, const char *sep, int width)
|
||||
pr_msg("\n%s", offset);
|
||||
pos = offset_len;
|
||||
}
|
||||
pr_msg("%s", fl->name);
|
||||
pr_msg("%s", fl->name); // no \n
|
||||
pos += len;
|
||||
if ((fl + 1)->name) { // not the last item
|
||||
pr_msg("%s", sep);
|
||||
pr_msg("%s", sep); // no \n
|
||||
pos += sep_len;
|
||||
}
|
||||
}
|
||||
|
@ -1462,7 +1462,7 @@ static inline int fork_with_pid(struct pstree_item *item)
|
||||
ret = set_next_pid((void *)&pid);
|
||||
}
|
||||
if (ret != 0) {
|
||||
pr_err("Setting PID failed");
|
||||
pr_err("Setting PID failed\n");
|
||||
goto err_unlock;
|
||||
}
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ int main(int argc, char *argv[], char *envp[])
|
||||
if (strcmp(argv[optind], "service")) {
|
||||
ret = open_image_dir(opts.imgs_dir, image_dir_mode(argv, optind));
|
||||
if (ret < 0) {
|
||||
pr_err("Couldn't open image dir: %s", opts.imgs_dir);
|
||||
pr_err("Couldn't open image dir %s\n", opts.imgs_dir);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@ -1536,7 +1536,7 @@ static int get_build_id(const int fd, const struct stat *fd_status,
|
||||
mapped_size = min_t(size_t, fd_status->st_size, BUILD_ID_MAP_SIZE);
|
||||
start_addr = mmap(0, mapped_size, PROT_READ, MAP_PRIVATE | MAP_FILE, fd, 0);
|
||||
if (start_addr == MAP_FAILED) {
|
||||
pr_warn("Couldn't mmap file with fd %d", fd);
|
||||
pr_warn("Couldn't mmap file with fd %d\n", fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ static void fill_ipc_desc(int id, IpcDescEntry *desc, const struct ipc_perm *ipc
|
||||
static void pr_ipc_sem_array(int nr, u16 *values)
|
||||
{
|
||||
while (nr--)
|
||||
pr_info(" %-5d", values[nr]);
|
||||
pr_info(" %-5d", values[nr]); // no \n
|
||||
pr_info("\n");
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ static int check_pagemap(void)
|
||||
fd = __open_proc(PROC_SELF, EPERM, O_RDONLY, "pagemap");
|
||||
if (fd < 0) {
|
||||
if (errno == EPERM) {
|
||||
pr_info("Pagemap disabled");
|
||||
pr_info("Pagemap disabled\n");
|
||||
kdat.pmap = PM_DISABLED;
|
||||
return 0;
|
||||
}
|
||||
|
@ -2428,7 +2428,7 @@ static inline int restore_nftables(int pid)
|
||||
return -1;
|
||||
if (empty_image(img)) {
|
||||
/* Backward compatibility */
|
||||
pr_info("Skipping nft restore, no image");
|
||||
pr_info("Skipping nft restore, no image\n");
|
||||
ret = 0;
|
||||
goto image_close_out;
|
||||
}
|
||||
|
@ -665,7 +665,7 @@ static int unix_resolve_name(int lfd, uint32_t id, struct unix_sk_desc *d,
|
||||
|
||||
fd = ioctl(lfd, SIOCUNIXFILE);
|
||||
if (fd < 0) {
|
||||
pr_warn("Unable to get a socket file descriptor with SIOCUNIXFILE ioctl.");
|
||||
pr_warn("Unable to get a socket file descriptor with SIOCUNIXFILE ioctl: %m\n");
|
||||
goto fallback;
|
||||
}
|
||||
|
||||
@ -716,7 +716,7 @@ out:
|
||||
return ret;
|
||||
|
||||
fallback:
|
||||
pr_warn("Trying to resolve unix socket with obsolete method");
|
||||
pr_warn("Trying to resolve unix socket with obsolete method\n");
|
||||
ret = unix_resolve_name_old(lfd, id, d, ue, p);
|
||||
if (ret < 0)
|
||||
pr_err("Unable to resolve unix socket name with obsolete method. Try a linux kernel newer than 4.10\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user