Skip to content

Commit 909592b

Browse files
ij-intelshuahkh
authored andcommitted
selftests/resctrl: Make some strings passed to resctrlfs functions const
Control group, monitor group and resctrl_val are not mutated and should not be mutated within resctrlfs.c functions. Mark this by using const char * for the arguments. Signed-off-by: Ilpo Järvinen <[email protected]> Tested-by: Babu Moger <[email protected]> Reviewed-by: Reinette Chatre <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent fa1116d commit 909592b

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tools/testing/selftests/resctrl/resctrl.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,10 @@ bool test_resource_feature_check(const struct resctrl_test *test);
141141
char *fgrep(FILE *inf, const char *str);
142142
int taskset_benchmark(pid_t bm_pid, int cpu_no, cpu_set_t *old_affinity);
143143
int taskset_restore(pid_t bm_pid, cpu_set_t *old_affinity);
144-
int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, const char *resource);
145-
int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp,
146-
char *resctrl_val);
144+
int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no,
145+
const char *resource);
146+
int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,
147+
const char *mongrp, const char *resctrl_val);
147148
int perf_event_open(struct perf_event_attr *hw_event, pid_t pid, int cpu,
148149
int group_fd, unsigned long flags);
149150
unsigned char *alloc_buffer(size_t buf_size, int memflush);

tools/testing/selftests/resctrl/resctrlfs.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,8 +534,8 @@ static int write_pid_to_tasks(char *tasks, pid_t pid)
534534
*
535535
* Return: 0 on success, < 0 on error.
536536
*/
537-
int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp,
538-
char *resctrl_val)
537+
int write_bm_pid_to_resctrl(pid_t bm_pid, const char *ctrlgrp,
538+
const char *mongrp, const char *resctrl_val)
539539
{
540540
char controlgroup[128], monitorgroup[512], monitorgroup_p[256];
541541
char tasks[1024];
@@ -593,7 +593,8 @@ int write_bm_pid_to_resctrl(pid_t bm_pid, char *ctrlgrp, char *mongrp,
593593
*
594594
* Return: 0 on success, < 0 on error.
595595
*/
596-
int write_schemata(char *ctrlgrp, char *schemata, int cpu_no, const char *resource)
596+
int write_schemata(const char *ctrlgrp, char *schemata, int cpu_no,
597+
const char *resource)
597598
{
598599
char controlgroup[1024], reason[128], schema[1024] = {};
599600
int domain_id, fd, schema_len, ret = 0;

0 commit comments

Comments
 (0)