Skip to content

Commit

Permalink
amdgpu_plugin: fix lint errors
Browse files Browse the repository at this point in the history
$ make lint
 ...
 # Do not append \n to pr_perror, pr_pwarn or fail
 ! git --no-pager grep -E '^\s*\<(pr_perror|pr_pwarn|fail)\>.*\\n"'
 plugins/amdgpu/amdgpu_plugin.c:		pr_perror("%s(), Can't handle VMAs of input device\n", __func__);

 ! git --no-pager grep -En '^\s*\<pr_(err|warn|msg|info|debug)\>.*);$' | grep -v '\\n'
 plugins/amdgpu/amdgpu_plugin_drm.c:45:		pr_err("Error in getting stat for: %s", path);
 plugins/amdgpu/amdgpu_plugin_util.c:77:		pr_err("Unable to read file (read:%ld buf_len:%ld)", len_read, buf_len);
 plugins/amdgpu/amdgpu_plugin_util.c:89:		pr_err("Unable to write file (wrote:%ld buf_len:%ld)", len_write, buf_len);
 plugins/amdgpu/amdgpu_plugin_util.c:120:		pr_err("%s: Failed to open for %s", path, write ? "write" : "read");
 plugins/amdgpu/amdgpu_plugin_util.c:126:		pr_err("%s: Failed get pointer for %s", path, write ? "write" : "read");
 plugins/amdgpu/amdgpu_plugin_util.c:136:		pr_err("%s:Failed to access file size", path);
 plugins/amdgpu/amdgpu_plugin_util.c:152:		pr_err("Cannot fopen %s", file_path);

 make: *** [Makefile:470: lint] Error 1

Signed-off-by: Radostin Stoyanov <[email protected]>
  • Loading branch information
rst0git authored and avagin committed Feb 12, 2024
1 parent 495081c commit 6d37f9a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugins/amdgpu/amdgpu_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ int amdgpu_plugin_handle_device_vma(int fd, const struct stat *st_buf)
/* Determine if input is a DRM device and therefore is supported */
ret = amdgpu_plugin_drm_handle_device_vma(fd, st_buf);
if (ret)
pr_perror("%s(), Can't handle VMAs of input device\n", __func__);
pr_perror("%s(), Can't handle VMAs of input device", __func__);

return ret;
}
Expand Down
3 changes: 1 addition & 2 deletions plugins/amdgpu/amdgpu_plugin_drm.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int amdgpu_plugin_drm_handle_device_vma(int fd, const struct stat *st)
snprintf(path, sizeof(path), AMDGPU_DRM_DEVICE, DRM_FIRST_RENDER_NODE);
ret = stat(path, &drm);
if (ret == -1) {
pr_err("Error in getting stat for: %s", path);
pr_err("Error in getting stat for: %s\n", path);
return ret;
}

Expand Down Expand Up @@ -98,4 +98,3 @@ int amdgpu_plugin_drm_dump_file(int fd, int id, struct stat *drm)
xfree(buf);
return ret;
}

16 changes: 7 additions & 9 deletions plugins/amdgpu/amdgpu_plugin_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void init_gpu_count(struct tp_system *topo)
return;

/* We add ONE to include checkpointing of KFD device */
dev_file_cnt = 1 + topology_gpu_count(topo);
dev_file_cnt = 1 + topology_gpu_count(topo);
}

int read_fp(FILE *fp, void *buf, const size_t buf_len)
Expand All @@ -74,7 +74,7 @@ int read_fp(FILE *fp, void *buf, const size_t buf_len)

len_read = fread(buf, 1, buf_len, fp);
if (len_read != buf_len) {
pr_err("Unable to read file (read:%ld buf_len:%ld)", len_read, buf_len);
pr_err("Unable to read file (read:%ld buf_len:%ld)\n", len_read, buf_len);
return -EIO;
}
return 0;
Expand All @@ -86,7 +86,7 @@ int write_fp(FILE *fp, const void *buf, const size_t buf_len)

len_write = fwrite(buf, 1, buf_len, fp);
if (len_write != buf_len) {
pr_err("Unable to write file (wrote:%ld buf_len:%ld)", len_write, buf_len);
pr_err("Unable to write file (wrote:%ld buf_len:%ld)\n", len_write, buf_len);
return -EIO;
}
return 0;
Expand Down Expand Up @@ -117,13 +117,13 @@ FILE *open_img_file(char *path, bool write, size_t *size)
fd = openat(criu_get_image_dir(), path, write ? (O_WRONLY | O_CREAT) : O_RDONLY, 0600);

if (fd < 0) {
pr_err("%s: Failed to open for %s", path, write ? "write" : "read");
pr_err("%s: Failed to open for %s\n", path, write ? "write" : "read");
return NULL;
}

fp = fdopen(fd, write ? "w" : "r");
if (!fp) {
pr_err("%s: Failed get pointer for %s", path, write ? "write" : "read");
pr_err("%s: Failed get pointer for %s\n", path, write ? "write" : "read");
return NULL;
}

Expand All @@ -133,7 +133,7 @@ FILE *open_img_file(char *path, bool write, size_t *size)
ret = read_fp(fp, size, sizeof(*size));

if (ret) {
pr_err("%s:Failed to access file size", path);
pr_err("%s:Failed to access file size\n", path);
fclose(fp);
return NULL;
}
Expand All @@ -149,7 +149,7 @@ int read_file(const char *file_path, void *buf, const size_t buf_len)

fp = fopen(file_path, "r");
if (!fp) {
pr_err("Cannot fopen %s", file_path);
pr_err("Cannot fopen %s\n", file_path);
return -errno;
}

Expand Down Expand Up @@ -204,5 +204,3 @@ void print_kfd_bo_stat(int bo_cnt, struct kfd_criu_bo_bucket *bo_list)
}
pr_info("\n");
}


0 comments on commit 6d37f9a

Please sign in to comment.