From fb1223e91bb49d3a91b869d4c347e86566481ee5 Mon Sep 17 00:00:00 2001 From: Pasha Date: Wed, 19 Jul 2023 08:05:25 +0000 Subject: fix sizeof of known value --- lib/cgroup_file_handle.c | 3 +-- src/main.c | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/cgroup_file_handle.c b/lib/cgroup_file_handle.c index 7097b10..184e02d 100644 --- a/lib/cgroup_file_handle.c +++ b/lib/cgroup_file_handle.c @@ -74,8 +74,7 @@ int get_cgroup_file_handle(const char *pathname, char *cgroupfhp) { goto clean_exit; } - memcpy(cgroupfhp, fhp->f_handle, - sizeof(unsigned char) * CGROUP_FILE_HANDLE_BYTES); + memcpy(cgroupfhp, fhp->f_handle, CGROUP_FILE_HANDLE_BYTES); ret = 1; clean_exit: diff --git a/src/main.c b/src/main.c index bc10112..64b1ba3 100644 --- a/src/main.c +++ b/src/main.c @@ -28,8 +28,7 @@ enum output_pref { DEFAULT = 0, PATH = 1, CGROUPID = 2 }; static inline void print_cgroup_file_handle(const char *pathname, enum output_pref output_type) { - unsigned char *cgroupfhp = - (unsigned char *)malloc(sizeof(unsigned char) * CGROUP_FILE_HANDLE_BYTES); + unsigned char *cgroupfhp = (unsigned char *)malloc(CGROUP_FILE_HANDLE_BYTES); if (!cgroupfhp) { fprintf(stderr, "Cannot allocate memory for cgroup file handle\n"); return; @@ -116,8 +115,8 @@ static int display_controller_data(char *ctr_name, char *ctr_path, base_path[1] = '\0'; depth = 0; - ret = - cgroup_walk_tree_begin(ctr_name, base_path, depth, &handle, &info, &base_level); + ret = cgroup_walk_tree_begin(ctr_name, base_path, depth, &handle, &info, + &base_level); if (ret != 0) return ret; @@ -136,7 +135,8 @@ static int display_controller_data(char *ctr_name, char *ctr_path, return 1; } - while ((ret = cgroup_walk_tree_next(depth, &handle, &info, base_level)) == 0) { + while ((ret = cgroup_walk_tree_next(depth, &handle, &info, base_level)) == + 0) { if (compare_cgroup_search_name(info.path, cgroup_search_name)) { print_info(&info, len, ctr_path, output_type); break; -- cgit v1.2.1