Ignore:
Timestamp:
Feb 4, 2014 10:13:56 AM (11 years ago)
Author:
bennylp
Message:

Misc (re #1630): Fixing warnings about variable set but not used with recent gcc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pjlib-test/thread.c

    r3553 r4728  
    11/* $Id$ */ 
    2 /*  
     2/* 
    33 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com) 
    44 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> 
     
    1616 * You should have received a copy of the GNU General Public License 
    1717 * along with this program; if not, write to the Free Software 
    18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  
     18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    1919 */ 
    2020#include "test.h" 
     
    3131 *  - whether thread timeslicing works, and threads have equal 
    3232 *    time-slice proportion. 
    33  *  
     33 * 
    3434 * APIs tested: 
    3535 *  - pj_thread_create() 
     
    7878 
    7979    id = *pcounter; 
     80    PJ_UNUSED_ARG(id); /* Warning about unused var if TRACE__ is disabled */ 
    8081    TRACE__((THIS_FILE, "     thread %d running..", id)); 
    8182 
     
    121122    pj_status_t rc; 
    122123    pj_uint32_t counter = 0; 
    123   
     124 
    124125    PJ_LOG(3,(THIS_FILE, "..%s", title)); 
    125      
     126 
    126127    pool = pj_pool_create(mem, NULL, 4000, 4000, NULL); 
    127128    if (!pool) 
     
    153154            return -1015; 
    154155        } 
    155          
     156 
    156157        rc = pj_thread_resume(thread); 
    157158        if (rc != PJ_SUCCESS) { 
     
    160161        } 
    161162    } 
    162      
     163 
    163164    PJ_LOG(3,(THIS_FILE, "..waiting for thread to quit..")); 
    164165 
     
    174175        return -1025; 
    175176    } 
    176      
     177 
    177178    PJ_LOG(3,(THIS_FILE, "...%s success", title)); 
    178179    return PJ_SUCCESS; 
     
    203204    for (i=0; i<NUM_THREADS; ++i) { 
    204205        counter[i] = i; 
    205         rc = pj_thread_create(pool, "thread", (pj_thread_proc*)&thread_proc,  
    206                               &counter[i],  
    207                               PJ_THREAD_DEFAULT_STACK_SIZE,  
    208                               PJ_THREAD_SUSPENDED,  
     206        rc = pj_thread_create(pool, "thread", (pj_thread_proc*)&thread_proc, 
     207                              &counter[i], 
     208                              PJ_THREAD_DEFAULT_STACK_SIZE, 
     209                              PJ_THREAD_SUSPENDED, 
    209210                              &thread[i]); 
    210211        if (rc!=PJ_SUCCESS) { 
     
    224225    for (i=0; i<NUM_THREADS; ++i) { 
    225226        if (counter[i] > i) { 
    226             PJ_LOG(3,(THIS_FILE, "....ERROR! Thread %d-th is not suspended!",  
     227            PJ_LOG(3,(THIS_FILE, "....ERROR! Thread %d-th is not suspended!", 
    227228                      i)); 
    228229            return -30; 
     
    240241    } 
    241242 
    242     /* Main thread sleeps for some time to allow threads to run.  
     243    /* Main thread sleeps for some time to allow threads to run. 
    243244     * The longer we sleep, the more accurate the calculation will be, 
    244245     * but it'll make user waits for longer for the test to finish. 
     
    253254    /* Wait until all threads quit, then destroy. */ 
    254255    for (i=0; i<NUM_THREADS; ++i) { 
    255         TRACE__((THIS_FILE, "    Main thread joining thread %d [%p]..",  
     256        TRACE__((THIS_FILE, "    Main thread joining thread %d [%p]..", 
    256257                            i, thread[i])); 
    257258        rc = pj_thread_join(thread[i]); 
     
    292293    diff = (highest-lowest)*100 / ((highest+lowest)/2); 
    293294    if ( diff >= 50) { 
    294         PJ_LOG(3,(THIS_FILE,  
     295        PJ_LOG(3,(THIS_FILE, 
    295296                  "...ERROR: thread didn't have equal timeslice!")); 
    296         PJ_LOG(3,(THIS_FILE,  
     297        PJ_LOG(3,(THIS_FILE, 
    297298                  ".....lowest counter=%u, highest counter=%u, diff=%u%%", 
    298299                  lowest, highest, diff)); 
    299300        return -80; 
    300301    } else { 
    301         PJ_LOG(3,(THIS_FILE,  
     302        PJ_LOG(3,(THIS_FILE, 
    302303                  "...info: timeslice diff between lowest & highest=%u%%", 
    303304                  diff)); 
     
    315316    if (rc != PJ_SUCCESS) 
    316317        return rc; 
    317      
     318 
    318319    rc = simple_thread("suspended thread test", PJ_THREAD_SUSPENDED); 
    319320    if (rc != PJ_SUCCESS) 
    320321        return rc; 
    321      
     322 
    322323    rc = timeslice_test(); 
    323324    if (rc != PJ_SUCCESS) 
     
    329330#else 
    330331/* To prevent warning about "translation unit is empty" 
    331  * when this test is disabled.  
     332 * when this test is disabled. 
    332333 */ 
    333334int dummy_thread_test; 
Note: See TracChangeset for help on using the changeset viewer.