]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 69258 via svnmerge from
authorJason Parker <jparker@digium.com>
Thu, 14 Jun 2007 15:21:29 +0000 (15:21 +0000)
committerJason Parker <jparker@digium.com>
Thu, 14 Jun 2007 15:21:29 +0000 (15:21 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.2

........
r69258 | qwell | 2007-06-14 10:15:53 -0500 (Thu, 14 Jun 2007) | 4 lines

Change a quite broken while loop to a for loop, so "continue;" works as expected instead of eating 99% CPU...

Issue 9966, patch by me.

........

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

funcs/func_groupcount.c

index f08f0241c03d11d0a34db049890504d5c3598b57..93ec1e52fe5332ba846d548d85c7df787832ff9e 100644 (file)
@@ -47,7 +47,7 @@ static int group_count_function_read(struct ast_channel *chan, char *cmd,
 
        if ((count = ast_app_group_get_count(group, category)) == -1)
                ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name);
-        else
+       else
                snprintf(buf, len, "%d", count);
 
        return 0;
@@ -101,15 +101,13 @@ static int group_function_read(struct ast_channel *chan, char *cmd,
        
        ast_app_group_list_lock();
        
-       gi = ast_app_group_list_head();
-       while (gi) {
+       for (gi = ast_app_group_list_head(); gi; gi = AST_LIST_NEXT(gi, list)) {
                if (gi->chan != chan)
                        continue;
                if (ast_strlen_zero(data))
                        break;
                if (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, data))
                        break;
-               gi = AST_LIST_NEXT(gi, list);
        }
        
        if (gi)
@@ -159,23 +157,21 @@ static int group_list_function_read(struct ast_channel *chan, char *cmd,
 
        ast_app_group_list_lock();
 
-       gi = ast_app_group_list_head();
-       while (gi) {
+       for (gi = ast_app_group_list_head(); gi; gi = AST_LIST_NEXT(gi, list)) {
                if (gi->chan != chan)
                        continue;
                if (!ast_strlen_zero(tmp1)) {
                        ast_copy_string(tmp2, tmp1, sizeof(tmp2));
                        if (!ast_strlen_zero(gi->category))
                                snprintf(tmp1, sizeof(tmp1), "%s %s@%s", tmp2, gi->group, gi->category);
-                        else
+                       else
                                snprintf(tmp1, sizeof(tmp1), "%s %s", tmp2, gi->group);
                } else {
                        if (!ast_strlen_zero(gi->category))
                                snprintf(tmp1, sizeof(tmp1), "%s@%s", gi->group, gi->category);
-                        else
+                       else
                                snprintf(tmp1, sizeof(tmp1), "%s", gi->group);
                }
-               gi = AST_LIST_NEXT(gi, list);
        }
        
        ast_app_group_list_unlock();