[Devel] [PATCH 1/2] cr: be more informative with obj_new errors

Serge Hallyn serue at us.ibm.com
Fri Apr 9 14:12:57 PDT 2010


From: Serge E. Hallyn <serue at us.ibm.com>

If some checkpoint object type was mis-registered or mis-used,
at least give some info to help deduce the caller.

Signed-off-by: Serge E. Hallyn <serue at us.ibm.com>
---
 kernel/checkpoint/objhash.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/kernel/checkpoint/objhash.c b/kernel/checkpoint/objhash.c
index af1e5e7..6a3937e 100644
--- a/kernel/checkpoint/objhash.c
+++ b/kernel/checkpoint/objhash.c
@@ -188,9 +188,18 @@ static struct ckpt_obj *obj_new(struct ckpt_ctx *ctx, void *ptr,
 	int i, ret;
 
 	/* explicitly disallow null pointers */
-	BUG_ON(!ptr);
+	if (!ptr) {
+		ckpt_err(ctx, -EINVAL, "checkpointing NULL type %d\n", type);
+		return -EINVAL;
+	}
+
 	/* make sure we don't change this accidentally */
-	BUG_ON(ops->obj_type != type);
+	if (ops->obj_type != type)
+	{
+		ckpt_err(ctx, -EINVAL, "type mismatch: %d->ops->obj_type %d\n",
+			type, ops->obj_type);
+		return ERR_PTR(-EINVAL);
+	}
 
 	obj = kzalloc(sizeof(*obj), GFP_KERNEL);
 	if (!obj)
-- 
1.7.0.4

_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list