Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ClamAV: devel

Re: Comments cleanup patch (C89) (still applies cleanly to 0.67)

 

 

ClamAV devel RSS feed   Index | Next | Previous | View Threaded


juhl at dif

Feb 17, 2004, 2:30 PM

Post #1 of 1 (351 views)
Permalink
Re: Comments cleanup patch (C89) (still applies cleanly to 0.67)

Hi,

This is just a small mail to point out that the patch below still applies
cleanly to clamav-0.67 - please consider applying.

/Jesper Juhl


On Sun, 15 Feb 2004, Jesper Juhl wrote:

>
> Hi,
>
> First of all, since this is my first post, let me introduce myself to the
> list.
>
> My name is Jesper Juhl, and I work as a systems administrator at the
> Danish Sports Federation where I maintain several Linux and AIX based
> servers and a bunch of Cisco network equipment. We have recently put
> ClamAV into production use for scanning all email for 400+ users.
> I've been programming in x86 ASM, C & C++ for several years, and since we
> are now using ClamAV I thought I might as well get involved in its
> development.
>
> Since code talks and bullshit walks, I thought I'd better accompany my
> first mail with a patch as well (however insignificant), so I desided to
> do a quick 5min cleanup of the C++ style comments in various ClamAV C
> files. C89 does not support C++ style comments, and though gcc and most
> other contemporary compilers handle them just fine they should none the
> less really be C style comments, so my patch (found below) makes that
> change.
> More changes, more substantial in nature, are forthcomming in future
> posts.
>
>
> Here's the patch (applies cleanly to clam 0.66 with patch -p1) :
>
>
> diff -urp clamav-0.66/clamd/cfgfile.c clamav-0.66-juhl/clamd/cfgfile.c
> --- clamav-0.66/clamd/cfgfile.c 2004-02-11 00:01:52.000000000 +0100
> +++ clamav-0.66-juhl/clamd/cfgfile.c 2004-02-15 03:58:07.000000000 +0100
> @@ -141,8 +141,10 @@ struct cfgstruct *parsecfg(const char *c
> fprintf(stderr, "ERROR: Parse error at line %d: Option %s requires string as argument.\n", line, name);
> return NULL;
> }
> - // FIXME: this one is an ugly hack of the above
> - // case
> +/*
> + FIXME: this one is an ugly hack of the above
> + case
> +*/
> free(arg);
> arg = strstr(buff, " ");
> arg = strdup(++arg);
> diff -urp clamav-0.66/clamd/dazuko.h clamav-0.66-juhl/clamd/dazuko.h
> --- clamav-0.66/clamd/dazuko.h 2003-07-29 17:48:10.000000000 +0200
> +++ clamav-0.66-juhl/clamd/dazuko.h 2004-02-15 03:59:46.000000000 +0100
> @@ -23,7 +23,9 @@
> #ifndef DAZUKO_H
> #define DAZUKO_H
>
> -//#define VERSION "1.1.0"
> +/*
> +#define VERSION "1.1.0"
> +*/
> #define DEVICE_NAME "dazuko"
> #define DAZUKO_FILENAME_MAX_LENGTH 4095
>
> diff -urp clamav-0.66/clamd/localserver.c clamav-0.66-juhl/clamd/localserver.c
> --- clamav-0.66/clamd/localserver.c 2004-02-10 14:25:27.000000000 +0100
> +++ clamav-0.66-juhl/clamd/localserver.c 2004-02-15 03:59:07.000000000 +0100
> @@ -49,7 +49,9 @@ int localserver(const struct optstruct *
>
> if((sockfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) {
> estr = strerror(errno);
> - //fprintf(stderr, "ERROR: socket() error: %s\n", estr);
> +/*
> + fprintf(stderr, "ERROR: socket() error: %s\n", estr);
> +*/
> logg("!Socket allocation error: %s\n", estr);
> exit(1);
> }
> @@ -95,7 +97,9 @@ int localserver(const struct optstruct *
>
> if(listen(sockfd, backlog) == -1) {
> estr = strerror(errno);
> - //fprintf(stderr, "ERROR: listen() error: %s\n", estr);
> +/*
> + fprintf(stderr, "ERROR: listen() error: %s\n", estr);
> +*/
> logg("!listen() error: %s\n", estr);
> exit(1);
> }
> diff -urp clamav-0.66/clamd/tcpserver.c clamav-0.66-juhl/clamd/tcpserver.c
> --- clamav-0.66/clamd/tcpserver.c 2004-02-06 03:40:39.000000000 +0100
> +++ clamav-0.66-juhl/clamd/tcpserver.c 2004-02-15 03:58:41.000000000 +0100
> @@ -64,7 +64,9 @@ int tcpserver(const struct optstruct *op
>
> if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
> estr = strerror(errno);
> - //fprintf(stderr, "ERROR: socket() error: %s\n", estr);
> +/*
> + fprintf(stderr, "ERROR: socket() error: %s\n", estr);
> +*/
> logg("!socket() error: %s\n", estr);
> exit(1);
> }
> @@ -75,7 +77,9 @@ int tcpserver(const struct optstruct *op
>
> if(bind(sockfd, (struct sockaddr *) &server, sizeof(struct sockaddr_in)) == -1) {
> estr = strerror(errno);
> - //fprintf(stderr, "ERROR: can't bind(): %s\n", estr);
> +/*
> + fprintf(stderr, "ERROR: can't bind(): %s\n", estr);
> +*/
> logg("!bind() error: %s\n", estr);
> exit(1);
> } else {
> @@ -94,7 +98,9 @@ int tcpserver(const struct optstruct *op
>
> if(listen(sockfd, backlog) == -1) {
> estr = strerror(errno);
> - //fprintf(stderr, "ERROR: listen() error: %s\n", estr);
> +/*
> + fprintf(stderr, "ERROR: listen() error: %s\n", estr);
> +*/
> logg("!listen() error: %s\n", estr);
> exit(1);
> }
> diff -urp clamav-0.66/clamdscan/clamdscan.c clamav-0.66-juhl/clamdscan/clamdscan.c
> --- clamav-0.66/clamdscan/clamdscan.c 2004-02-06 02:54:16.000000000 +0100
> +++ clamav-0.66-juhl/clamdscan/clamdscan.c 2004-02-15 04:00:44.000000000 +0100
> @@ -102,7 +102,9 @@ void clamscan(struct optstruct *opt)
> gettimeofday(&t1, &tz);
> ret = client(opt);
>
> -//Implement STATUS in clamd
> +/*
> +Implement STATUS in clamd
> +*/
> if(!optl(opt, "disable-summary")) {
> gettimeofday(&t2, &tz);
> ds = t2.tv_sec - t1.tv_sec;
> diff -urp clamav-0.66/libclamav/readdb.c clamav-0.66-juhl/libclamav/readdb.c
> --- clamav-0.66/libclamav/readdb.c 2004-02-06 03:12:21.000000000 +0100
> +++ clamav-0.66-juhl/libclamav/readdb.c 2004-02-15 03:46:33.000000000 +0100
> @@ -187,7 +187,9 @@ int cl_loaddb(const char *filename, stru
> fclose(fd);
> return ret;
> }
> -// cli_dbgmsg("Added part %d of partial signature (id %d)\n", i, sigid);
> +/*
> + cli_dbgmsg("Added part %d of partial signature (id %d)\n", i, sigid);
> +*/
> free(pt2);
> }
>
> diff -urp clamav-0.66/libclamav/unrarlib.c clamav-0.66-juhl/libclamav/unrarlib.c
> --- clamav-0.66/libclamav/unrarlib.c 2004-02-06 03:42:23.000000000 +0100
> +++ clamav-0.66-juhl/libclamav/unrarlib.c 2004-02-15 03:52:30.000000000 +0100
> @@ -418,9 +418,11 @@ int urarlib_get(void *output,
> if (ArcPtr!=NULL){
> /* FIXME: possible FILE* leak */
> cli_dbgmsg("%s:%d NOT Close ArcPtr from fd %d\n", __FILE__, __LINE__, desc);
> - // fclose(ArcPtr);
> - // lseek(desc, 0, SEEK_SET);
> - // ArcPtr = NULL;
> +/*
> + fclose(ArcPtr);
> + lseek(desc, 0, SEEK_SET);
> + ArcPtr = NULL;
> +*/
> }
> #endif
>
> @@ -1814,66 +1816,66 @@ static void DecodeNumber(struct Decode *
> __asm {
>
> xor eax, eax
> - mov eax, BitField // N=BitField & 0xFFFE;
> + mov eax, BitField /* N=BitField & 0xFFFE; */
> and eax, 0xFFFFFFFE
> mov [N], eax
> - mov edx, [Deco] // EAX=N, EDX=Deco
> + mov edx, [Deco] /* EAX=N, EDX=Deco */
>
> - cmp eax, dword ptr[edx + 8*4 + 4]// if (N<Dec->DecodeLen[8])
> + cmp eax, dword ptr[edx + 8*4 + 4] /* if (N<Dec->DecodeLen[8]) */
> jae else_G
>
> - cmp eax, dword ptr[edx + 4*4 + 4]// if (N<Dec->DecodeLen[4])
> + cmp eax, dword ptr[edx + 4*4 + 4] /* if (N<Dec->DecodeLen[4]) */
> jae else_F
>
>
> - cmp eax, dword ptr[edx + 2*4 + 4]// if (N<Dec->DecodeLen[2])
> + cmp eax, dword ptr[edx + 2*4 + 4] /* if (N<Dec->DecodeLen[2]) */
> jae else_C
>
> - cmp eax, dword ptr[edx + 1*4 + 4]// if (N<Dec->DecodeLen[1])
> + cmp eax, dword ptr[edx + 1*4 + 4] /* if (N<Dec->DecodeLen[1]) */
> jae else_1
> - mov I, 1 // I=1;
> + mov I, 1 /* I=1; */
> jmp next_1
> - else_1: // else
> - mov I, 2 // I=2;
> + else_1: /* else */
> + mov I, 2 /* I=2; */
> next_1:
>
> jmp next_C
> - else_C: // else
> + else_C: /* else */
>
> - cmp eax, dword ptr[edx + 3*4 + 4]// if (N<Dec->DecodeLen[3])
> + cmp eax, dword ptr[edx + 3*4 + 4] /* if (N<Dec->DecodeLen[3]) */
> jae else_2
> - mov I, 3 // I=3;
> + mov I, 3 /* I=3; */
> jmp next_2
> - else_2: // else
> - mov I, 4 // I=4;
> + else_2: /* else */
> + mov I, 4 /* I=4; */
> next_2:
>
> - next_C: // else
> + next_C: /* else */
>
> jmp next_F
> else_F:
>
>
> - cmp eax, dword ptr[edx + 6*4 + 4]// if (N<Dec->DecodeLen[6])
> + cmp eax, dword ptr[edx + 6*4 + 4] /* if (N<Dec->DecodeLen[6]) */
> jae else_E
>
> - cmp eax, dword ptr[edx + 5*4 + 4]// if (N<Dec->DecodeLen[5])
> + cmp eax, dword ptr[edx + 5*4 + 4] /* if (N<Dec->DecodeLen[5]) */
> jae else_3
> - mov I, 5 // I=5;
> + mov I, 5 /* I=5; */
> jmp next_3
> - else_3: // else
> - mov I, 6 // I=6;
> + else_3: /* else */
> + mov I, 6 /* I=6; */
> next_3:
>
> jmp next_E
> - else_E: // else
> + else_E: /* else */
>
> - cmp eax, dword ptr[edx + 7*4 + 4]// if (N<Dec->DecodeLen[7])
> + cmp eax, dword ptr[edx + 7*4 + 4] /* if (N<Dec->DecodeLen[7]) */
> jae else_4
> - mov I, 7 // I=7;
> + mov I, 7 /* I=7; */
> jmp next_4
> - else_4: // else
> - mov I, 8 // I=8;
> + else_4: /* else */
> + mov I, 8 /* I=8; */
> next_4:
>
> next_E:
> @@ -1883,51 +1885,51 @@ static void DecodeNumber(struct Decode *
> jmp next_G
> else_G:
>
> - cmp eax, dword ptr[edx + 12*4 + 4] // if (N<Dec->DecodeLen[12])
> + cmp eax, dword ptr[edx + 12*4 + 4] /* if (N<Dec->DecodeLen[12]) */
> jae else_D
>
> - cmp eax, dword ptr[edx + 10*4 + 4]// if (N<Dec->DecodeLen[10])
> + cmp eax, dword ptr[edx + 10*4 + 4] /* if (N<Dec->DecodeLen[10]) */
> jae else_B
>
> - cmp eax, dword ptr[edx + 9*4 + 4]// if (N<Dec->DecodeLen[9])
> + cmp eax, dword ptr[edx + 9*4 + 4] /* if (N<Dec->DecodeLen[9]) */
> jae else_5
> - mov I, 9 // I=9;
> + mov I, 9 /* I=9; */
> jmp next_5
> - else_5: // else
> - mov I, 10 // I=10;
> + else_5: /* else */
> + mov I, 10 /* I=10; */
> next_5:
>
> jmp next_B
> - else_B: // else
> + else_B: /* else */
>
> - cmp eax, dword ptr[edx + 11*4 + 4]// if (N<Dec->DecodeLen[11])
> + cmp eax, dword ptr[edx + 11*4 + 4] /* if (N<Dec->DecodeLen[11]) */
> jae else_6
> - mov I, 11 // I=11;
> + mov I, 11 /* I=11; */
> jmp next_6
> - else_6: // else
> - mov I, 12 // I=12;
> + else_6: /* else */
> + mov I, 12 /* I=12; */
> next_6:
>
> next_B:
>
>
> jmp next_D
> - else_D: // else
> + else_D: /* else */
>
> - cmp eax, dword ptr[edx + 14*4 + 4]// if (N<Dec->DecodeLen[14])
> + cmp eax, dword ptr[edx + 14*4 + 4] /* if (N<Dec->DecodeLen[14]) */
> jae else_A
>
> - cmp eax, dword ptr[edx + 13*4 + 4]// if (N<Dec->DecodeLen[13])
> + cmp eax, dword ptr[edx + 13*4 + 4] /* if (N<Dec->DecodeLen[13]) */
> jae else_7
> - mov I, 13 // I=13;
> + mov I, 13 /* I=13; */
> jmp next_7
> - else_7: // else
> - mov I, 14 // I=14;
> + else_7: /* else */
> + mov I, 14 /* I=14; */
> next_7:
>
> jmp next_A
> - else_A: // else
> - mov I, 15 // I=15;
> + else_A: /* else */
> + mov I, 15 /* I=15; */
> next_A:
>
> next_D:
> @@ -2546,19 +2548,19 @@ void SetCryptKeys(char *Password)
> mov ebx, Offset SubstTable
> mov edx, ebx
>
> - xor ecx, ecx // read SubstTable[N1]...
> + xor ecx, ecx /* read SubstTable[N1]... */
> mov cl, N1
> add ebx, ecx
> mov al, byte ptr[ebx]
>
> - mov cl, N1 // read SubstTable[(N1+I+K)&0xFF]...
> + mov cl, N1 /* read SubstTable[(N1+I+K)&0xFF]... */
> add ecx, I
> add ecx, K
> and ecx, 0xFF
> add edx, ecx
> mov ah, byte ptr[edx]
>
> - mov byte ptr[ebx], ah // and write back
> + mov byte ptr[ebx], ah /* and write back */
> mov byte ptr[edx], al
>
> }
> diff -urp clamav-0.66/libclamav/zziplib/zzip-dir.c clamav-0.66-juhl/libclamav/zziplib/zzip-dir.c
> --- clamav-0.66/libclamav/zziplib/zzip-dir.c 2004-02-06 03:43:59.000000000 +0100
> +++ clamav-0.66-juhl/libclamav/zziplib/zzip-dir.c 2004-02-15 03:53:15.000000000 +0100
> @@ -27,7 +27,9 @@
> #include <stdio.h>
> #endif
>
> -//#include "__dirent.h"
> +/*
> +#include "__dirent.h"
> +*/
>
> #ifndef offsetof
> #pragma warning had to DEFINE offsetof as it was not in stddef.h
> diff -urp clamav-0.66/libclamav/zziplib/zzip-file.c clamav-0.66-juhl/libclamav/zziplib/zzip-file.c
> --- clamav-0.66/libclamav/zziplib/zzip-file.c 2004-02-06 03:44:34.000000000 +0100
> +++ clamav-0.66-juhl/libclamav/zziplib/zzip-file.c 2004-02-15 03:54:34.000000000 +0100
> @@ -28,7 +28,9 @@
> #include <ctype.h>
>
> #include <zzipformat.h>
> -//#include "__debug.h"
> +/*
> +#include "__debug.h"
> +*/
>
> #if 0
> # if defined ZZIP_HAVE_IO_H
> @@ -175,8 +177,10 @@ zzip_file_open(ZZIP_DIR * dir, zzip_char
> if (n) hdr_name = n + 1;
> }
>
> - //HINT4("name='%s', compr=%d, size=%d\n",
> - // hdr->d_name, hdr->d_compr, hdr->d_usize);
> +/*
> + HINT4("name='%s', compr=%d, size=%d\n",
> + hdr->d_name, hdr->d_compr, hdr->d_usize);
> +*/
>
> if (!cmp(hdr_name, name))
> {
> diff -urp clamav-0.66/libclamav/zziplib/zzip-zip.c clamav-0.66-juhl/libclamav/zziplib/zzip-zip.c
> --- clamav-0.66/libclamav/zziplib/zzip-zip.c 2004-02-06 03:45:05.000000000 +0100
> +++ clamav-0.66-juhl/libclamav/zziplib/zzip-zip.c 2004-02-15 03:57:12.000000000 +0100
> @@ -28,8 +28,10 @@
> #include <sys/stat.h>
> #endif
>
> -//#include "__mmap.h"
> -//#include "__debug.h"
> +/*
> +#include "__mmap.h"
> +#include "__debug.h"
> +*/
>
> #define __sizeof(X) ((zzip_ssize_t)(sizeof(X)))
>
> @@ -94,8 +96,10 @@ _zzip_inline static void __fixup_rootsee
> trailer->z_rootseek[1] = offset >> 8 & 0xff;
> trailer->z_rootseek[2] = offset >> 16 & 0xff;
> trailer->z_rootseek[3] = offset >> 24 & 0xff;
> - //HINT2("new rootseek=%li",
> - // (long) ZZIP_GET32(trailer->z_rootseek));
> +/*
> + HINT2("new rootseek=%li",
> + (long) ZZIP_GET32(trailer->z_rootseek));
> +*/
> }
> }
> #define __correct_rootseek(A,B,C)
> @@ -126,8 +130,10 @@ _zzip_inline static void __debug_dir_hdr
> * (as long as the following assertion holds...)
> */
>
> - //if (((unsigned)hdr)&3)
> - //{ NOTE1("this machine's malloc(3) returns sth. not u32-aligned"); }
> +/*
> + if (((unsigned)hdr)&3)
> + { NOTE1("this machine's malloc(3) returns sth. not u32-aligned"); }
> +*/
> /* we assume that if this machine's malloc has returned a non-aligned
> * memory block, then it is actually safe to access misaligned data, and
> * since it does only affect the first hdr it should not even bring about
> @@ -167,7 +173,7 @@ __zzip_find_disk_trailer(int fd, zzip_of
> #else
> */
> #define return(val) { e=val; goto cleanup; }
> -//#endif
> +/* #endif */
> register int e;
>
> #ifndef _LOWSTK
> @@ -251,8 +257,10 @@ __zzip_find_disk_trailer(int fd, zzip_of
> if (io->read(fd, buf, (zzip_size_t)maplen) < (zzip_ssize_t)maplen)
> { return(ZZIP_DIR_READ); }
> mapped = buf; /* success */
> - //HINT5("offs=$%lx len=%li filesize=%li pagesize=%i",
> - //(long)offset, (long)maplen, (long)filesize, ZZIP_BUFSIZ);
> +/*
> + HINT5("offs=$%lx len=%li filesize=%li pagesize=%i",
> + (long)offset, (long)maplen, (long)filesize, ZZIP_BUFSIZ);
> +*/
> }
>
> {/* now, check for the trailer-magic, hopefully near the end of file */
> @@ -387,9 +395,10 @@ __zzip_parse_root_directory(int fd,
> u_extras = ZZIP_GET16(d->z_extras);
> u_comment = ZZIP_GET16(d->z_comment);
> u_namlen = ZZIP_GET16(d->z_namlen);
> - //HINT5("offset=0x%lx, size %ld, dirent *%p, hdr %p\n",
> - // offset+u_rootseek, (long)u_rootsize, d, hdr);
> -
> +/*
> + HINT5("offset=0x%lx, size %ld, dirent *%p, hdr %p\n",
> + offset+u_rootseek, (long)u_rootsize, d, hdr);
> +*/
> /* writes over the read buffer, Since the structure where data is
> copied is smaller than the data in buffer this can be done.
> It is important that the order of setting the fields is considered
> @@ -420,12 +429,14 @@ __zzip_parse_root_directory(int fd,
> if (offset > (long)u_rootsize)
> { /*FAIL2("%i's end beyond root directory", entries);*/ entries--; break;}
>
> - //HINT5("file %d { compr=%d crc32=$%x offset=%d",
> - // entries, hdr->d_compr, hdr->d_crc32, hdr->d_off);
> - //HINT5("csize=%d usize=%d namlen=%d extras=%d",
> - // hdr->d_csize, hdr->d_usize, u_namlen, u_extras);
> - //HINT5("comment=%d name='%s' %s <sizeof %d> } ",
> - // u_comment, hdr->d_name, "",(int) sizeof(*d));
> +/*
> + HINT5("file %d { compr=%d crc32=$%x offset=%d",
> + entries, hdr->d_compr, hdr->d_crc32, hdr->d_off);
> + HINT5("csize=%d usize=%d namlen=%d extras=%d",
> + hdr->d_csize, hdr->d_usize, u_namlen, u_extras);
> + HINT5("comment=%d name='%s' %s <sizeof %d> } ",
> + u_comment, hdr->d_name, "",(int) sizeof(*d));
> +*/
>
> p_reclen = &hdr->d_reclen;
>
> @@ -599,19 +610,20 @@ __zzip_dir_parse (ZZIP_DIR* dir)
> * { rv = EINVAL; goto error; }
> */
>
> - //HINT2("------------------ fd=%i", (int) dir->fd);
> + /* HINT2("------------------ fd=%i", (int) dir->fd); */
> if ((filesize = dir->io->filesize(dir->fd)) < 0)
> { rv = ZZIP_DIR_STAT; goto error; }
>
> - //HINT2("------------------ filesize=%ld", (long) filesize);
> + /* HINT2("------------------ filesize=%ld", (long) filesize); */
> if ((rv = __zzip_find_disk_trailer(dir->fd, filesize, &trailer,
> dir->io)) != 0)
> { goto error; }
>
> - //HINT5("directory = { entries= %d/%d, size= %d, seek= %d } ",
> - // ZZIP_GET16(trailer.z_entries), ZZIP_GET16(trailer.z_finalentries),
> - // ZZIP_GET32(trailer.z_rootsize), ZZIP_GET32(trailer.z_rootseek));
> -
> +/*
> + HINT5("directory = { entries= %d/%d, size= %d, seek= %d } ",
> + ZZIP_GET16(trailer.z_entries), ZZIP_GET16(trailer.z_finalentries),
> + ZZIP_GET32(trailer.z_rootsize), ZZIP_GET32(trailer.z_rootseek));
> +*/
> if ( (rv = __zzip_parse_root_directory(dir->fd, &trailer, &dir->hdr0,
> dir->io)) != 0)
> { goto error; }
>
>
>
> Kind regards,
>
> Jesper Juhl <juhl [at] dif>
>
>
>
> -------------------------------------------------------
> SF.Net is sponsored by: Speed Start Your Linux Apps Now.
> Build and deploy apps & Web services for Linux with
> a free DVD software kit from IBM. Click Now!
> http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
> _______________________________________________
> Clamav-devel mailing list
> Clamav-devel [at] lists
> https://lists.sourceforge.net/lists/listinfo/clamav-devel
>

ClamAV devel RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.