[Libvirt-cim] [PATCH] Some minor std_association fixes

Kaitlin Rupert kaitlin at linux.vnet.ibm.com
Fri Nov 9 22:47:02 UTC 2007


# HG changeset patch
# User Kaitlin Rupert <karupert at us.ibm.com>
# Date 1194651524 28800
# Node ID 22c4e9b498fb52f5fce98a71702c4610a42b6f18
# Parent  5f84fd6c5cdefb2dfe41e4d8ec6ca750d3e69faa
Some minor std_association fixes.

Change result_list to tmp_list since the list is freed before filter_results() returns.

The CU_DEBUG() call before the match_class() call on info->assoc_class has a typo.  The string text prints info->assoc_class, but the value passed in for info->assoc_class is info->result_class.

Return an error if match_class() fails.  This needs to be done in both do_assoc() and do_ref()

Resent patch due to poor grammar in the match_class() for assoc_class error message.

Signed-off-by: Kaitlin Rupert <karupert at us.ibm.com>

diff -r 5f84fd6c5cde -r 22c4e9b498fb std_association.c
--- a/std_association.c	Thu Nov 08 11:21:50 2007 -0800
+++ b/std_association.c	Fri Nov 09 15:38:44 2007 -0800
@@ -80,16 +80,16 @@ static CMPIStatus filter_results(struct 
                                  const char *filter_class,
                                  const CMPIBroker *broker)
 {
-        struct inst_list result_list;
+        struct inst_list tmp_list;
         CMPIStatus s = {CMPI_RC_OK, NULL};
         CMPIObjectPath *op;
         int i;
 
-        result_list = *list;
+        tmp_list = *list;
         inst_list_init(list);
 
-        for (i = 0; result_list.list[i] != NULL; i++) {
-                op = CMGetObjectPath(result_list.list[i], &s);
+        for (i = 0; tmp_list.list[i] != NULL; i++) {
+                op = CMGetObjectPath(tmp_list.list[i], &s);
                 if ((s.rc != CMPI_RC_OK) || CMIsNullObject(op))
                           goto out;
 
@@ -100,11 +100,11 @@ static CMPIStatus filter_results(struct 
                 if (!match_op(broker, op, filter_class))
                           continue;
 
-                inst_list_add(list, result_list.list[i]);
+                inst_list_add(list, tmp_list.list[i]);
         }
 
 out:
-        inst_list_free(&result_list);
+        inst_list_free(&tmp_list);
 
         return s;
 }
@@ -163,18 +163,25 @@ static CMPIStatus do_assoc(struct std_as
                         handler->target_class);
         if (!rc) {
                 CU_DEBUG("Match_class failed.\n");
+                cu_statusf(ctx->brkr, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Result class is not valid for this association");
                 goto out;
         }
         CU_DEBUG("Match_class succeeded.\n");
 
         CU_DEBUG("Calling match_class: \n\tinfo->assoc_class: '%s'\n",
-              info->result_class);
+              info->assoc_class);
         rc = match_class(ctx->brkr, 
                         NAMESPACE(ref), 
                         info->assoc_class, 
                         handler->assoc_class);
         if (!rc) {
                 CU_DEBUG("Match_class failed.\n");
+                cu_statusf(ctx->brkr, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Association class given is not valid for"
+                           "this association");
                 goto out;
         }
         CU_DEBUG("Match_class succeeded.\n");
@@ -248,8 +255,13 @@ static CMPIStatus do_ref(struct std_asso
                         NAMESPACE(ref), 
                         info->result_class, 
                         handler->assoc_class);
-        if (!rc)
-                goto out;
+        if (!rc) {
+                cu_statusf(ctx->brkr, &s,
+                           CMPI_RC_ERR_FAILED,
+                           "Result class is not valid for this association");
+                goto out;
+        }
+
 
         s = handler->handler(ref, info, &list);
         if ((s.rc != CMPI_RC_OK) || (list.list == NULL))




More information about the Libvirt-cim mailing list