]> git.tuebingen.mpg.de Git - osl.git/commitdiff
osl_get_nth_row(): Always initialize result pointer.
authorAndre Noll <maan@tuebingen.mpg.de>
Sat, 13 Jun 2015 18:47:33 +0000 (20:47 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 13 Jun 2015 18:47:33 +0000 (20:47 +0200)
We buy into Postel's prescription and try to be liberal in what we
accept, and conservative in what we send. This patch makes sure the
result pointer is set to NULL on failure, and documents this fact.

osl.c
osl.h.in

diff --git a/osl.c b/osl.c
index 80bec0f4fb8fcc8b7ea38b9329a3aa04a54feacd..66661969e3720193d7f7af4c5295ee02d8db13d5 100644 (file)
--- a/osl.c
+++ b/osl.c
@@ -1702,6 +1702,7 @@ __export int osl_get_nth_row(const struct osl_table *t, unsigned col_num,
        unsigned num_rows;
        int ret;
 
+       *result = NULL;
        if (n == 0)
                return -E_OSL_RB_KEY_NOT_FOUND;
        ret = osl_get_num_rows(t, &num_rows);
index 5491a2c82411eb20a735185f6dd3b144cd00e881..17bfbc16656abf7b6ac0a928378cc7529dbb00cf 100644 (file)
--- a/osl.h.in
+++ b/osl.h.in
@@ -214,7 +214,8 @@ int osl_close_table(struct osl_table *t, enum osl_close_flags flags);
  * Lookup \a obj in \a t and return the row containing \a obj. The column
  * specified by \a col_num must have an associated rbtree.
  *
- * \return Standard.
+ * \return Standard. \a result is set to \p NULL if and only if the function
+ * returns negative.
  *
  * \sa osl_storage_flags
  */