Changeset 846 for trunk/xcache.c


Ignore:
Timestamp:
2012-03-26T11:41:19+02:00 (2 years ago)
Author:
moo
Message:

kill most const warning

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/xcache.c

    r840 r846  
    3838#include "utils.h" 
    3939 
    40 #define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > pentry->ctime + (pentry)->ttl) 
     40#define VAR_ENTRY_EXPIRED(pentry) ((pentry)->ttl && XG(request_time) > (pentry)->ctime + (pentry)->ttl) 
    4141#define CHECK(x, e) do { if ((x) == NULL) { zend_error(E_ERROR, "XCache: " e); goto err; } } while (0) 
    42 #define LOCK(x) xc_lock(x->lck) 
    43 #define UNLOCK(x) xc_unlock(x->lck) 
     42#define LOCK(x) xc_lock((x)->lck) 
     43#define UNLOCK(x) xc_unlock((x)->lck) 
    4444 
    4545#define ENTER_LOCK_EX(x) \ 
    46     xc_lock(x->lck); \ 
     46    xc_lock((x)->lck); \ 
    4747    zend_try { \ 
    4848        do 
     
    5252        catched = 1; \ 
    5353    } zend_end_try(); \ 
    54     xc_unlock(x->lck) 
     54    xc_unlock((x)->lck) 
    5555 
    5656#define ENTER_LOCK(x) do { \ 
     
    859859    /* fall back to current directory */ 
    860860    if (zend_is_executing(TSRMLS_C)) { 
    861         char *path = zend_get_executed_filename(TSRMLS_C); 
    862         if (path && path[0] != '[') { 
    863             int len = strlen(path); 
    864             while ((--len >= 0) && !IS_SLASH(path[len])) { 
     861        const char *executed_filename = zend_get_executed_filename(TSRMLS_C); 
     862        if (executed_filename && executed_filename[0] != '[') { 
     863            int len = strlen(executed_filename); 
     864            while ((--len >= 0) && !IS_SLASH(executed_filename[len])) { 
    865865                /* skipped */ 
    866866            } 
    867867            if (len > 0 && len + strlen(filename) + 1 < MAXPATHLEN - 1) { 
    868                 strcpy(filepath, path); 
     868                strcpy(filepath, executed_filename); 
    869869                strcpy(filepath + len + 1, filename); 
    870870                if (VCWD_STAT(filepath, pbuf) == 0) { 
     
    886886 
    887887#define HASH(i) (i) 
    888 #define HASH_ZSTR_L(t, s, l) HASH(zend_u_inline_hash_func(t, s, (l + 1) * sizeof(UChar))) 
    889 #define HASH_STR_S(s, l) HASH(zend_inline_hash_func(s, l)) 
    890 #define HASH_STR_L(s, l) HASH_STR_S(s, l + 1) 
    891 #define HASH_STR(s) HASH_STR_L(s, strlen(s) + 1) 
     888#define HASH_ZSTR_L(t, s, l) HASH(zend_u_inline_hash_func((t), (s), ((l) + 1) * sizeof(UChar))) 
     889#define HASH_STR_S(s, l) HASH(zend_inline_hash_func((s), (l))) 
     890#define HASH_STR_L(s, l) HASH_STR_S((s), (l) + 1) 
     891#define HASH_STR(s) HASH_STR_L((s), strlen((s)) + 1) 
    892892#define HASH_NUM(n) HASH(n) 
    893893static inline xc_hash_value_t xc_hash_fold(xc_hash_value_t hvalue, const xc_hash_t *hasher) /* {{{ fold hash bits as needed */ 
     
    962962/* }}} */ 
    963963 
    964 static int xc_entry_init_key_php(xc_entry_t *xce, char *filename TSRMLS_DC) /* {{{ */ 
     964static int xc_entry_init_key_php(xc_entry_t *xce, const char *filename TSRMLS_DC) /* {{{ */ 
    965965{ 
    966966    char opened_path_buffer[MAXPATHLEN]; 
    967     struct stat buf, *pbuf; 
    968     xc_hash_value_t hv; 
    969967    int cacheid; 
    970     xc_entry_data_php_t *php; 
    971     char *ptr; 
    972     time_t delta; 
    973968 
    974969    if (!filename || !SG(request_info).path_translated) { 
     
    980975    } 
    981976 
    982     php = xce->data.php; 
    983  
    984977    if (XG(stat)) { 
     978        struct stat buf, *pbuf; 
     979 
    985980        if (strcmp(SG(request_info).path_translated, filename) == 0) { 
    986981            /* sapi has already done this stat() for us */ 
     
    1002997        /* relative path */ 
    1003998        if (*filename == '.' && (IS_SLASH(filename[1]) || filename[1] == '.')) { 
    1004             ptr = filename + 1; 
     999            const char *ptr = filename + 1; 
    10051000            if (*ptr == '.') { 
    10061001                while (*(++ptr) == '.'); 
     
    10251020 
    10261021stat_done: 
    1027         delta = XG(request_time) - pbuf->st_mtime; 
    1028         if (abs(delta) < 2 && !xc_test) { 
    1029             return FAILURE; 
     1022        { 
     1023            time_t delta = XG(request_time) - pbuf->st_mtime; 
     1024            if (abs(delta) < 2 && !xc_test) { 
     1025                return FAILURE; 
     1026            } 
    10301027        } 
    10311028 
     
    10351032        xce->inode        = pbuf->st_ino; 
    10361033#endif 
    1037         php->sourcesize  = pbuf->st_size; 
     1034        xce->data.php->sourcesize = pbuf->st_size; 
    10381035    } 
    10391036    else { /* XG(inode) */ 
     
    10431040        xce->inode        = 0; 
    10441041#endif 
    1045         php->sourcesize  = 0; 
     1042        xce->data.php->sourcesize = 0; 
    10461043    } 
    10471044 
     
    10591056 
    10601057    UNISW(NOTHING, xce->name_type = IS_STRING;) 
    1061     xce->name.str.val = filename; 
     1058    xce->name.str.val = (char *) filename; 
    10621059    xce->name.str.len = strlen(filename); 
    10631060 
    1064     if (xc_php_hcache.size > 1) { 
    1065         hv = xc_entry_hash_php_basename(xce TSRMLS_CC); 
    1066         cacheid = xc_hash_fold(hv, &xc_php_hcache); 
    1067     } 
    1068     else { 
    1069         cacheid = 0; 
    1070     } 
     1061    cacheid = xc_php_hcache.size > 1 ? xc_hash_fold(xc_entry_hash_php_basename(xce TSRMLS_CC), &xc_php_hcache) : 0; 
    10711062    xce->cache = xc_php_caches[cacheid]; 
    1072  
    1073     hv = xc_entry_hash_php(xce TSRMLS_CC); 
    1074     xce->hvalue = xc_hash_fold(hv, &xc_php_hentry); 
    1075  
     1063    xce->hvalue = xc_hash_fold(xc_entry_hash_php(xce TSRMLS_CC), &xc_php_hentry); 
    10761064    xce->type = XC_TYPE_PHP; 
    1077  
    10781065    xce->filepath  = NULL; 
    10791066    xce->dirpath   = NULL; 
     
    10881075static inline xc_hash_value_t xc_php_hash_md5(xc_entry_data_php_t *php TSRMLS_DC) /* {{{ */ 
    10891076{ 
    1090     return HASH_STR_S(&php->md5, sizeof(php->md5)); 
     1077    return HASH_STR_S(php->md5.digest, sizeof(php->md5)); 
    10911078} 
    10921079/* }}} */ 
     
    10971084    int             n; 
    10981085    php_stream     *stream; 
    1099     xc_hash_value_t hv; 
    11001086    ulong           old_rsid = EG(regular_list).nNextFreeElement; 
    11011087 
     
    11201106    } 
    11211107 
    1122     hv = xc_php_hash_md5(php TSRMLS_CC); 
    11231108    php->cache  = xce->cache; 
    1124     php->hvalue = (hv & php->cache->hphp->mask); 
     1109    php->hvalue = (xc_php_hash_md5(php TSRMLS_CC) & php->cache->hphp->mask); 
    11251110#ifdef XCACHE_DEBUG 
    11261111    { 
     
    11341119} 
    11351120/* }}} */ 
    1136 static void xc_entry_init_key_php_entry(xc_entry_t *xce, char *filepath TSRMLS_DC) /* {{{*/ 
     1121static void xc_entry_init_key_php_entry(xc_entry_t *xce, ZEND_24(const) char *filepath TSRMLS_DC) /* {{{*/ 
    11371122{ 
    11381123    xce->filepath     = filepath; 
     
    15181503    /* }}} */ 
    15191504    /* {{{ prepare */ 
    1520     zend_restore_compiled_filename(h->opened_path ? h->opened_path : h->filename TSRMLS_CC); 
     1505    zend_restore_compiled_filename(h->opened_path ? h->opened_path : (char *) h->filename TSRMLS_CC); 
    15211506    php->op_array      = op_array; 
    15221507 
     
    18901875     */ 
    18911876    if (xce->inode) { 
    1892         char *filename = h->opened_path ? h->opened_path : h->filename; 
     1877        const char *filename = h->opened_path ? h->opened_path : h->filename; 
    18931878        if (xce->name.str.val != filename) { 
    1894             xce->name.str.val = filename; 
     1879            xce->name.str.val = (char *) filename; 
    18951880            xce->name.str.len = strlen(filename); 
    18961881        } 
     
    19791964    xc_entry_t xce; 
    19801965    xc_entry_data_php_t php; 
    1981     char *filename; 
     1966    const char *filename; 
    19821967 
    19831968    assert(xc_initized); 
Note: See TracChangeset for help on using the changeset viewer.