Formatting touch-up

pull/117/head
Micah Snyder 6 years ago
parent 206dbaefe8
commit 898c08f08b
  1. 15
      .clang-format
  2. 6
      clam-format
  3. 8
      clamd/server-th.c
  4. 24
      clamdscan/clamdscan.c
  5. 22
      clamdtop/clamdtop.c
  6. 30
      clamscan/clamscan.c
  7. 1
      libclamav/crtmgr.c
  8. 6
      libclamav/hashtab.c
  9. 2
      libclamav/macho.c
  10. 6
      libclamav/ole2_extract.c
  11. 2
      libclamav/pdf.c
  12. 2
      libclamav/pe.c
  13. 2
      libclamav/phishcheck.c
  14. 4
      libclamav/sis.c
  15. 4
      libfreshclam/libfreshclam.c

@ -7,11 +7,14 @@ AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: true
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
@ -19,7 +22,8 @@ AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: MultiLine
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
BraceWrapping:
AfterCaseLabel: false
AfterClass: true
AfterControlStatement: false
AfterEnum: false
@ -55,12 +59,12 @@ DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
IncludeCategories:
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
Priority: 2
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
@ -96,6 +100,7 @@ ReflowComments: true
SortIncludes: false
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
@ -111,7 +116,7 @@ SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
StatementMacros:
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 8

