Fix warnings

This commit is contained in:
Vladimir Dubrovin 2026-08-08 21:58:53 +03:00
parent e7bc76da73
commit aea9ff8c94
3 changed files with 16 additions and 12 deletions

View File

@ -298,7 +298,7 @@ void cyclestep(void){
default: default:
break; break;
} }
dologname (tmpbuf, conf.logname, (conf.archiver)?conf.archiver[1]:NULL, conf.logtype, (conf.logtime - t * conf.rotate)); dologname (tmpbuf, conf.logname, (conf.archiver)?conf.archiver[1]:NULL, conf.logtype, (conf.logtime - (time_t)t * conf.rotate));
remove ((char *) tmpbuf); remove ((char *) tmpbuf);
if(conf.archiver) { if(conf.archiver) {
int i; int i;

View File

@ -70,9 +70,9 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
_3proxy_mutex_init(&ht->hash_mutex); _3proxy_mutex_init(&ht->hash_mutex);
_3proxy_mutex_lock(&ht->hash_mutex); _3proxy_mutex_lock(&ht->hash_mutex);
} }
if(!(ht->ihashtable = malloc(tablesize * sizeof(uint32_t))) if(!(ht->ihashtable = malloc((size_t)tablesize * sizeof(uint32_t)))
|| !(ht->hashvalues = malloc(poolsize * (sizeof(struct hashentry) + ht->recsize - 4))) || !(ht->hashvalues = malloc((size_t)poolsize * (sizeof(struct hashentry) + ht->recsize - 4)))
|| !(ht->hashhashvalues = malloc(poolsize * ht->hash_size)) || !(ht->hashhashvalues = malloc((size_t)poolsize * ht->hash_size))
){ ){
free(ht->ihashtable); free(ht->ihashtable);
ht->ihashtable = NULL; ht->ihashtable = NULL;
@ -126,13 +126,13 @@ static void hashgrow(struct hashtable *ht){
if(ht->ihashempty) return; if(ht->ihashempty) return;
if(ht->poolsize >= ht->growlimit) return; if(ht->poolsize >= ht->growlimit) return;
if(newsize > ht->growlimit) newsize = ht->growlimit; if(newsize > ht->growlimit) newsize = ht->growlimit;
newvalues = realloc(ht->hashvalues, newsize * (sizeof(struct hashentry) + ht->recsize - 4)); newvalues = realloc(ht->hashvalues, (size_t)newsize * (sizeof(struct hashentry) + ht->recsize - 4));
if(!newvalues) return; if(!newvalues) return;
ht->hashvalues = newvalues; ht->hashvalues = newvalues;
newvalues = realloc(ht->hashhashvalues, newsize * ht->hash_size); newvalues = realloc(ht->hashhashvalues, (size_t)newsize * ht->hash_size);
if(!newvalues) return; if(!newvalues) return;
ht->hashhashvalues = newvalues; ht->hashhashvalues = newvalues;
memset(ht->hashvalues + (ht->poolsize * (sizeof(struct hashentry) + ht->recsize - 4)), 0, (newsize - ht->poolsize) * (sizeof(struct hashentry) + ht->recsize - 4)); memset(ht->hashvalues + ((size_t)ht->poolsize * (sizeof(struct hashentry) + ht->recsize - 4)), 0, (size_t)(newsize - ht->poolsize) * (sizeof(struct hashentry) + ht->recsize - 4));
for(i = ht->poolsize + 1; i < newsize; i++) { for(i = ht->poolsize + 1; i < newsize; i++) {
hvalue(ht,i)->inext = i+1; hvalue(ht,i)->inext = i+1;
} }

View File

@ -109,15 +109,17 @@ struct sockfuncs sso;
static void genpaths(struct fp_stream *fps){ static void genpaths(struct fp_stream *fps){
size_t len = strlen(path) + 32;
if(fps->what & (FP_CLIDATA|FP_CLIHEADER)){ if(fps->what & (FP_CLIDATA|FP_CLIHEADER)){
if(fps->fpd.path_cli) free(fps->fpd.path_cli); if(fps->fpd.path_cli) free(fps->fpd.path_cli);
fps->fpd.path_cli = malloc(strlen(path) + 10); fps->fpd.path_cli = malloc(len);
sprintf(fps->fpd.path_cli, path, counter++); if(fps->fpd.path_cli) sprintf(fps->fpd.path_cli, path, counter++);
} }
if(fps->what & (FP_SRVDATA|FP_SRVHEADER)){ if(fps->what & (FP_SRVDATA|FP_SRVHEADER)){
if(fps->fpd.path_srv) free(fps->fpd.path_srv); if(fps->fpd.path_srv) free(fps->fpd.path_srv);
fps->fpd.path_srv = malloc(strlen(path) + 10); fps->fpd.path_srv = malloc(len);
sprintf(fps->fpd.path_srv, path, counter++); if(fps->fpd.path_srv) sprintf(fps->fpd.path_srv, path, counter++);
} }
} }
@ -139,6 +141,7 @@ static
return fps->fpd.h_cli; return fps->fpd.h_cli;
#else #else
if(fps->fpd.fd_cli != -1) close(fps->fpd.fd_cli); if(fps->fpd.fd_cli != -1) close(fps->fpd.fd_cli);
if(!fps->fpd.path_cli) return (fps->fpd.fd_cli = -1);
fps->fpd.fd_cli = open(fps->fpd.path_cli, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, 0600); fps->fpd.fd_cli = open(fps->fpd.path_cli, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, 0600);
return fps->fpd.fd_cli; return fps->fpd.fd_cli;
#endif #endif
@ -160,6 +163,7 @@ static
return fps->fpd.h_srv; return fps->fpd.h_srv;
#else #else
if(fps->fpd.fd_srv != -1) close(fps->fpd.fd_srv); if(fps->fpd.fd_srv != -1) close(fps->fpd.fd_srv);
if(!fps->fpd.path_srv) return (fps->fpd.fd_srv = -1);
fps->fpd.fd_srv = open(fps->fpd.path_srv, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, 0600); fps->fpd.fd_srv = open(fps->fpd.path_srv, O_BINARY|O_RDWR|O_CREAT|O_TRUNC, 0600);
return fps->fpd.fd_srv; return fps->fpd.fd_srv;
#endif #endif
@ -871,7 +875,7 @@ static int h_cachedir(int argc, unsigned char **argv){
size_t len; size_t len;
dirp = (argc > 1)? (char *)argv[1] : getenv("TEMP"); dirp = (argc > 1)? (char *)argv[1] : getenv("TEMP");
len = strlen(dirp); len = dirp? strlen(dirp) : 0;
if(!dirp || !len || len > 200 || strchr(dirp, '%')) { if(!dirp || !len || len > 200 || strchr(dirp, '%')) {
fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp); fprintf(stderr, "FilePlugin: invalid directory path: %s\n", dirp);
return (1); return (1);