Don't throw a spurious error when using DBdeltree
authorMatthew Jordan <mjordan@digium.com>
Thu, 14 Feb 2013 03:49:52 +0000 (03:49 +0000)
committerMatthew Jordan <mjordan@digium.com>
Thu, 14 Feb 2013 03:49:52 +0000 (03:49 +0000)
The function call ast_db_deltree returns the number of row deleted, or a
negative number if it failed. DBdeltree was treating any non-zero return
as an error, causing a spurious verbose error message to be displayed.

This patch handles the return code of ast_db_deltree correctly.

(closes issue ASTERISK-21070)
Reported by: ianc
patches:
  dbdeltree.diff uploaded by ianc (License #5955)
........

Merged revisions 381364 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 381365 from http://svn.asterisk.org/svn/asterisk/branches/11

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@381366 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_db.c

index 1fa2408..ef8d0b3 100644 (file)
@@ -106,13 +106,15 @@ static int deltree_exec(struct ast_channel *chan, const char *data)
                keytree = 0;
        }
 
-       if (keytree)
+       if (keytree) {
                ast_verb(3, "DBdeltree: family=%s, keytree=%s\n", family, keytree);
-       else
+       } else {
                ast_verb(3, "DBdeltree: family=%s\n", family);
+       }
 
-       if (ast_db_deltree(family, keytree))
+       if (ast_db_deltree(family, keytree) < 0) {
                ast_verb(3, "DBdeltree: Error deleting key from database.\n");
+       }
 
        return 0;
 }