Return NULL from rpmtsProblems() if no problems exist
authorPanu Matilainen <pmatilai@redhat.com>
Thu, 2 Sep 2010 11:12:42 +0000 (14:12 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Thu, 2 Sep 2010 11:12:42 +0000 (14:12 +0300)
- Avoids callers having to separately test for number of problems
  and freeing when no problems exist

lib/rpmts.c
lib/rpmts.h

index 30cf2ab..2633ff7 100644 (file)
@@ -494,6 +494,12 @@ rpmps rpmtsProblems(rpmts ts)
        rpmpsFree(teprobs);
     }
     pi = rpmtsiFree(pi);
+
+    /* Return NULL on no problems instead of an empty set */
+    if (rpmpsNumProblems(ps) == 0) {
+       ps = rpmpsFree(ps);
+    }
+
     return ps;
 }
 
index 4bae9e1..04fc9d1 100644 (file)
@@ -316,7 +316,7 @@ int rpmtsSetSolveCallback(rpmts ts,
 /** \ingroup rpmts
  * Return current transaction set problems.
  * @param ts           transaction set
- * @return             current problem set (or NULL)
+ * @return             current problem set (or NULL if no problems)
  */
 rpmps rpmtsProblems(rpmts ts);