diff --git a/src/mod_dirlisting.c b/src/mod_dirlisting.c index f3d08089..9774c549 100644 --- a/src/mod_dirlisting.c +++ b/src/mod_dirlisting.c @@ -338,15 +338,15 @@ SETDEFAULTS_FUNC(mod_dirlisting_set_defaults) { } typedef struct { - size_t namelen; + uint32_t namelen; time_t mtime; off_t size; } dirls_entry_t; typedef struct { dirls_entry_t **ent; - size_t used; - size_t size; + uint32_t used; + uint32_t size; } dirls_list_t; #define DIRLIST_ENT_NAME(ent) ((char*)(ent) + sizeof(dirls_entry_t)) @@ -919,7 +919,7 @@ static int http_list_directory(request_st * const r, plugin_data * const p, buff tmp = (dirls_entry_t*) malloc(sizeof(dirls_entry_t) + 1 + i); tmp->mtime = st.st_mtime; tmp->size = st.st_size; - tmp->namelen = i; + tmp->namelen = (uint32_t)i; memcpy(DIRLIST_ENT_NAME(tmp), dent->d_name, i + 1); list->ent[list->used++] = tmp; diff --git a/src/mod_webdav.c b/src/mod_webdav.c index 0f9c6a4c..713c678d 100644 --- a/src/mod_webdav.c +++ b/src/mod_webdav.c @@ -2225,7 +2225,7 @@ webdav_response_etag (request_st * const r, struct stat *st) static void webdav_parent_modified (const buffer *path) { - size_t dirlen = buffer_string_length(path); + uint32_t dirlen = buffer_string_length(path); const char *fn = path->ptr; /*force_assert(0 != dirlen);*/ /*force_assert(fn[0] == '/');*/ @@ -2260,7 +2260,7 @@ webdav_parse_Depth (const request_st * const r) static int webdav_unlinkat (const plugin_config * const pconf, const buffer * const uri, - const int dfd, const char * const d_name, size_t len) + const int dfd, const char * const d_name, uint32_t len) { if (0 == unlinkat(dfd, d_name, 0)) { stat_cache_delete_entry(d_name, len); diff --git a/src/stat_cache.c b/src/stat_cache.c index 9a38408a..f8fe0429 100644 --- a/src/stat_cache.c +++ b/src/stat_cache.c @@ -57,26 +57,26 @@ static stat_cache sc; /* the famous DJB hash function for strings */ __attribute_pure__ -static uint32_t djbhash(const char *str, const size_t len) +static uint32_t djbhash(const char *str, const uint32_t len) { const unsigned char * const s = (const unsigned char *)str; uint32_t hash = 5381; - for (size_t i = 0; i < len; ++i) hash = ((hash << 5) + hash) ^ s[i]; + for (uint32_t i = 0; i < len; ++i) hash = ((hash << 5) + hash) ^ s[i]; return hash; } __attribute_pure__ -static uint32_t hashme(const char *str, const size_t len) +static int32_t hashme(const char *str, const uint32_t len) { /* strip highest bit of hash value for splaytree */ - return djbhash(str,len) & ~(((uint32_t)1) << 31); + return (int32_t)(djbhash(str,len) & ~(((uint32_t)1) << 31)); } static void * stat_cache_sptree_find(splay_tree ** const sptree, const char * const name, - size_t len) + uint32_t len) { const int ndx = hashme(name, len); *sptree = splaytree_splay(*sptree, ndx); @@ -252,7 +252,7 @@ static void fam_dir_invalidate_tree(splay_tree *t, const char *name, size_t len) } /* declarations */ -static void stat_cache_delete_tree(const char *name, size_t len); +static void stat_cache_delete_tree(const char *name, uint32_t len); static void stat_cache_invalidate_dir_tree(const char *name, size_t len); static void stat_cache_handle_fdevent_in(stat_cache_fam *scf) @@ -412,7 +412,7 @@ static void stat_cache_free_fam(stat_cache_fam *scf) { free(scf); } -static fam_dir_entry * fam_dir_monitor(stat_cache_fam *scf, char *fn, size_t dirlen, struct stat *st) +static fam_dir_entry * fam_dir_monitor(stat_cache_fam *scf, char *fn, uint32_t dirlen, struct stat *st) { if (NULL == scf->fdn) return NULL; /* FAM connection closed; do nothing */ const int fn_is_dir = S_ISDIR(st->st_mode); @@ -653,7 +653,7 @@ int stat_cache_choose_engine (const buffer *stat_cache_string, log_error_st *err return 0; } -const buffer * stat_cache_mimetype_by_ext(const array * const mimetypes, const char * const name, const size_t nlen) +const buffer * stat_cache_mimetype_by_ext(const array * const mimetypes, const char * const name, const uint32_t nlen) { const char * const end = name + nlen; /*(end of string)*/ const uint32_t used = mimetypes->used; @@ -783,7 +783,7 @@ const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags) { return NULL; } -void stat_cache_update_entry(const char *name, size_t len, +void stat_cache_update_entry(const char *name, uint32_t len, struct stat *st, buffer *etagb) { if (sc.stat_cache_engine == STAT_CACHE_ENGINE_NONE) return; @@ -802,7 +802,7 @@ void stat_cache_update_entry(const char *name, size_t len, } } -void stat_cache_delete_entry(const char *name, size_t len) +void stat_cache_delete_entry(const char *name, uint32_t len) { if (sc.stat_cache_engine == STAT_CACHE_ENGINE_NONE) return; force_assert(0 != len); @@ -815,7 +815,7 @@ void stat_cache_delete_entry(const char *name, size_t len) } } -void stat_cache_invalidate_entry(const char *name, size_t len) +void stat_cache_invalidate_entry(const char *name, uint32_t len) { splay_tree **sptree = &sc.files; stat_cache_entry *sce = stat_cache_sptree_find(sptree, name, len); @@ -898,13 +898,13 @@ static void stat_cache_prune_dir_tree(const char *name, size_t len) sc.files = sptree; } -static void stat_cache_delete_tree(const char *name, size_t len) +static void stat_cache_delete_tree(const char *name, uint32_t len) { stat_cache_delete_entry(name, len); stat_cache_prune_dir_tree(name, len); } -void stat_cache_delete_dir(const char *name, size_t len) +void stat_cache_delete_dir(const char *name, uint32_t len) { force_assert(0 != len); if (name[len-1] == '/') { if (0 == --len) len = 1; } diff --git a/src/stat_cache.h b/src/stat_cache.h index dd7435b6..41e00833 100644 --- a/src/stat_cache.h +++ b/src/stat_cache.h @@ -35,7 +35,7 @@ void stat_cache_free(void); __attribute_cold__ void stat_cache_xattrname (const char *name); -const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, size_t nlen); +const buffer * stat_cache_mimetype_by_ext(const array *mimetypes, const char *name, uint32_t nlen); #if defined(HAVE_XATTR) || defined(HAVE_EXTATTR) const buffer * stat_cache_mimetype_by_xattr(const char *name); const buffer * stat_cache_content_type_get_by_xattr(stat_cache_entry *sce, const array *mimetypes, int use_xattr); @@ -45,10 +45,10 @@ const buffer * stat_cache_content_type_get_by_ext(stat_cache_entry *sce, const a #define stat_cache_content_type_get(con, r) stat_cache_content_type_get_by_ext((sce), (r)->conf.mimetypes) #endif const buffer * stat_cache_etag_get(stat_cache_entry *sce, int flags); -void stat_cache_update_entry(const char *name, size_t len, struct stat *st, buffer *etagb); -void stat_cache_delete_entry(const char *name, size_t len); -void stat_cache_delete_dir(const char *name, size_t len); -void stat_cache_invalidate_entry(const char *name, size_t len); +void stat_cache_update_entry(const char *name, uint32_t len, struct stat *st, buffer *etagb); +void stat_cache_delete_entry(const char *name, uint32_t len); +void stat_cache_delete_dir(const char *name, uint32_t len); +void stat_cache_invalidate_entry(const char *name, uint32_t len); stat_cache_entry * stat_cache_get_entry(const buffer *name); int stat_cache_path_contains_symlink(const buffer *name, log_error_st *errh); int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symlinks);