Thread (19 messages) 19 messages, 3 authors, 2018-06-28

[PATCH 1/5] kernel/jump_label: abstract jump_entry member accessors

From: peterz@infradead.org (Peter Zijlstra)
Date: 2018-06-28 08:40:21
Also in: lkml

On Wed, Jun 27, 2018 at 06:06:00PM +0200, Ard Biesheuvel wrote:
quoted hunk ↗ jump to hunk
diff --git a/kernel/jump_label.c b/kernel/jump_label.c
index 01ebdf1f9f40..c3524c9b3004 100644
--- a/kernel/jump_label.c
+++ b/kernel/jump_label.c
@@ -38,10 +38,12 @@ static int jump_label_cmp(const void *a, const void *b)
 	const struct jump_entry *jea = a;
 	const struct jump_entry *jeb = b;
 
-	if (jea->key < jeb->key)
+	if ((unsigned long)jump_entry_key(jea) <
+	    (unsigned long)jump_entry_key(jeb))
 		return -1;
 
-	if (jea->key > jeb->key)
+	if ((unsigned long)jump_entry_key(jea) >
+	    (unsigned long)jump_entry_key(jeb))
 		return 1;
I think you can ditch the unsigned long cast and directly compare
pointers. That leads to much prettier code:

	if (jump_entry_key(jea) < jump_entry_key(jeb))
		return -1;

etc..
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help