Skip to contentSkip to conversation

debugobjects: make fixup functions return bool instead of int

PATCH New [email protected] 1 participant 1 message May 20, 2016

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 8/117 debugobjects: make fixup functions return bool instead of int

From: "Du, Changbin" <[email protected]>
Subject: debugobjects: make fixup functions return bool instead of int

I am going to introduce debugobjects infrastructure to USB subsystem. But before this, I found the code of debugobjects could be improved. This patchset will make fixup functions return bool type instead of int. Because fixup only need report success or no. boolean is the 'real' type.

This patch (of 7):

The object debugging infrastructure core provides some fixup callbacks for the subsystem who use it. These callbacks are called from the debug code whenever a problem in debug_object_init is detected. And debugobjects core suppose them returns 1 when the fixup was successful, otherwise 0. So the return type is boolean.

A bad thing is that debug_object_fixup use the return value for arithmetic operation. It confused me that what is the reall return type.

Reading over the whole code, I found some place do use the return value incorrectly(see next patch). So why use bool type instead?

Cc Jonathan Corbet <[email protected]>
Cc Josh Triplett <[email protected]>
Cc Steven Rostedt <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Christian Borntraeger <[email protected]>

---

 include/linux/debugobjects.h |   15 ++++++-----
 lib/debugobjects.c           |   43 ++++++++++++++++-----------------
 2 files changed, 29 insertions(+), 29 deletions(-)
include/linux/debugobjects.h renamed from include/linux/debugobjects.h~debugobjects-make-fixup-functions-return-bool-instead-of-int +8 -7
diff -puN include/linux/debugobjects.h~debugobjects-make-fixup-functions-return-bool-instead-of-int include/linux/debugobjects.h
@@ -39,7 +39,8 @@ struct debug_obj {
  * @debug_hint:		function returning address, which have associated
  *			kernel symbol, to allow identify the object
  * @fixup_init:		fixup function, which is called when the init check
- *			fails
+ *			fails. All fixup functions must return true if fixup
+ *			was successful, otherwise return false
  * @fixup_activate:	fixup function, which is called when the activate check
  *			fails
  * @fixup_destroy:	fixup function, which is called when the destroy check
@@ -51,12 +52,12 @@ struct debug_obj {
  */
 struct debug_obj_descr {
 	const char		*name;
-	void *(*debug_hint)	(void *addr);
-	int (*fixup_init)	(void *addr, enum debug_obj_state state);
-	int (*fixup_activate)	(void *addr, enum debug_obj_state state);
-	int (*fixup_destroy)	(void *addr, enum debug_obj_state state);
-	int (*fixup_free)	(void *addr, enum debug_obj_state state);
-	int (*fixup_assert_init)(void *addr, enum debug_obj_state state);
+	void *(*debug_hint)(void *addr);
+	bool (*fixup_init)(void *addr, enum debug_obj_state state);
+	bool (*fixup_activate)(void *addr, enum debug_obj_state state);
+	bool (*fixup_destroy)(void *addr, enum debug_obj_state state);
+	bool (*fixup_free)(void *addr, enum debug_obj_state state);
+	bool (*fixup_assert_init)(void *addr, enum debug_obj_state state);
 };
 
 #ifdef CONFIG_DEBUG_OBJECTS
lib/debugobjects.c renamed from lib/debugobjects.c~debugobjects-make-fixup-functions-return-bool-instead-of-int +21 -22

109 lines not on this page · raw message

_