@ -31,7 +31,7 @@ clang-format -i -verbose libclamav/jsparse/*.h
clang-format -i -verbose libclamav/lzw/*.c
clang-format -i -verbose libclamav/lzw/*.h
clang-format -i -verbose libclamav/nsis/nulsft.*
clang-format -i -verbose libclamunrar_iface/*.c
clang-format -i -verbose libclamunrar_iface/*.cpp
clang-format -i -verbose libclamunrar_iface/*.h
clang-format -i -verbose libfreshclam/*.c
clang-format -i -verbose libfreshclam/*.h
@ -50,8 +50,6 @@ clang-format -i -verbose win32/compat/*.h
clang-format -i -verbose win32/*.h
# Undo changes to specific files (whitelist)
git checkout clamd/fts.c
git checkout clamd/priv_fts.h
git checkout libclamav/iana_cctld.h
git checkout libclamav/bytecode_api_decl.c
git checkout libclamav/bytecode_api_impl.h
@ -77,3 +75,5 @@ git checkout libclamav/inflate64_priv.h
git checkout shared/queue.h
git checkout clamonacc/c-thread-pool/thpool.c
git checkout clamonacc/c-thread-pool/thpool.h
git checkout clamonacc/misc/fts.c
git checkout clamonacc/misc/priv_fts.h

@ -1074,15 +1074,15 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
logg("HTML support disabled.\n");
}
#ifdef PRELUDE
if (optget(opts, "PreludeEnable")->enabled){
if ((opt = optget(opts, "PreludeAnalyzerName"))->enabled){
#ifdef PRELUDE
if (optget(opts, "PreludeEnable")->enabled) {
if ((opt = optget(opts, "PreludeAnalyzerName"))->enabled) {
prelude_initialize_client(opt->strarg);
} else {
prelude_initialize_client("ClamAV");
}
}
#endif
#endif
if (optget(opts, "ScanXMLDOCS")->enabled) {
logg("XMLDOCS support enabled.\n");

@ -62,7 +62,7 @@ int main(int argc, char **argv)
{
int ds, dms, ret, infected = 0, err = 0;
struct timeval t1, t2;
time_t date_start, date_end;
time_t date_start, date_end;
struct optstruct *opts;
const struct optstruct *opt;
@ -143,7 +143,7 @@ int main(int argc, char **argv)
sigaction(SIGPIPE, &sigact, NULL);
#endif
date_start = time(NULL);
date_start = time(NULL);
gettimeofday(&t1, NULL);
ret = client(opts, &infected, &err);
@ -151,9 +151,9 @@ int main(int argc, char **argv)
/* TODO: Implement STATUS in clamd */
if (!optget(opts, "no-summary")->enabled) {
struct tm tmp;
struct tm tmp;
date_end = time(NULL);
date_end = time(NULL);
gettimeofday(&t2, NULL);
ds = t2.tv_sec - t1.tv_sec;
dms = t2.tv_usec - t1.tv_usec;
@ -172,22 +172,22 @@ int main(int argc, char **argv)
logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms / 1000, ds / 60, ds % 60);
#ifdef _WIN32
if (0 != localtime_s(&tmp, &date_start)) {
if (0 != localtime_s(&tmp, &date_start)) {
#else
if (!localtime_r(&date_start, &tmp)) {
if (!localtime_r(&date_start, &tmp)) {
#endif
logg("!Failed to get local time for Start Date.\n");
}
logg("!Failed to get local time for Start Date.\n");
}
strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
logg("Start Date: %s\n", buffer);
#ifdef _WIN32
if (0 != localtime_s(&tmp, &date_end)) {
if (0 != localtime_s(&tmp, &date_end)) {
#else
if (!localtime_r(&date_end, &tmp)) {
if (!localtime_r(&date_end, &tmp)) {
#endif
logg("!Failed to get local time for End Date.\n");
}
logg("!Failed to get local time for End Date.\n");
}
strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
logg("End Date: %s\n", buffer);
}

@ -417,7 +417,7 @@ static void cleanup(void)
}
rm_windows();
#ifndef _WIN32
endwin();
endwin();
#endif // !_WIN32
}
curses_inited = 0;
@ -425,9 +425,9 @@ static void cleanup(void)
if (global.conn[i].sd && global.conn[i].sd != -1) {
send_string_noreconn(&global.conn[i], "nEND\n");
#ifndef WIN32
close(global.conn[i].sd);
close(global.conn[i].sd);
#else
closesocket(global.conn[i].sd);
closesocket(global.conn[i].sd);
#endif
}
free(global.conn[i].version);
@ -648,7 +648,7 @@ static int make_connection_real(const char *soname, conn_t *conn)
print_con_info(conn, "Connecting to: %s\n", soname);
if (connect(s, (struct sockaddr *)&addr, sizeof(addr))) {
perror("connect");
close(s);
close(s);
return -1;
}
@ -687,7 +687,7 @@ static int make_connection_real(const char *soname, conn_t *conn)
#ifndef WIN32
close(s);
#else
closesocket(s);
closesocket(s);
#endif
continue;
}
@ -768,13 +768,13 @@ static void reconnect(conn_t *conn)
if (++tries > 3) {
EXIT_PROGRAM(RECONNECT_FAIL);
}
if (conn->sd != -1) {
if (conn->sd != -1) {
#ifndef WIN32
close(conn->sd);
close(conn->sd);
#else
closesocket(conn->sd);
closesocket(conn->sd);
#endif
}
}
if (make_connection(conn->remote, conn) < 0) {
print_con_info(conn, "Unable to reconnect to %s: %s", conn->remote, strerror(errno));
EXIT_PROGRAM(RECONNECT_FAIL);
@ -799,9 +799,9 @@ static int recv_line(conn_t *conn, char *buf, size_t len)
/* it could be a timeout, be nice and send an END */
send_string_noreconn(conn, "nEND\n");
#ifndef WIN32
close(conn->sd);
close(conn->sd);
#else
closesocket(conn->sd);
closesocket(conn->sd);
#endif
conn->sd = -1;
return 0;

@ -62,7 +62,7 @@ int main(int argc, char **argv)
int ds, dms, ret;
double mb, rmb;
struct timeval t1, t2;
time_t date_start, date_end;
time_t date_start, date_end;
char buffer[26];
#ifndef _WIN32
@ -157,15 +157,15 @@ int main(int argc, char **argv)
memset(&info, 0, sizeof(struct s_info));
date_start = time(NULL);
date_start = time(NULL);
gettimeofday(&t1, NULL);
ret = scanmanager(opts);
if (!optget(opts, "no-summary")->enabled) {
struct tm tmp;
struct tm tmp;
date_end = time(NULL);
date_end = time(NULL);
gettimeofday(&t2, NULL);
ds = t2.tv_sec - t1.tv_sec;
dms = t2.tv_usec - t1.tv_usec;
@ -192,23 +192,23 @@ int main(int argc, char **argv)
logg("Time: %u.%3.3u sec (%u m %u s)\n", ds, dms / 1000, ds / 60, ds % 60);
#ifdef _WIN32
if (0 != localtime_s(&tmp, &date_start)) {
if (0 != localtime_s(&tmp, &date_start)) {
#else
if (!localtime_r(&date_start, &tmp)) {
if (!localtime_r(&date_start, &tmp)) {
#endif
logg("!Failed to get local time for Start Date.\n");
}
strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
logg("Start Date: %s\n", buffer);
logg("!Failed to get local time for Start Date.\n");
}
strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
logg("Start Date: %s\n", buffer);
#ifdef _WIN32
if (0 != localtime_s(&tmp, &date_end)) {
if (0 != localtime_s(&tmp, &date_end)) {
#else
if (!localtime_r(&date_end, &tmp)) {
if (!localtime_r(&date_end, &tmp)) {
#endif
logg("!Failed to get local time for End Date.\n");
}
strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
logg("!Failed to get local time for End Date.\n");
}
strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
logg("End Date: %s\n", buffer);
}

@ -124,7 +124,6 @@ cli_crt *crtmgr_whitelist_lookup(crtmgr *m, cli_crt *x509, int crb_crts_only)
mp_cmp(&x509->e, &i->e)) {
continue;
}
}
if (!i->ignore_serial) {

@ -709,9 +709,9 @@ void cli_hashset_destroy(struct cli_hashset *hs)
hs->capacity = 0;
}
#define BITMAP_CONTAINS(bmap, val) ((bmap)[(val) >> 5] & ((uint64_t) 1 << ((val)&0x1f)))
#define BITMAP_INSERT(bmap, val) ((bmap)[(val) >> 5] |= ((uint64_t) 1 << ((val)&0x1f)))
#define BITMAP_REMOVE(bmap, val) ((bmap)[(val) >> 5] &= ~((uint64_t) 1 << ((val)&0x1f)))
#define BITMAP_CONTAINS(bmap, val) ((bmap)[(val) >> 5] & ((uint64_t)1 << ((val)&0x1f)))
#define BITMAP_INSERT(bmap, val) ((bmap)[(val) >> 5] |= ((uint64_t)1 << ((val)&0x1f)))
#define BITMAP_REMOVE(bmap, val) ((bmap)[(val) >> 5] &= ~((uint64_t)1 << ((val)&0x1f)))
/*
* searches the hashset for the @key.

@ -407,7 +407,7 @@ int cli_scanmacho(cli_ctx *ctx, struct cli_exe_info *fileinfo)
sections[sect].rva = EC32(section.addr, conv);
sections[sect].vsz = EC32(section.size, conv);
sections[sect].raw = EC32(section.offset, conv);
if ((uint64_t) 1 << EC32(section.align, conv) > INT32_MAX) {
if ((uint64_t)1 << EC32(section.align, conv) > INT32_MAX) {
cli_dbgmsg("cli_scanmacho: Section aligned is malformed\n");
free(sections);
RETURN_BROKEN;

@ -391,9 +391,9 @@ ole2_read_block(ole2_header_t *hdr, void *buff, unsigned int size, int32_t block
return FALSE;
}
/* other methods: (blockno+1) * 512 or (blockno * block_size) + 512; */
if (( (uint64_t) blockno << hdr->log2_big_block_size) < (INT32_MAX - MAX(512, (uint64_t) 1 << hdr->log2_big_block_size) )) {
/* 512 is header size */
offset = (blockno << hdr->log2_big_block_size) + MAX(512, 1 << hdr->log2_big_block_size);
if (((uint64_t)blockno << hdr->log2_big_block_size) < (INT32_MAX - MAX(512, (uint64_t)1 << hdr->log2_big_block_size))) {
/* 512 is header size */
offset = (blockno << hdr->log2_big_block_size) + MAX(512, 1 << hdr->log2_big_block_size);
offend = offset + size;
} else {
offset = INT32_MAX - size;

@ -3118,7 +3118,7 @@ cl_error_t pdf_find_and_parse_objs_in_objstm(struct pdf_struct *pdf, struct objs
if (retval != CL_SUCCESS) {
if (retval != CL_BREAK) {
cli_dbgmsg("pdf_find_and_parse_objs_in_objstm: Fewer objects in stream than expected: %u found, %u expected.\n",
objstm->nobjs_found, objstm->n);
objstm->nobjs_found, objstm->n);
badobjects++;
pdf->stats.ninvalidobjs++;
}

@ -5648,7 +5648,7 @@ cl_error_t cli_check_auth_header(cli_ctx *ctx, struct cli_exe_info *peinfo)
if (at < sec_dir_offset) {
hlen = sec_dir_offset - at;
add_chunk_to_hash_list(at, hlen);
} else if(at > sec_dir_offset) {
} else if (at > sec_dir_offset) {
cli_dbgmsg("cli_check_auth_header: security directory offset appears to overlap with the PE header\n");
goto finish;
}

@ -1493,7 +1493,7 @@ static enum phish_status phishingCheck(const struct cl_engine* engine, struct ur
*/
/* Provide copies of the oirinal URL's, because domainlist_match() may modify the buffer,
and we don't want that to happen in this case. */
realData = cli_strdup(urls->realLink.data);
realData = cli_strdup(urls->realLink.data);
if (!realData) {
cli_errmsg("Phishcheck: Failed to allocate memory for temporary real link string.\n");
return CL_PHISH_CLEAN;

@ -139,7 +139,7 @@ enum {
memcpy(buff, buff + smax - sleft, sleft); \
size_t tmp = fmap_readn(map, buff + sleft, pos, BUFSIZ - sleft); \
smax = tmp; \
if (((size_t) -1) == tmp) { \
if (((size_t)-1) == tmp) { \
cli_dbgmsg("SIS: Read failed during GETD2\n"); \
FREE(alangs); \
FREE(ptrs); \
@ -169,7 +169,7 @@ enum {
} \
pos += (N)-sleft; \
size_t tmp = fmap_readn(map, buff, pos, BUFSIZ); \
if (((size_t) -1) == tmp) { \
if (((size_t)-1) == tmp) { \
cli_dbgmsg("SIS: Read failed during SKIP\n"); \
free(alangs); \
return CL_CLEAN; \

@ -588,8 +588,8 @@ fc_error_t fc_update_database(
fc_error_t status = FC_EARG;
char *dbFilename = NULL;
int signo = 0;
long attempt = 1;
int signo = 0;
long attempt = 1;
uint32_t i;
if ((NULL == database) || (NULL == serverList) || (NULL == bUpdated)) {

Loading…
Cancel
Save