* [LTP] [PATCH 0/2] Minor tst_cgroup improvements
@ 2022-07-26 15:56 Petr Vorel
2022-07-26 15:56 ` [LTP] [PATCH 1/2] tst_cgroup: Fix -Wstringop-truncation warning Petr Vorel
2022-07-26 15:56 ` [LTP] [PATCH 2/2] tst_cgroup: Add macro Petr Vorel
0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2022-07-26 15:56 UTC (permalink / raw)
To: ltp; +Cc: Richard Palethorpe, Luke Nowakowski-Krijger
Petr Vorel (2):
tst_cgroup: Fix -Wstringop-truncation warning
tst_cgroup: Add macro
lib/tst_cgroup.c | 71 +++++++++++++++---------------------------------
1 file changed, 22 insertions(+), 49 deletions(-)
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* [LTP] [PATCH 1/2] tst_cgroup: Fix -Wstringop-truncation warning
2022-07-26 15:56 [LTP] [PATCH 0/2] Minor tst_cgroup improvements Petr Vorel
@ 2022-07-26 15:56 ` Petr Vorel
2022-07-27 4:44 ` Li Wang
2022-07-26 15:56 ` [LTP] [PATCH 2/2] tst_cgroup: Add macro Petr Vorel
1 sibling, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2022-07-26 15:56 UTC (permalink / raw)
To: ltp; +Cc: Richard Palethorpe, Luke Nowakowski-Krijger
Add space for null terminator to fix warning:
tst_cgroup.c:505:17: warning: ‘__builtin_strncpy’ output may be truncated copying 255 bytes from a string of length 255 [-Wstringop-truncation]
505 | strncpy(cgroup_test_dir, test_dir_name, NAME_MAX);
| ^
Fixes: ebebdd735 ("API/cgroup: Implement tst_cg_load_config")
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_cgroup.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index 998b259a6..6f24e0450 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -502,7 +502,7 @@ static void cgroup_parse_config_line(const char *const config_entry)
}
if (!root->test_dir.dir_name && strcmp(test_dir_name, "NULL")) {
- strncpy(cgroup_test_dir, test_dir_name, NAME_MAX);
+ strncpy(cgroup_test_dir, test_dir_name, NAME_MAX + 1);
cgroup_dir_mk(&root->ltp_dir, cgroup_test_dir, &root->test_dir);
root->test_dir.we_created_it = 1;
}
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [LTP] [PATCH 2/2] tst_cgroup: Add macro
2022-07-26 15:56 [LTP] [PATCH 0/2] Minor tst_cgroup improvements Petr Vorel
2022-07-26 15:56 ` [LTP] [PATCH 1/2] tst_cgroup: Fix -Wstringop-truncation warning Petr Vorel
@ 2022-07-26 15:56 ` Petr Vorel
2022-07-27 5:01 ` Li Wang
1 sibling, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2022-07-26 15:56 UTC (permalink / raw)
To: ltp; +Cc: Richard Palethorpe, Luke Nowakowski-Krijger
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
lib/tst_cgroup.c | 69 +++++++++++++++---------------------------------
1 file changed, 21 insertions(+), 48 deletions(-)
diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
index 6f24e0450..1cfd79243 100644
--- a/lib/tst_cgroup.c
+++ b/lib/tst_cgroup.c
@@ -229,11 +229,11 @@ static const struct cgroup_file freezer_ctrl_files[] = {
{ }
};
-static const struct cgroup_file netcls_ctrl_files[] = {
+static const struct cgroup_file net_cls_ctrl_files[] = {
{ }
};
-static const struct cgroup_file netprio_ctrl_files[] = {
+static const struct cgroup_file net_prio_ctrl_files[] = {
{ }
};
@@ -254,54 +254,27 @@ static const struct cgroup_file debug_ctrl_files[] = {
};
#define CTRL_NAME_MAX 31
+#define CGROUP_CTRL_MEMBER(x, y)[y] = { .ctrl_name = #x, .files = \
+ x ## _ctrl_files, .ctrl_indx = y, NULL, 0 }
+
/* Lookup tree for item names. */
static struct cgroup_ctrl controllers[] = {
- [0] = { "cgroup", cgroup_ctrl_files, 0, NULL, 0 },
- [CTRL_MEMORY] = {
- "memory", memory_ctrl_files, CTRL_MEMORY, NULL, 0
- },
- [CTRL_CPU] = {
- "cpu", cpu_ctrl_files, CTRL_CPU, NULL, 0
- },
- [CTRL_CPUSET] = {
- "cpuset", cpuset_ctrl_files, CTRL_CPUSET, NULL, 0
- },
- [CTRL_IO] = {
- "io", io_ctrl_files, CTRL_IO, NULL, 0
- },
- [CTRL_PIDS] = {
- "pids", pids_ctrl_files, CTRL_PIDS, NULL, 0
- },
- [CTRL_HUGETLB] = {
- "hugetlb", hugetlb_ctrl_files, CTRL_HUGETLB, NULL, 0
- },
- [CTRL_CPUACCT] = {
- "cpuacct", cpuacct_ctrl_files, CTRL_CPUACCT, NULL, 0
- },
- [CTRL_DEVICES] = {
- "devices", devices_ctrl_files, CTRL_DEVICES, NULL, 0
- },
- [CTRL_FREEZER] = {
- "freezer", freezer_ctrl_files, CTRL_FREEZER, NULL, 0
- },
- [CTRL_NETCLS] = {
- "net_cls", netcls_ctrl_files, CTRL_NETCLS, NULL, 0
- },
- [CTRL_NETPRIO] = {
- "net_prio", netprio_ctrl_files, CTRL_NETPRIO, NULL, 0
- },
- [CTRL_BLKIO] = {
- "blkio", blkio_ctrl_files, CTRL_BLKIO, NULL, 0
- },
- [CTRL_MISC] = {
- "misc", misc_ctrl_files, CTRL_MISC, NULL, 0
- },
- [CTRL_PERFEVENT] = {
- "perf_event", perf_event_ctrl_files, CTRL_PERFEVENT, NULL, 0
- },
- [CTRL_DEBUG] = {
- "debug", debug_ctrl_files, CTRL_DEBUG, NULL, 0
- },
+ CGROUP_CTRL_MEMBER(cgroup, 0),
+ CGROUP_CTRL_MEMBER(memory, CTRL_MEMORY),
+ CGROUP_CTRL_MEMBER(cpu, CTRL_CPU),
+ CGROUP_CTRL_MEMBER(cpuset, CTRL_CPUSET),
+ CGROUP_CTRL_MEMBER(io, CTRL_IO),
+ CGROUP_CTRL_MEMBER(pids, CTRL_PIDS),
+ CGROUP_CTRL_MEMBER(hugetlb, CTRL_HUGETLB),
+ CGROUP_CTRL_MEMBER(cpuacct, CTRL_CPUACCT),
+ CGROUP_CTRL_MEMBER(devices, CTRL_DEVICES),
+ CGROUP_CTRL_MEMBER(freezer, CTRL_FREEZER),
+ CGROUP_CTRL_MEMBER(net_cls, CTRL_NETCLS),
+ CGROUP_CTRL_MEMBER(net_prio, CTRL_NETPRIO),
+ CGROUP_CTRL_MEMBER(blkio, CTRL_BLKIO),
+ CGROUP_CTRL_MEMBER(misc, CTRL_MISC),
+ CGROUP_CTRL_MEMBER(perf_event, CTRL_PERFEVENT),
+ CGROUP_CTRL_MEMBER(debug, CTRL_DEBUG),
{ }
};
--
2.37.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 1/2] tst_cgroup: Fix -Wstringop-truncation warning
2022-07-26 15:56 ` [LTP] [PATCH 1/2] tst_cgroup: Fix -Wstringop-truncation warning Petr Vorel
@ 2022-07-27 4:44 ` Li Wang
0 siblings, 0 replies; 6+ messages in thread
From: Li Wang @ 2022-07-27 4:44 UTC (permalink / raw)
To: Petr Vorel; +Cc: Richard Palethorpe, LTP List, Luke Nowakowski-Krijger
[-- Attachment #1.1: Type: text/plain, Size: 1315 bytes --]
On Tue, Jul 26, 2022 at 11:56 PM Petr Vorel <pvorel@suse.cz> wrote:
> Add space for null terminator to fix warning:
>
> tst_cgroup.c:505:17: warning: ‘__builtin_strncpy’ output may be truncated
> copying 255 bytes from a string of length 255 [-Wstringop-truncation]
> 505 | strncpy(cgroup_test_dir, test_dir_name, NAME_MAX);
> | ^
>
> Fixes: ebebdd735 ("API/cgroup: Implement tst_cg_load_config")
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>
> ---
> lib/tst_cgroup.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
> index 998b259a6..6f24e0450 100644
> --- a/lib/tst_cgroup.c
> +++ b/lib/tst_cgroup.c
> @@ -502,7 +502,7 @@ static void cgroup_parse_config_line(const char *const
> config_entry)
> }
>
> if (!root->test_dir.dir_name && strcmp(test_dir_name, "NULL")) {
> - strncpy(cgroup_test_dir, test_dir_name, NAME_MAX);
> + strncpy(cgroup_test_dir, test_dir_name, NAME_MAX + 1);
> cgroup_dir_mk(&root->ltp_dir, cgroup_test_dir,
> &root->test_dir);
> root->test_dir.we_created_it = 1;
> }
> --
> 2.37.1
>
>
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 2384 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 2/2] tst_cgroup: Add macro
2022-07-26 15:56 ` [LTP] [PATCH 2/2] tst_cgroup: Add macro Petr Vorel
@ 2022-07-27 5:01 ` Li Wang
2022-07-27 12:48 ` Petr Vorel
0 siblings, 1 reply; 6+ messages in thread
From: Li Wang @ 2022-07-27 5:01 UTC (permalink / raw)
To: Petr Vorel; +Cc: Richard Palethorpe, LTP List, Luke Nowakowski-Krijger
[-- Attachment #1.1: Type: text/plain, Size: 3692 bytes --]
On Tue, Jul 26, 2022 at 11:56 PM Petr Vorel <pvorel@suse.cz> wrote:
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>
Reviewed-by: Li Wang <liwang@redhat.com>
> ---
> lib/tst_cgroup.c | 69 +++++++++++++++---------------------------------
> 1 file changed, 21 insertions(+), 48 deletions(-)
>
> diff --git a/lib/tst_cgroup.c b/lib/tst_cgroup.c
> index 6f24e0450..1cfd79243 100644
> --- a/lib/tst_cgroup.c
> +++ b/lib/tst_cgroup.c
> @@ -229,11 +229,11 @@ static const struct cgroup_file freezer_ctrl_files[]
> = {
> { }
> };
>
> -static const struct cgroup_file netcls_ctrl_files[] = {
> +static const struct cgroup_file net_cls_ctrl_files[] = {
> { }
> };
>
> -static const struct cgroup_file netprio_ctrl_files[] = {
> +static const struct cgroup_file net_prio_ctrl_files[] = {
> { }
> };
>
> @@ -254,54 +254,27 @@ static const struct cgroup_file debug_ctrl_files[] =
> {
> };
>
> #define CTRL_NAME_MAX 31
> +#define CGROUP_CTRL_MEMBER(x, y)[y] = { .ctrl_name = #x, .files = \
> + x ## _ctrl_files, .ctrl_indx = y, NULL, 0 }
> +
> /* Lookup tree for item names. */
> static struct cgroup_ctrl controllers[] = {
> - [0] = { "cgroup", cgroup_ctrl_files, 0, NULL, 0 },
> - [CTRL_MEMORY] = {
> - "memory", memory_ctrl_files, CTRL_MEMORY, NULL, 0
> - },
> - [CTRL_CPU] = {
> - "cpu", cpu_ctrl_files, CTRL_CPU, NULL, 0
> - },
> - [CTRL_CPUSET] = {
> - "cpuset", cpuset_ctrl_files, CTRL_CPUSET, NULL, 0
> - },
> - [CTRL_IO] = {
> - "io", io_ctrl_files, CTRL_IO, NULL, 0
> - },
> - [CTRL_PIDS] = {
> - "pids", pids_ctrl_files, CTRL_PIDS, NULL, 0
> - },
> - [CTRL_HUGETLB] = {
> - "hugetlb", hugetlb_ctrl_files, CTRL_HUGETLB, NULL, 0
> - },
> - [CTRL_CPUACCT] = {
> - "cpuacct", cpuacct_ctrl_files, CTRL_CPUACCT, NULL, 0
> - },
> - [CTRL_DEVICES] = {
> - "devices", devices_ctrl_files, CTRL_DEVICES, NULL, 0
> - },
> - [CTRL_FREEZER] = {
> - "freezer", freezer_ctrl_files, CTRL_FREEZER, NULL, 0
> - },
> - [CTRL_NETCLS] = {
> - "net_cls", netcls_ctrl_files, CTRL_NETCLS, NULL, 0
> - },
> - [CTRL_NETPRIO] = {
> - "net_prio", netprio_ctrl_files, CTRL_NETPRIO, NULL, 0
> - },
> - [CTRL_BLKIO] = {
> - "blkio", blkio_ctrl_files, CTRL_BLKIO, NULL, 0
> - },
> - [CTRL_MISC] = {
> - "misc", misc_ctrl_files, CTRL_MISC, NULL, 0
> - },
> - [CTRL_PERFEVENT] = {
> - "perf_event", perf_event_ctrl_files, CTRL_PERFEVENT, NULL,
> 0
> - },
> - [CTRL_DEBUG] = {
> - "debug", debug_ctrl_files, CTRL_DEBUG, NULL, 0
> - },
> + CGROUP_CTRL_MEMBER(cgroup, 0),
> + CGROUP_CTRL_MEMBER(memory, CTRL_MEMORY),
> + CGROUP_CTRL_MEMBER(cpu, CTRL_CPU),
> + CGROUP_CTRL_MEMBER(cpuset, CTRL_CPUSET),
> + CGROUP_CTRL_MEMBER(io, CTRL_IO),
> + CGROUP_CTRL_MEMBER(pids, CTRL_PIDS),
> + CGROUP_CTRL_MEMBER(hugetlb, CTRL_HUGETLB),
> + CGROUP_CTRL_MEMBER(cpuacct, CTRL_CPUACCT),
> + CGROUP_CTRL_MEMBER(devices, CTRL_DEVICES),
> + CGROUP_CTRL_MEMBER(freezer, CTRL_FREEZER),
> + CGROUP_CTRL_MEMBER(net_cls, CTRL_NETCLS),
> + CGROUP_CTRL_MEMBER(net_prio, CTRL_NETPRIO),
> + CGROUP_CTRL_MEMBER(blkio, CTRL_BLKIO),
> + CGROUP_CTRL_MEMBER(misc, CTRL_MISC),
> + CGROUP_CTRL_MEMBER(perf_event, CTRL_PERFEVENT),
> + CGROUP_CTRL_MEMBER(debug, CTRL_DEBUG),
> { }
> };
>
> --
> 2.37.1
>
>
--
Regards,
Li Wang
[-- Attachment #1.2: Type: text/html, Size: 5421 bytes --]
[-- Attachment #2: Type: text/plain, Size: 60 bytes --]
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [LTP] [PATCH 2/2] tst_cgroup: Add macro
2022-07-27 5:01 ` Li Wang
@ 2022-07-27 12:48 ` Petr Vorel
0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2022-07-27 12:48 UTC (permalink / raw)
To: Li Wang; +Cc: Richard Palethorpe, LTP List, Luke Nowakowski-Krijger
Hi Li, all,
> On Tue, Jul 26, 2022 at 11:56 PM Petr Vorel <pvorel@suse.cz> wrote:
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> Reviewed-by: Li Wang <liwang@redhat.com>
Thanks, patchsed merged!
Kind regards,
Petr
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-07-27 12:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-26 15:56 [LTP] [PATCH 0/2] Minor tst_cgroup improvements Petr Vorel
2022-07-26 15:56 ` [LTP] [PATCH 1/2] tst_cgroup: Fix -Wstringop-truncation warning Petr Vorel
2022-07-27 4:44 ` Li Wang
2022-07-26 15:56 ` [LTP] [PATCH 2/2] tst_cgroup: Add macro Petr Vorel
2022-07-27 5:01 ` Li Wang
2022-07-27 12:48 ` Petr Vorel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.