Re: [Qemu-devel] [PATCH v1 1/1] qom/object: Don't poll cast cache for NULL objects

2013-05-21 Thread Andreas Färber
Am 21.05.2013 08:05, schrieb peter.crosthwa...@xilinx.com:
 From: Peter Crosthwaite peter.crosthwa...@xilinx.com
 
 object_dymamic_cast_assert used to be tolerant of NULL objects and not

dynamic

 assert. Its clear from the implementation that this is the expected

It's

 behavior.
 
 The preceding check of the cast cache dereferences obj however causing
 a segfault. Fix by conditionalizing the cast cache logic on obj being
 non-null.
 
 Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com

Otherwise,

Reviewed-by: Andreas Färber afaer...@suse.de

Andreas

 ---
 
  qom/object.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
 
 diff --git a/qom/object.c b/qom/object.c
 index ec88231..803b94b 100644
 --- a/qom/object.c
 +++ b/qom/object.c
 @@ -442,7 +442,7 @@ Object *object_dynamic_cast_assert(Object *obj, const 
 char *typename,
  int i;
  Object *inst;
  
 -for (i = 0; i  OBJECT_CLASS_CAST_CACHE; i++) {
 +for (i = 0; obj  i  OBJECT_CLASS_CAST_CACHE; i++) {
  if (obj-class-cast_cache[i] == typename) {
  goto out;
  }
 @@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const 
 char *typename,
  
  assert(obj == inst);
  
 -if (obj == inst) {
 +if (obj  obj == inst) {
  for (i = 1; i  OBJECT_CLASS_CAST_CACHE; i++) {
  obj-class-cast_cache[i - 1] = obj-class-cast_cache[i];
  }
 

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg



Re: [Qemu-devel] [PATCH v1 1/1] qom/object: Don't poll cast cache for NULL objects

2013-05-21 Thread Anthony Liguori
peter.crosthwa...@xilinx.com writes:

 From: Peter Crosthwaite peter.crosthwa...@xilinx.com

 object_dymamic_cast_assert used to be tolerant of NULL objects and not
 assert. Its clear from the implementation that this is the expected
 behavior.

 The preceding check of the cast cache dereferences obj however causing
 a segfault. Fix by conditionalizing the cast cache logic on obj being
 non-null.

 Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com

Reviewed-by: Anthony Liguori aligu...@us.ibm.com

Regards,

Anthony Liguori

 ---

  qom/object.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)

 diff --git a/qom/object.c b/qom/object.c
 index ec88231..803b94b 100644
 --- a/qom/object.c
 +++ b/qom/object.c
 @@ -442,7 +442,7 @@ Object *object_dynamic_cast_assert(Object *obj, const 
 char *typename,
  int i;
  Object *inst;
  
 -for (i = 0; i  OBJECT_CLASS_CAST_CACHE; i++) {
 +for (i = 0; obj  i  OBJECT_CLASS_CAST_CACHE; i++) {
  if (obj-class-cast_cache[i] == typename) {
  goto out;
  }
 @@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const 
 char *typename,
  
  assert(obj == inst);
  
 -if (obj == inst) {
 +if (obj  obj == inst) {
  for (i = 1; i  OBJECT_CLASS_CAST_CACHE; i++) {
  obj-class-cast_cache[i - 1] = obj-class-cast_cache[i];
  }
 -- 
 1.8.3.rc1.44.gb387c77.dirty




[Qemu-devel] [PATCH v1 1/1] qom/object: Don't poll cast cache for NULL objects

2013-05-21 Thread peter . crosthwaite
From: Peter Crosthwaite peter.crosthwa...@xilinx.com

object_dymamic_cast_assert used to be tolerant of NULL objects and not
assert. Its clear from the implementation that this is the expected
behavior.

The preceding check of the cast cache dereferences obj however causing
a segfault. Fix by conditionalizing the cast cache logic on obj being
non-null.

Signed-off-by: Peter Crosthwaite peter.crosthwa...@xilinx.com
---

 qom/object.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qom/object.c b/qom/object.c
index ec88231..803b94b 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -442,7 +442,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char 
*typename,
 int i;
 Object *inst;
 
-for (i = 0; i  OBJECT_CLASS_CAST_CACHE; i++) {
+for (i = 0; obj  i  OBJECT_CLASS_CAST_CACHE; i++) {
 if (obj-class-cast_cache[i] == typename) {
 goto out;
 }
@@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const char 
*typename,
 
 assert(obj == inst);
 
-if (obj == inst) {
+if (obj  obj == inst) {
 for (i = 1; i  OBJECT_CLASS_CAST_CACHE; i++) {
 obj-class-cast_cache[i - 1] = obj-class-cast_cache[i];
 }
-- 
1.8.3.rc1.44.gb387c77.dirty