Skip to content

Commit 70d078d

Browse files
committed
Clang-format and Rust format fixup
1 parent 048eed5 commit 70d078d

File tree

10 files changed

+32
-20
lines changed

10 files changed

+32
-20
lines changed

clamd/clamd.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ int main(int argc, char **argv)
172172
pid_t mainpid = 0;
173173
mode_t old_umask = 0;
174174
const char *user_name = NULL;
175-
char *cvdcertsdir = NULL;
175+
char *cvdcertsdir = NULL;
176176
STATBUF statbuf;
177177

178178
if (check_flevel())
@@ -597,9 +597,9 @@ int main(int argc, char **argv)
597597
// (which would've used the env var or hardcoded path)
598598
if (LSTAT(cvdcertsdir, &statbuf) == -1) {
599599
logg(LOGG_ERROR,
600-
"ClamAV CA certificates directory is missing: %s\n"
601-
"It should have been provided as a part of installation.",
602-
cvdcertsdir);
600+
"ClamAV CA certificates directory is missing: %s\n"
601+
"It should have been provided as a part of installation.",
602+
cvdcertsdir);
603603
ret = 1;
604604
break;
605605
}

clamscan/manager.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,9 +1258,9 @@ int scanmanager(const struct optstruct *opts)
12581258
// (which would've used the env var or hardcoded path)
12591259
if (LSTAT(cvdcertsdir, &statbuf) == -1) {
12601260
logg(LOGG_ERROR,
1261-
"ClamAV CA certificates directory is missing: %s\n"
1262-
"It should have been provided as a part of installation.",
1263-
cvdcertsdir);
1261+
"ClamAV CA certificates directory is missing: %s\n"
1262+
"It should have been provided as a part of installation.",
1263+
cvdcertsdir);
12641264
ret = 2;
12651265
goto done;
12661266
}

libclamav/cvd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ struct cl_cvd *cl_cvdhead(const char *file)
373373
if ((pt = strpbrk(head, "\n\r")))
374374
*pt = 0;
375375

376-
for (i = bread - 1; i > 0 && (head[i] == ' ' || head[i] == '\n' || head[i] == '\r'); head[i] = 0, i--);
376+
for (i = bread - 1; i > 0 && (head[i] == ' ' || head[i] == '\n' || head[i] == '\r'); head[i] = 0, i--)
377+
;
377378

378379
return cl_cvdparse(head);
379380
}

libclamav/others.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ struct cl_engine {
321321
uint32_t ac_mindepth;
322322
uint32_t ac_maxdepth;
323323
char *tmpdir;
324-
char* certs_directory;
324+
char *certs_directory;
325325
uint32_t keeptmp;
326326
uint64_t engine_options;
327327
uint32_t cache_size;

libclamav_rust/build.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@ const BINDGEN_FUNCTIONS: &[&str] = &[
6060
];
6161

6262
// Generate bindings for these types (structs, enums):
63-
const BINDGEN_TYPES: &[&str] = &["cli_matcher", "cli_ac_data", "cli_ac_result", "onedump_t", "cvd_t"];
63+
const BINDGEN_TYPES: &[&str] = &[
64+
"cli_matcher",
65+
"cli_ac_data",
66+
"cli_ac_result",
67+
"onedump_t",
68+
"cvd_t",
69+
];
6470

6571
// Find the required functions and types in these headers:
6672
const BINDGEN_HEADERS: &[&str] = &[

libclamav_rust/src/cdiff.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@
1919
*/
2020

2121
use std::{
22-
collections::BTreeMap, ffi::{c_void, CStr, CString}, fs::{self, File, OpenOptions}, io::{prelude::*, BufReader, BufWriter, Read, Seek, SeekFrom, Write}, iter::*, mem::ManuallyDrop, os::raw::c_char, path::{Path, PathBuf}, str::{self, FromStr}
22+
collections::BTreeMap,
23+
ffi::{c_void, CStr, CString},
24+
fs::{self, File, OpenOptions},
25+
io::{prelude::*, BufReader, BufWriter, Read, Seek, SeekFrom, Write},
26+
iter::*,
27+
mem::ManuallyDrop,
28+
os::raw::c_char,
29+
path::{Path, PathBuf},
30+
str::{self, FromStr},
2331
};
2432

2533
use crate::{

libclamav_rust/src/ffi_util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use std::{
2626
os::raw::c_char,
2727
};
2828

29-
use log::{warn};
29+
use log::warn;
3030

3131
/// Wraps a call to a "result-returning function", allowing it to specify an
3232
/// error receiver and (optionally) result receiver.
@@ -426,7 +426,7 @@ macro_rules! validate_str_param_null {
426426
///
427427
/// The CString pointer must be valid
428428
/// The CString pointer must not be used after calling this function
429-
#[export_name = "ffi_cstring_free"]
429+
#[export_name = "ffi_cstring_free"]
430430
pub unsafe extern "C" fn ffi_cstring_free(cstring: *mut c_char) {
431431
if cstring.is_null() {
432432
warn!("Attempted to free a NULL CString pointer. Please report this at:: https://github.com/Cisco-Talos/clamav/issues");

libclamav_rust/src/fuzzy_hash.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ pub unsafe extern "C" fn _fuzzy_hash_load_subsignature(
181181
subsig_id: u32,
182182
err: *mut *mut FFIError,
183183
) -> bool {
184-
let hexsig = validate_str_param!(hexsig, err=err);
184+
let hexsig = validate_str_param!(hexsig, err = err);
185185

186186
let mut hashmap = ManuallyDrop::new(Box::from_raw(fuzzy_hashmap as *mut FuzzyHashMap));
187187

libclamav_rust/src/util.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,7 @@ pub unsafe fn scan_archive_metadata(
145145
///
146146
/// No parameters may be NULL.
147147
#[export_name = "glob_rm"]
148-
pub unsafe extern "C" fn glob_rm(
149-
glob_str: *const c_char,
150-
err: *mut *mut FFIError,
151-
) -> bool {
148+
pub unsafe extern "C" fn glob_rm(glob_str: *const c_char, err: *mut *mut FFIError) -> bool {
152149
let glob_str = validate_str_param!(glob_str);
153150

154151
for entry in glob(glob_str).expect("Failed to read glob pattern") {

unit_tests/check_clamav.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ START_TEST(test_cl_load)
416416
struct cl_engine *engine;
417417
unsigned int sigs = 0;
418418
const char *testfile;
419-
const char* cvdcertsdir;
419+
const char *cvdcertsdir;
420420

421421
ret = cl_init(CL_INIT_DEFAULT);
422422
ck_assert_msg(ret == CL_SUCCESS, "cl_init failed: %s", cl_strerror(ret));
@@ -443,7 +443,7 @@ START_TEST(test_cl_cvdverify)
443443
FILE *orig_fs;
444444
FILE *new_fs;
445445
char cvd_bytes[5000];
446-
const char* cvdcertsdir;
446+
const char *cvdcertsdir;
447447

448448
cvdcertsdir = getenv("CVD_CERTS_DIR");
449449
ck_assert_msg(cvdcertsdir != NULL, "CVD_CERTS_DIR not set");

0 commit comments

Comments
 (0)