Skip to contentSkip to conversation

Remove unnecessary header includes from {tools/}lib/list_sort.c

PATCH Applied Kuan-Wei Chiu 2 participants 5 messages Oct 12, 2024 – Oct 22, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Remove unnecessary header includes from {tools/}lib/list_sort.c

Remove outdated and unnecessary header includes from lib/list_sort.c and tools/lib/list_sort.c. Additionally, update the hunk exceptions checked by check_headers.sh to reflect these changes.

Regards,
Kuan-Wei

Kuan-Wei Chiu (3):
lib/list_sort: Remove unnecessary header includes tools/lib/list_sort: Remove unnecessary header includes perf tools: Update expected diff for lib/list_sort.c

 lib/list_sort.c                                      |  3 ---
 tools/lib/list_sort.c                                |  2 --
 tools/perf/check-header_ignore_hunks/lib/list_sort.c | 11 ++---------
 3 files changed, 2 insertions(+), 14 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/3 lib/list_sort: Remove unnecessary header includes

After commit 043b3f7b6388 ("lib/list_sort: simplify and remove MAX_LIST_LENGTH_BITS"), list_sort.c no longer uses ARRAY_SIZE() (which required kernel.h and bug.h for BUILD_BUG_ON_ZERO via __must_be_array) or memset() (which required string.h). As these headers are no longer needed, removes them.

There are no changes to the generated code, as confirmed by 'objdump -d'. Additionally, 'wc -l' shows that the size of lib/.list_sort.o.cmd is reduced from 259 lines to 101 lines.

---
 lib/list_sort.c | 3 ---
 1 file changed, 3 deletions(-)
lib/list_sort.c +0 -3
index 0fb59e92ca2d..8d3f623536fe 100644
@@ -1,9 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <linux/kernel.h>
-#include <linux/bug.h>
 #include <linux/compiler.h>
 #include <linux/export.h>
-#include <linux/string.h>
 #include <linux/list_sort.h>
 #include <linux/list.h>
 
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/3 tools/lib/list_sort: Remove unnecessary header includes

In reply to Kuan-Wei Chiu

Since lib/list_sort.c no longer requires ARRAY_SIZE() and memset(), the includes for kernel.h, bug.h, and string.h have been removed. Similarly, tools/lib/list_sort.c also does not need to include these headers, so they have been removed as well.

---
 tools/lib/list_sort.c | 2 --
 1 file changed, 2 deletions(-)
tools/lib/list_sort.c +0 -2
index 69affa251fa7..bb99e493dcd1 100644
@@ -1,8 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
-#include <linux/kernel.h>
 #include <linux/compiler.h>
 #include <linux/export.h>
-#include <linux/string.h>
 #include <linux/list_sort.h>
 #include <linux/list.h>
 
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/3 perf tools: Update expected diff for lib/list_sort.c

In reply to Kuan-Wei Chiu

Since there are no longer any header include differences between lib/list_sort.c and tools/lib/list_sort.c, update the expected diff in check-header_ignore_hunks accordingly.

---
 tools/perf/check-header_ignore_hunks/lib/list_sort.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
tools/perf/check-header_ignore_hunks/lib/list_sort.c +2 -9
index 32d98cb34f80..b7316d29857d 100644
@@ -1,11 +1,4 @@
-@@ -1,5 +1,6 @@
- // SPDX-License-Identifier: GPL-2.0
- #include <linux/kernel.h>
-+#include <linux/bug.h>
- #include <linux/compiler.h>
- #include <linux/export.h>
- #include <linux/string.h>
-@@ -52,6 +53,7 @@
+@@ -50,6 +50,7 @@
  			struct list_head *a, struct list_head *b)
  {
  	struct list_head *tail = head;
@@ -13,7 +6,7 @@
  
  	for (;;) {
  		/* if equal, take 'a' -- important for sort stability */
-@@ -77,6 +79,15 @@
+@@ -75,6 +76,15 @@
  	/* Finish linking remainder of list b on to tail */
  	tail->next = b;
  	do {
Signature · 1 line
2.34.1
maintainer Acked-by on the v1 series
#4 lore raw
In reply to Kuan-Wei Chiu
Quoted 11 lines · Kuan-Wei Chiu

Remove outdated and unnecessary header includes from lib/list_sort.c and tools/lib/list_sort.c. Additionally, update the hunk exceptions checked by check_headers.sh to reflect these changes.

Regards,
Kuan-Wei

Kuan-Wei Chiu (3):
lib/list_sort: Remove unnecessary header includes tools/lib/list_sort: Remove unnecessary header includes perf tools: Update expected diff for lib/list_sort.c

Thanks,
Namhyung

Quoted 9 lines
 lib/list_sort.c                                      |  3 ---
 tools/lib/list_sort.c                                |  2 --
 tools/perf/check-header_ignore_hunks/lib/list_sort.c | 11 ++---------
 3 files changed, 2 insertions(+), 14 deletions(-)
Signature · 1 line
2.34.1