* [LTP] [PATCH v3] cfs-scheduler: Fixed "make check" errors and warnings in hackbench.c
@ 2026-06-02 9:56 Samir
2026-06-02 11:23 ` [LTP] " linuxtestproject.agent
0 siblings, 1 reply; 2+ messages in thread
From: Samir @ 2026-06-02 9:56 UTC (permalink / raw)
To: ltp; +Cc: Samir
Fixed all make check errors and warnings in hackbench.c to comply with
LTP coding style.
hackbench.c:
- Add SPDX-License-Identifier header.
- Remove obsolete header metadata.
- Keep short description and add trailing period.
- Remove initialization of static variables to 0.
- Convert zero-length array to C99 flexible array.
- Separate assignments from if conditions.
- Fix pointer declaration spacing.
- Add blank line after declarations.
- Fix spacing in macro and struct initialization.
- Remove unnecessary braces for single statement.
- Use Authors block for contributor attribution.
Patch v1: https://lore.kernel.org/ltp/20260407062336.127454-1-samir@linux.ibm.com/
Patch v2: https://lore.kernel.org/ltp/20260412122842.1074017-1-samir@linux.ibm.com/
Addressed review comments from patch v2 -> patch v3:
- Add SPDX-License-Identifier header as requested by Andrea Cervesato.
Signed-off-by: Samir <samir@linux.ibm.com>
---
.../kernel/sched/cfs-scheduler/hackbench.c | 73 +++++++------------
1 file changed, 25 insertions(+), 48 deletions(-)
diff --git a/testcases/kernel/sched/cfs-scheduler/hackbench.c b/testcases/kernel/sched/cfs-scheduler/hackbench.c
index 6f37060aa..c374e6069 100644
--- a/testcases/kernel/sched/cfs-scheduler/hackbench.c
+++ b/testcases/kernel/sched/cfs-scheduler/hackbench.c
@@ -1,49 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/******************************************************************************/
-/* Copyright Rusty Russell, */
-/* Copyright Pierre Peiffer */
-/* Copyright Zhang, Yanmin, */
-/* Copyright Ingo Molnar, */
-/* Copyright Arjan van de Ven, */
/* Copyright (c) International Business Machines Corp., 2008 */
/* */
-/* This program is free software; you can redistribute it and/or modify */
-/* it under the terms of the GNU General Public License as published by */
-/* the Free Software Foundation; either version 2 of the License, or */
-/* (at your option) any later version. */
-/* */
-/* This program is distributed in the hope that it will be useful, */
-/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */
-/* the GNU General Public License for more details. */
-/* */
-/* You should have received a copy of the GNU General Public License */
-/* along with this program; if not, write to the Free Software */
-/* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
+/* Authors: Rusty Russell <rusty@rustcorp.com.au> */
+/* Pierre Peiffer <pierre.peiffer@bull.net> */
+/* Ingo Molnar <mingo@elte.hu> */
+/* Arjan van de Ven <arjan@infradead.org> */
+/* Zhang, Yanmin <yanmin_zhang@linux.intel.com> */
+/* Nathan Lynch <ntl@pobox.com> */
+/* Subrata Modak <subrata@linux.vnet.ibm.com> */
/* */
/******************************************************************************/
/******************************************************************************/
/* */
-/* File: hackbench.c */
-/* */
/* Description: hackbench tests the Linux scheduler. Test groups of 20 */
-/* processes spraying to 20 receivers */
-/* */
-/* Total Tests: 1 */
-/* */
-/* Test Name: hackbench01 and hackbench02 */
-/* */
-/* Test Assertion: */
-/* */
-/* Author(s): Rusty Russell <rusty@rustcorp.com.au>, */
-/* Pierre Peiffer <pierre.peiffer@bull.net>, */
-/* Ingo Molnar <mingo@elte.hu>, */
-/* Arjan van de Ven <arjan@infradead.org>, */
-/* "Zhang, Yanmin" <yanmin_zhang@linux.intel.com>, */
-/* Nathan Lynch <ntl@pobox.com> */
-/* */
-/* History: Included into LTP */
-/* - June 26 2008 - Subrata Modak<subrata@linux.vnet.ibm.com>*/
+/* processes spraying to 20 receivers. */
/* */
/******************************************************************************/
#include <pthread.h>
@@ -59,24 +31,24 @@
#include <sys/poll.h>
#include <limits.h>
-#define SAFE_FREE(p) { if (p) { free(p); (p)=NULL; } }
+#define SAFE_FREE(p) { if (p) { free(p); (p) = NULL; } }
#define DATASIZE 100
static struct sender_context **snd_ctx_tab; /*Table for sender context pointers. */
static struct receiver_context **rev_ctx_tab; /*Table for receiver context pointers. */
-static int gr_num = 0; /*For group calculation */
+static int gr_num; /*For group calculation */
static unsigned int loops = 100;
/*
* 0 means thread mode and others mean process (default)
*/
static unsigned int process_mode = 1;
-static int use_pipes = 0;
+static int use_pipes;
struct sender_context {
unsigned int num_fds;
int ready_out;
int wakefd;
- int out_fds[0];
+ int out_fds[];
};
struct receiver_context {
@@ -115,7 +87,7 @@ static void fdpair(int fds[2])
static void ready(int ready_out, int wakefd)
{
char dummy;
- struct pollfd pollfd = {.fd = wakefd,.events = POLLIN };
+ struct pollfd pollfd = {.fd = wakefd, .events = POLLIN };
/* Tell them we're ready. */
if (write(ready_out, &dummy, 1) != 1)
@@ -210,7 +182,8 @@ pthread_t create_worker(void *ctx, void *(*func) (void *))
barf("pthread_attr_setstacksize");
#endif
- if ((err = pthread_create(&childid, &attr, func, ctx)) != 0) {
+ err = pthread_create(&childid, &attr, func, ctx);
+ if (err != 0) {
fprintf(stderr, "pthread_create failed: %s (%d)\n",
strerror(err), err);
exit(-1);
@@ -235,11 +208,12 @@ void reap_worker(pthread_t id)
}
/* One group of senders and receivers */
-static unsigned int group(pthread_t * pth,
+static unsigned int group(pthread_t *pth,
unsigned int num_fds, int ready_out, int wakefd)
{
unsigned int i;
struct sender_context *snd_ctx = malloc(sizeof(struct sender_context) + num_fds * sizeof(int));
+
if (!snd_ctx)
barf("malloc()");
else
@@ -305,8 +279,11 @@ int main(int argc, char *argv[])
argv++;
}
- if (argc >= 2 && (num_groups = atoi(argv[1])) == 0)
- print_usage_exit();
+ if (argc >= 2) {
+ num_groups = atoi(argv[1]);
+ if (num_groups == 0)
+ print_usage_exit();
+ }
printf("Running with %d*40 (== %d) tasks.\n",
num_groups, num_groups * 40);
@@ -363,9 +340,9 @@ int main(int argc, char *argv[])
/* free the memory */
for (i = 0; i < num_groups; i++) {
- for (j = 0; j < num_fds; j++) {
+ for (j = 0; j < num_fds; j++)
SAFE_FREE(rev_ctx_tab[i * num_fds + j])
- }
+
SAFE_FREE(snd_ctx_tab[i]);
}
SAFE_FREE(pth_tab);
--
2.53.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [LTP] cfs-scheduler: Fixed "make check" errors and warnings in hackbench.c
2026-06-02 9:56 [LTP] [PATCH v3] cfs-scheduler: Fixed "make check" errors and warnings in hackbench.c Samir
@ 2026-06-02 11:23 ` linuxtestproject.agent
0 siblings, 0 replies; 2+ messages in thread
From: linuxtestproject.agent @ 2026-06-02 11:23 UTC (permalink / raw)
To: Samir; +Cc: ltp
Hi Samir,
Some issues need to be addressed before this can be merged.
On Tue, 02 Jun 2026 11:56:56 +0200, Samir <samir@linux.ibm.com> wrote:
> cfs-scheduler: Fixed "make check" errors and warnings in hackbench.c
[COMMIT MESSAGE]
1. Subject line uses past tense. LTP (like the Linux kernel) uses
imperative mood in commit subjects:
cfs-scheduler: Fix 'make check' errors and warnings in hackbench.c
Also, prefer single quotes over double quotes in subjects.
2. The Signed-off-by line contains only a first name. The DCO requires
a real full name (first and last). Please use your full name, e.g.:
Signed-off-by: Samir Lastname <samir@linux.ibm.com>
3. The version-tracking block does not belong in the commit message body.
Remove it before merging:
Patch v1: https://lore.kernel.org/ltp/20260407062336.127454-1-samir@linux.ibm.com/
Patch v2: https://lore.kernel.org/ltp/20260412122842.1074017-1-samir@linux.ibm.com/
Addressed review comments from patch v2 -> patch v3:
- Add SPDX-License-Identifier header as requested by Andrea Cervesato.
This is patch-submission metadata for the cover letter / lore thread,
not part of the permanent history.
4. The bullet-list body ("hackbench.c: - Add SPDX-License-Identifier …")
describes individual line changes that are self-evident from the diff.
Replace it with one or two sentences explaining *why* the changes were
made, e.g.:
Fix all "make check" warnings in hackbench.c to comply with the LTP
coding style guidelines.
[CODE]
> -/* Copyright Rusty Russell, */
> -/* Copyright Pierre Peiffer */
> -/* Copyright Zhang, Yanmin, */
> -/* Copyright Ingo Molnar, */
> -/* Copyright Arjan van de Ven, */
> +/* Authors: Rusty Russell <rusty@rustcorp.com.au> */
> +/* Pierre Peiffer <pierre.peiffer@bull.net> */
> +/* Ingo Molnar <mingo@elte.hu> */
> +/* Arjan van de Ven <arjan@infradead.org> */
> +/* Zhang, Yanmin <yanmin_zhang@linux.intel.com> */
5. The original file listed these five contributors as *copyright holders*
("Copyright Rusty Russell", etc.). The patch silently demotes them to
mere "Authors" entries, stripping the copyright designation entirely.
Copyright notices must be preserved. Either retain them as copyright
lines (adding emails where known) or obtain explicit permission from
each holder to remove the copyright claim.
For example:
/* Copyright Rusty Russell <rusty@rustcorp.com.au> */
/* Copyright Pierre Peiffer <pierre.peiffer@bull.net> */
...
6. The Zhang, Yanmin line in the Authors block has fewer trailing spaces
than the other lines, breaking the column alignment:
/* Zhang, Yanmin <yanmin_zhang@linux.intel.com> */
^-- only 20 spaces
All other entries end with 26 spaces before "*/". Pad to match.
> - for (j = 0; j < num_fds; j++) {
> - SAFE_FREE(rev_ctx_tab[i * num_fds + j])
> - }
> + for (j = 0; j < num_fds; j++)
> + SAFE_FREE(rev_ctx_tab[i * num_fds + j])
7. Every other call to SAFE_FREE in the file is terminated with a
semicolon (e.g. "SAFE_FREE(snd_ctx_tab[i]);"). Although the macro
expands to a compound statement so the semicolon is not strictly
required, omitting it here creates an inconsistency. Add the semicolon:
SAFE_FREE(rev_ctx_tab[i * num_fds + j]);
Verdict: Needs revision
Thanks,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-02 11:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-02 9:56 [LTP] [PATCH v3] cfs-scheduler: Fixed "make check" errors and warnings in hackbench.c Samir
2026-06-02 11:23 ` [LTP] " linuxtestproject.agent
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox