Browse code

Formatting touch-up

Micah Snyder authored on 2020/01/04 05:53:29
Showing 15 changed files
... ...
@@ -7,11 +7,14 @@ AlignConsecutiveDeclarations: false
7 7
 AlignEscapedNewlines: Left
8 8
 AlignOperands:   true
9 9
 AlignTrailingComments: true
10
+AllowAllArgumentsOnNextLine: true
11
+AllowAllConstructorInitializersOnNextLine: true
10 12
 AllowAllParametersOfDeclarationOnNextLine: true
11 13
 AllowShortBlocksOnASingleLine: false
12 14
 AllowShortCaseLabelsOnASingleLine: false
13 15
 AllowShortFunctionsOnASingleLine: Empty
14
-AllowShortIfStatementsOnASingleLine: true
16
+AllowShortLambdasOnASingleLine: All
17
+AllowShortIfStatementsOnASingleLine: WithoutElse
15 18
 AllowShortLoopsOnASingleLine: true
16 19
 AlwaysBreakAfterDefinitionReturnType: None
17 20
 AlwaysBreakAfterReturnType: None
... ...
@@ -19,7 +22,8 @@ AlwaysBreakBeforeMultilineStrings: false
19 19
 AlwaysBreakTemplateDeclarations: MultiLine
20 20
 BinPackArguments: true
21 21
 BinPackParameters: true
22
-BraceWrapping:
22
+BraceWrapping:   
23
+  AfterCaseLabel:  false
23 24
   AfterClass:      true
24 25
   AfterControlStatement: false
25 26
   AfterEnum:       false
... ...
@@ -55,12 +59,12 @@ DerivePointerAlignment: true
55 55
 DisableFormat:   false
56 56
 ExperimentalAutoDetectBinPacking: false
57 57
 FixNamespaceComments: true
58
-ForEachMacros:
58
+ForEachMacros:   
59 59
   - foreach
60 60
   - Q_FOREACH
61 61
   - BOOST_FOREACH
62 62
 IncludeBlocks:   Preserve
63
-IncludeCategories:
63
+IncludeCategories: 
64 64
   - Regex:           '^"(llvm|llvm-c|clang|clang-c)/'
65 65
     Priority:        2
66 66
   - Regex:           '^(<|"(gtest|gmock|isl|json)/)'
... ...
@@ -96,6 +100,7 @@ ReflowComments:  true
96 96
 SortIncludes:    false
97 97
 SortUsingDeclarations: true
98 98
 SpaceAfterCStyleCast: false
99
+SpaceAfterLogicalNot: false
99 100
 SpaceAfterTemplateKeyword: true
100 101
 SpaceBeforeAssignmentOperators: true
101 102
 SpaceBeforeCpp11BracedList: false
... ...
@@ -111,7 +116,7 @@ SpacesInCStyleCastParentheses: false
111 111
 SpacesInParentheses: false
112 112
 SpacesInSquareBrackets: false
113 113
 Standard:        Cpp11
114
-StatementMacros:
114
+StatementMacros: 
115 115
   - Q_UNUSED
116 116
   - QT_REQUIRE_VERSION
117 117
 TabWidth:        8
... ...
@@ -31,7 +31,7 @@ clang-format -i -verbose libclamav/jsparse/*.h
31 31
 clang-format -i -verbose libclamav/lzw/*.c
32 32
 clang-format -i -verbose libclamav/lzw/*.h
33 33
 clang-format -i -verbose libclamav/nsis/nulsft.*
34
-clang-format -i -verbose libclamunrar_iface/*.c
34
+clang-format -i -verbose libclamunrar_iface/*.cpp
35 35
 clang-format -i -verbose libclamunrar_iface/*.h
36 36
 clang-format -i -verbose libfreshclam/*.c
37 37
 clang-format -i -verbose libfreshclam/*.h
... ...
@@ -50,8 +50,6 @@ clang-format -i -verbose win32/compat/*.h
50 50
 clang-format -i -verbose win32/*.h
51 51
 
52 52
 # Undo changes to specific files (whitelist)
53
-git checkout clamd/fts.c
54
-git checkout clamd/priv_fts.h
55 53
 git checkout libclamav/iana_cctld.h
56 54
 git checkout libclamav/bytecode_api_decl.c
57 55
 git checkout libclamav/bytecode_api_impl.h
... ...
@@ -77,3 +75,5 @@ git checkout libclamav/inflate64_priv.h
77 77
 git checkout shared/queue.h
78 78
 git checkout clamonacc/c-thread-pool/thpool.c
79 79
 git checkout clamonacc/c-thread-pool/thpool.h
80
+git checkout clamonacc/misc/fts.c
81
+git checkout clamonacc/misc/priv_fts.h
... ...
@@ -1074,15 +1074,15 @@ int recvloop_th(int *socketds, unsigned nsockets, struct cl_engine *engine, unsi
1074 1074
         logg("HTML support disabled.\n");
1075 1075
     }
1076 1076
 
1077
-    #ifdef PRELUDE
1078
-    if (optget(opts, "PreludeEnable")->enabled){
1079
-        if ((opt = optget(opts, "PreludeAnalyzerName"))->enabled){
1077
+#ifdef PRELUDE
1078
+    if (optget(opts, "PreludeEnable")->enabled) {
1079
+        if ((opt = optget(opts, "PreludeAnalyzerName"))->enabled) {
1080 1080
             prelude_initialize_client(opt->strarg);
1081 1081
         } else {
1082 1082
             prelude_initialize_client("ClamAV");
1083 1083
         }
1084 1084
     }
1085
-    #endif
1085
+#endif
1086 1086
 
1087 1087
     if (optget(opts, "ScanXMLDOCS")->enabled) {
1088 1088
         logg("XMLDOCS support enabled.\n");
... ...
@@ -62,7 +62,7 @@ int main(int argc, char **argv)
62 62
 {
63 63
     int ds, dms, ret, infected = 0, err = 0;
64 64
     struct timeval t1, t2;
65
-	time_t date_start, date_end;
65
+    time_t date_start, date_end;
66 66
 
67 67
     struct optstruct *opts;
68 68
     const struct optstruct *opt;
... ...
@@ -143,7 +143,7 @@ int main(int argc, char **argv)
143 143
     sigaction(SIGPIPE, &sigact, NULL);
144 144
 #endif
145 145
 
146
-	date_start = time(NULL);
146
+    date_start = time(NULL);
147 147
     gettimeofday(&t1, NULL);
148 148
 
149 149
     ret = client(opts, &infected, &err);
... ...
@@ -151,9 +151,9 @@ int main(int argc, char **argv)
151 151
 
152 152
     /* TODO: Implement STATUS in clamd */
153 153
     if (!optget(opts, "no-summary")->enabled) {
154
-		struct tm tmp;
154
+        struct tm tmp;
155 155
 
156
-		date_end = time(NULL);
156
+        date_end = time(NULL);
157 157
         gettimeofday(&t2, NULL);
158 158
         ds  = t2.tv_sec - t1.tv_sec;
159 159
         dms = t2.tv_usec - t1.tv_usec;
... ...
@@ -172,22 +172,22 @@ int main(int argc, char **argv)
172 172
         logg("Time: %d.%3.3d sec (%d m %d s)\n", ds, dms / 1000, ds / 60, ds % 60);
173 173
 
174 174
 #ifdef _WIN32
175
-		if (0 != localtime_s(&tmp, &date_start)) {
175
+        if (0 != localtime_s(&tmp, &date_start)) {
176 176
 #else
177
-		if (!localtime_r(&date_start, &tmp)) {
177
+        if (!localtime_r(&date_start, &tmp)) {
178 178
 #endif
179
-			logg("!Failed to get local time for Start Date.\n");
180
-		}
179
+            logg("!Failed to get local time for Start Date.\n");
180
+        }
181 181
         strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
182 182
         logg("Start Date: %s\n", buffer);
183 183
 
184 184
 #ifdef _WIN32
185
-		if (0 != localtime_s(&tmp, &date_end)) {
185
+        if (0 != localtime_s(&tmp, &date_end)) {
186 186
 #else
187
-		if (!localtime_r(&date_end, &tmp)) {
187
+        if (!localtime_r(&date_end, &tmp)) {
188 188
 #endif
189
-			logg("!Failed to get local time for End Date.\n");
190
-		}
189
+            logg("!Failed to get local time for End Date.\n");
190
+        }
191 191
         strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
192 192
         logg("End Date:   %s\n", buffer);
193 193
     }
... ...
@@ -417,7 +417,7 @@ static void cleanup(void)
417 417
         }
418 418
         rm_windows();
419 419
 #ifndef _WIN32
420
-		endwin();
420
+        endwin();
421 421
 #endif // !_WIN32
422 422
     }
423 423
     curses_inited = 0;
... ...
@@ -425,9 +425,9 @@ static void cleanup(void)
425 425
         if (global.conn[i].sd && global.conn[i].sd != -1) {
426 426
             send_string_noreconn(&global.conn[i], "nEND\n");
427 427
 #ifndef WIN32
428
-			close(global.conn[i].sd);
428
+            close(global.conn[i].sd);
429 429
 #else
430
-			closesocket(global.conn[i].sd);
430
+            closesocket(global.conn[i].sd);
431 431
 #endif
432 432
         }
433 433
         free(global.conn[i].version);
... ...
@@ -648,7 +648,7 @@ static int make_connection_real(const char *soname, conn_t *conn)
648 648
         print_con_info(conn, "Connecting to: %s\n", soname);
649 649
         if (connect(s, (struct sockaddr *)&addr, sizeof(addr))) {
650 650
             perror("connect");
651
-			close(s);
651
+            close(s);
652 652
             return -1;
653 653
         }
654 654
 
... ...
@@ -687,7 +687,7 @@ static int make_connection_real(const char *soname, conn_t *conn)
687 687
 #ifndef WIN32
688 688
             close(s);
689 689
 #else
690
-			closesocket(s);
690
+            closesocket(s);
691 691
 #endif
692 692
             continue;
693 693
         }
... ...
@@ -768,13 +768,13 @@ static void reconnect(conn_t *conn)
768 768
     if (++tries > 3) {
769 769
         EXIT_PROGRAM(RECONNECT_FAIL);
770 770
     }
771
-	if (conn->sd != -1) {
771
+    if (conn->sd != -1) {
772 772
 #ifndef WIN32
773
-		close(conn->sd);
773
+        close(conn->sd);
774 774
 #else
775
-		closesocket(conn->sd);
775
+        closesocket(conn->sd);
776 776
 #endif
777
-	}
777
+    }
778 778
     if (make_connection(conn->remote, conn) < 0) {
779 779
         print_con_info(conn, "Unable to reconnect to %s: %s", conn->remote, strerror(errno));
780 780
         EXIT_PROGRAM(RECONNECT_FAIL);
... ...
@@ -799,9 +799,9 @@ static int recv_line(conn_t *conn, char *buf, size_t len)
799 799
             /* it could be a timeout, be nice and send an END */
800 800
             send_string_noreconn(conn, "nEND\n");
801 801
 #ifndef WIN32
802
-			close(conn->sd);
802
+            close(conn->sd);
803 803
 #else
804
-			closesocket(conn->sd);
804
+            closesocket(conn->sd);
805 805
 #endif
806 806
             conn->sd = -1;
807 807
             return 0;
... ...
@@ -62,7 +62,7 @@ int main(int argc, char **argv)
62 62
     int ds, dms, ret;
63 63
     double mb, rmb;
64 64
     struct timeval t1, t2;
65
-	time_t date_start, date_end;
65
+    time_t date_start, date_end;
66 66
 
67 67
     char buffer[26];
68 68
 #ifndef _WIN32
... ...
@@ -157,15 +157,15 @@ int main(int argc, char **argv)
157 157
 
158 158
     memset(&info, 0, sizeof(struct s_info));
159 159
 
160
-	date_start = time(NULL);
160
+    date_start = time(NULL);
161 161
     gettimeofday(&t1, NULL);
162 162
 
163 163
     ret = scanmanager(opts);
164 164
 
165 165
     if (!optget(opts, "no-summary")->enabled) {
166
-		struct tm tmp;
166
+        struct tm tmp;
167 167
 
168
-		date_end = time(NULL);
168
+        date_end = time(NULL);
169 169
         gettimeofday(&t2, NULL);
170 170
         ds  = t2.tv_sec - t1.tv_sec;
171 171
         dms = t2.tv_usec - t1.tv_usec;
... ...
@@ -192,23 +192,23 @@ int main(int argc, char **argv)
192 192
         logg("Time: %u.%3.3u sec (%u m %u s)\n", ds, dms / 1000, ds / 60, ds % 60);
193 193
 
194 194
 #ifdef _WIN32
195
-		if (0 != localtime_s(&tmp, &date_start)) {
195
+        if (0 != localtime_s(&tmp, &date_start)) {
196 196
 #else
197
-		if (!localtime_r(&date_start, &tmp)) {
197
+        if (!localtime_r(&date_start, &tmp)) {
198 198
 #endif
199
-			logg("!Failed to get local time for Start Date.\n");
200
-		}
201
-		strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
202
-		logg("Start Date: %s\n", buffer);
199
+            logg("!Failed to get local time for Start Date.\n");
200
+        }
201
+        strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
202
+        logg("Start Date: %s\n", buffer);
203 203
 
204 204
 #ifdef _WIN32
205
-		if (0 != localtime_s(&tmp, &date_end)) {
205
+        if (0 != localtime_s(&tmp, &date_end)) {
206 206
 #else
207
-		if (!localtime_r(&date_end, &tmp)) {
207
+        if (!localtime_r(&date_end, &tmp)) {
208 208
 #endif
209
-			logg("!Failed to get local time for End Date.\n");
210
-		}
211
-		strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
209
+            logg("!Failed to get local time for End Date.\n");
210
+        }
211
+        strftime(buffer, sizeof(buffer), "%Y:%m:%d %H:%M:%S", &tmp);
212 212
         logg("End Date:   %s\n", buffer);
213 213
     }
214 214
 
... ...
@@ -124,7 +124,6 @@ cli_crt *crtmgr_whitelist_lookup(crtmgr *m, cli_crt *x509, int crb_crts_only)
124 124
                 mp_cmp(&x509->e, &i->e)) {
125 125
                 continue;
126 126
             }
127
-
128 127
         }
129 128
 
130 129
         if (!i->ignore_serial) {
... ...
@@ -709,9 +709,9 @@ void cli_hashset_destroy(struct cli_hashset *hs)
709 709
     hs->capacity          = 0;
710 710
 }
711 711
 
712
-#define BITMAP_CONTAINS(bmap, val) ((bmap)[(val) >> 5] & ((uint64_t) 1 << ((val)&0x1f)))
713
-#define BITMAP_INSERT(bmap, val) ((bmap)[(val) >> 5] |= ((uint64_t) 1 << ((val)&0x1f)))
714
-#define BITMAP_REMOVE(bmap, val) ((bmap)[(val) >> 5] &= ~((uint64_t) 1 << ((val)&0x1f)))
712
+#define BITMAP_CONTAINS(bmap, val) ((bmap)[(val) >> 5] & ((uint64_t)1 << ((val)&0x1f)))
713
+#define BITMAP_INSERT(bmap, val) ((bmap)[(val) >> 5] |= ((uint64_t)1 << ((val)&0x1f)))
714
+#define BITMAP_REMOVE(bmap, val) ((bmap)[(val) >> 5] &= ~((uint64_t)1 << ((val)&0x1f)))
715 715
 
716 716
 /*
717 717
  * searches the hashset for the @key.
... ...
@@ -407,7 +407,7 @@ int cli_scanmacho(cli_ctx *ctx, struct cli_exe_info *fileinfo)
407 407
                     sections[sect].rva = EC32(section.addr, conv);
408 408
                     sections[sect].vsz = EC32(section.size, conv);
409 409
                     sections[sect].raw = EC32(section.offset, conv);
410
-                    if ((uint64_t) 1 << EC32(section.align, conv) > INT32_MAX) {
410
+                    if ((uint64_t)1 << EC32(section.align, conv) > INT32_MAX) {
411 411
                         cli_dbgmsg("cli_scanmacho: Section aligned is malformed\n");
412 412
                         free(sections);
413 413
                         RETURN_BROKEN;
... ...
@@ -391,9 +391,9 @@ ole2_read_block(ole2_header_t *hdr, void *buff, unsigned int size, int32_t block
391 391
         return FALSE;
392 392
     }
393 393
     /* other methods: (blockno+1) * 512 or (blockno * block_size) + 512; */
394
-    if (( (uint64_t) blockno << hdr->log2_big_block_size) < (INT32_MAX - MAX(512, (uint64_t) 1 << hdr->log2_big_block_size) )) {
395
-	/* 512 is header size */
396
-	offset = (blockno << hdr->log2_big_block_size) + MAX(512, 1 << hdr->log2_big_block_size);
394
+    if (((uint64_t)blockno << hdr->log2_big_block_size) < (INT32_MAX - MAX(512, (uint64_t)1 << hdr->log2_big_block_size))) {
395
+        /* 512 is header size */
396
+        offset = (blockno << hdr->log2_big_block_size) + MAX(512, 1 << hdr->log2_big_block_size);
397 397
         offend = offset + size;
398 398
     } else {
399 399
         offset = INT32_MAX - size;
... ...
@@ -3118,7 +3118,7 @@ cl_error_t pdf_find_and_parse_objs_in_objstm(struct pdf_struct *pdf, struct objs
3118 3118
         if (retval != CL_SUCCESS) {
3119 3119
             if (retval != CL_BREAK) {
3120 3120
                 cli_dbgmsg("pdf_find_and_parse_objs_in_objstm: Fewer objects in stream than expected: %u found, %u expected.\n",
3121
-                        objstm->nobjs_found, objstm->n);
3121
+                           objstm->nobjs_found, objstm->n);
3122 3122
                 badobjects++;
3123 3123
                 pdf->stats.ninvalidobjs++;
3124 3124
             }
... ...
@@ -5648,7 +5648,7 @@ cl_error_t cli_check_auth_header(cli_ctx *ctx, struct cli_exe_info *peinfo)
5648 5648
         if (at < sec_dir_offset) {
5649 5649
             hlen = sec_dir_offset - at;
5650 5650
             add_chunk_to_hash_list(at, hlen);
5651
-        } else if(at > sec_dir_offset) {
5651
+        } else if (at > sec_dir_offset) {
5652 5652
             cli_dbgmsg("cli_check_auth_header: security directory offset appears to overlap with the PE header\n");
5653 5653
             goto finish;
5654 5654
         }
... ...
@@ -1493,7 +1493,7 @@ static enum phish_status phishingCheck(const struct cl_engine* engine, struct ur
1493 1493
      */
1494 1494
     /* Provide copies of the oirinal URL's, because domainlist_match() may modify the buffer,
1495 1495
        and we don't want that to happen in this case. */
1496
-    realData    = cli_strdup(urls->realLink.data);
1496
+    realData = cli_strdup(urls->realLink.data);
1497 1497
     if (!realData) {
1498 1498
         cli_errmsg("Phishcheck: Failed to allocate memory for temporary real link string.\n");
1499 1499
         return CL_PHISH_CLEAN;
... ...
@@ -139,7 +139,7 @@ enum {
139 139
             memcpy(buff, buff + smax - sleft, sleft);                        \
140 140
             size_t tmp = fmap_readn(map, buff + sleft, pos, BUFSIZ - sleft); \
141 141
             smax       = tmp;                                                \
142
-            if (((size_t) -1) == tmp) {                                                 \
142
+            if (((size_t)-1) == tmp) {                                       \
143 143
                 cli_dbgmsg("SIS: Read failed during GETD2\n");               \
144 144
                 FREE(alangs);                                                \
145 145
                 FREE(ptrs);                                                  \
... ...
@@ -169,7 +169,7 @@ enum {
169 169
         }                                                       \
170 170
         pos += (N)-sleft;                                       \
171 171
         size_t tmp = fmap_readn(map, buff, pos, BUFSIZ);        \
172
-        if (((size_t) -1) == tmp) {                                        \
172
+        if (((size_t)-1) == tmp) {                              \
173 173
             cli_dbgmsg("SIS: Read failed during SKIP\n");       \
174 174
             free(alangs);                                       \
175 175
             return CL_CLEAN;                                    \
... ...
@@ -588,8 +588,8 @@ fc_error_t fc_update_database(
588 588
     fc_error_t status = FC_EARG;
589 589
 
590 590
     char *dbFilename = NULL;
591
-    int signo    = 0;
592
-    long attempt = 1;
591
+    int signo        = 0;
592
+    long attempt     = 1;
593 593
     uint32_t i;
594 594
 
595 595
     if ((NULL == database) || (NULL == serverList) || (NULL == bUpdated)) {