Changes to remove gcc warnings under linux

This commit is contained in:
sackett 2021-11-28 22:50:19 +03:00
parent f53b0eb985
commit 8735cf1b4a
5 changed files with 22 additions and 9 deletions

View File

@ -199,6 +199,8 @@ void dumpcounters(struct trafcount *tlin, int counterd){
unsigned char tmpbuf[8192]; unsigned char tmpbuf[8192];
struct trafcount *tl; struct trafcount *tl;
ssize_t len;
if(counterd >= 0 && tlin) { if(counterd >= 0 && tlin) {
conf.time = time(0); conf.time = time(0);
@ -218,7 +220,8 @@ void dumpcounters(struct trafcount *tlin, int counterd){
cheader.updated = conf.time; cheader.updated = conf.time;
lseek(counterd, 0, SEEK_SET); lseek(counterd, 0, SEEK_SET);
write(counterd, &cheader, sizeof(struct counter_header)); len = write(counterd, &cheader, sizeof(struct counter_header));
if (len != sizeof(struct counter_header)) fprintf(stderr, "%s error: written %ld bytes\n", __func__, len);
for(tl=tlin; tl; tl = tl->next){ for(tl=tlin; tl; tl = tl->next){
if(tl->number){ if(tl->number){
lseek(counterd, lseek(counterd,
@ -227,7 +230,8 @@ void dumpcounters(struct trafcount *tlin, int counterd){
crecord.traf64 = tl->traf64; crecord.traf64 = tl->traf64;
crecord.cleared = tl->cleared; crecord.cleared = tl->cleared;
crecord.updated = tl->updated; crecord.updated = tl->updated;
write(counterd, &crecord, sizeof(struct counter_record)); len = write(counterd, &crecord, sizeof(struct counter_record));
if (len != sizeof(struct counter_header)) fprintf(stderr, "%s error: written %ld bytes\n", __func__, len);
} }
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){ if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
tl->cleared = conf.time; tl->cleared = conf.time;
@ -318,7 +322,7 @@ void cyclestep(void){
else else
strcat((char *)tmpbuf, (char *)conf.archiver[i]); strcat((char *)tmpbuf, (char *)conf.archiver[i]);
} }
system((char *)tmpbuf+1); if (system((char *)tmpbuf+1)==-1) fprintf(stderr, "%s: some error in system() call\n", __func__);
} }
} }
} }

View File

@ -1274,6 +1274,7 @@ static int h_ace(int argc, unsigned char **argv){
if((acl->action == COUNTIN)||(acl->action == COUNTOUT)||(acl->action == COUNTALL)) { if((acl->action == COUNTIN)||(acl->action == COUNTOUT)||(acl->action == COUNTALL)) {
unsigned long lim; unsigned long lim;
ssize_t len;
tl->comment = ( char *)argv[1]; tl->comment = ( char *)argv[1];
while(isdigit(*tl->comment))tl->comment++; while(isdigit(*tl->comment))tl->comment++;
@ -1295,7 +1296,8 @@ static int h_ace(int argc, unsigned char **argv){
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record), sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
SEEK_SET); SEEK_SET);
memset(&crecord, 0, sizeof(struct counter_record)); memset(&crecord, 0, sizeof(struct counter_record));
read(conf.counterd, &crecord, sizeof(struct counter_record)); len = read(conf.counterd, &crecord, sizeof(struct counter_record));
if (len<sizeof(struct counter_record)) fprintf(stderr, "Error: read %ld bytes insread of %lu\n", len, sizeof(struct counter_record));
tl->traf64 = crecord.traf64; tl->traf64 = crecord.traf64;
tl->cleared = crecord.cleared; tl->cleared = crecord.cleared;
tl->updated = crecord.updated; tl->updated = crecord.updated;
@ -1522,7 +1524,10 @@ static int h_chroot(int argc, unsigned char **argv){
fprintf(stderr, "Unable to set uid %d", (int)uid); fprintf(stderr, "Unable to set uid %d", (int)uid);
return(5); return(5);
} }
chdir("/"); if (chdir("/")!=0) {
fprintf(stderr, "Unable to chdir /");
return(6);
}
return 0; return 0;
} }
#endif #endif

View File

@ -32,7 +32,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
/*find start service section*/ /*find start service section*/
while(!feof(f)) while(!feof(f))
{ {
fgets(tmpbuf1, 1023,f); if (!fgets(tmpbuf1, 1023,f)) break;
if ((strstr(tmpbuf1,start))!=NULL) { i++; break; } if ((strstr(tmpbuf1,start))!=NULL) { i++; break; }
tmpbuf1[0]='\0'; tmpbuf1[0]='\0';
} }
@ -51,7 +51,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
i=0; i=0;
while ( !feof(f) || i< max_count_str) while ( !feof(f) || i< max_count_str)
{ {
fgets(tmpbuf1, 1023,f); if (!fgets(tmpbuf1, 1023,f)) break;
if ((strstr(tmpbuf1,stop))!=NULL) { break; } if ((strstr(tmpbuf1,stop))!=NULL) { break; }

View File

@ -16,8 +16,12 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <stdint.h> #include <stdint.h>
#ifndef PRINTF_INT64_MODIFIER #ifndef PRINTF_INT64_MODIFIER
#if __WORDSIZE == 64
#define PRINTF_INT64_MODIFIER "l"
#else
#define PRINTF_INT64_MODIFIER "ll" #define PRINTF_INT64_MODIFIER "ll"
#endif #endif
#endif
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -711,7 +715,7 @@ struct sockfuncs {
int (*_getsockname)(SOCKET s, struct sockaddr * name, socklen_t * namelen); int (*_getsockname)(SOCKET s, struct sockaddr * name, socklen_t * namelen);
int (*_getsockopt)(SOCKET s, int level, int optname, void * optval, socklen_t * optlen); int (*_getsockopt)(SOCKET s, int level, int optname, void * optval, socklen_t * optlen);
int (*_setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen); int (*_setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen);
int (*_poll)(struct pollfd *fds, unsigned int nfds, int timeout); int (*_poll)(struct pollfd *fds, nfds_t, int timeout);
size_t (*_send)(SOCKET s, const void *msg, size_t len, int flags); size_t (*_send)(SOCKET s, const void *msg, size_t len, int flags);
size_t (*_sendto)(SOCKET s, const void *msg, size_t len, int flags, const struct sockaddr *to, SASIZETYPE tolen); size_t (*_sendto)(SOCKET s, const void *msg, size_t len, int flags, const struct sockaddr *to, SASIZETYPE tolen);
size_t (*_recv)(SOCKET s, void *buf, size_t len, int flags); size_t (*_recv)(SOCKET s, void *buf, size_t len, int flags);

View File

@ -593,7 +593,7 @@ void * adminchild(struct clientparam* param) {
if(writable && !error){ if(writable && !error){
fflush(writable); fflush(writable);
#ifndef _WINCE #ifndef _WINCE
ftruncate(fileno(writable), ftell(writable)); if (ftruncate(fileno(writable), ftell(writable))!=0) perror("Failed to truncate");
#endif #endif
} }
printstr(&pp, error? "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file": printstr(&pp, error? "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file":