Skip to content

Commit

Permalink
Clang-format and Rust format fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
micahsnyder committed Jan 14, 2025
1 parent 048eed5 commit 70d078d
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 20 deletions.
8 changes: 4 additions & 4 deletions clamd/clamd.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ int main(int argc, char **argv)
pid_t mainpid = 0;
mode_t old_umask = 0;
const char *user_name = NULL;
char *cvdcertsdir = NULL;
char *cvdcertsdir = NULL;
STATBUF statbuf;

if (check_flevel())
Expand Down Expand Up @@ -597,9 +597,9 @@ int main(int argc, char **argv)
// (which would've used the env var or hardcoded path)
if (LSTAT(cvdcertsdir, &statbuf) == -1) {
logg(LOGG_ERROR,
"ClamAV CA certificates directory is missing: %s\n"
"It should have been provided as a part of installation.",
cvdcertsdir);
"ClamAV CA certificates directory is missing: %s\n"
"It should have been provided as a part of installation.",
cvdcertsdir);
ret = 1;
break;
}
Expand Down
6 changes: 3 additions & 3 deletions clamscan/manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1258,9 +1258,9 @@ int scanmanager(const struct optstruct *opts)
// (which would've used the env var or hardcoded path)
if (LSTAT(cvdcertsdir, &statbuf) == -1) {
logg(LOGG_ERROR,
"ClamAV CA certificates directory is missing: %s\n"
"It should have been provided as a part of installation.",
cvdcertsdir);
"ClamAV CA certificates directory is missing: %s\n"
"It should have been provided as a part of installation.",
cvdcertsdir);
ret = 2;
goto done;
}
Expand Down
3 changes: 2 additions & 1 deletion libclamav/cvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ struct cl_cvd *cl_cvdhead(const char *file)
if ((pt = strpbrk(head, "\n\r")))
*pt = 0;

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

return cl_cvdparse(head);
}
Expand Down
2 changes: 1 addition & 1 deletion libclamav/others.h
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ struct cl_engine {
uint32_t ac_mindepth;
uint32_t ac_maxdepth;
char *tmpdir;
char* certs_directory;
char *certs_directory;
uint32_t keeptmp;
uint64_t engine_options;
uint32_t cache_size;
Expand Down
8 changes: 7 additions & 1 deletion libclamav_rust/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ const BINDGEN_FUNCTIONS: &[&str] = &[
];

// Generate bindings for these types (structs, enums):
const BINDGEN_TYPES: &[&str] = &["cli_matcher", "cli_ac_data", "cli_ac_result", "onedump_t", "cvd_t"];
const BINDGEN_TYPES: &[&str] = &[
"cli_matcher",
"cli_ac_data",
"cli_ac_result",
"onedump_t",
"cvd_t",
];

// Find the required functions and types in these headers:
const BINDGEN_HEADERS: &[&str] = &[
Expand Down
10 changes: 9 additions & 1 deletion libclamav_rust/src/cdiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,15 @@
*/

use std::{
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}
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},
};

use crate::{
Expand Down
4 changes: 2 additions & 2 deletions libclamav_rust/src/ffi_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use std::{
os::raw::c_char,
};

use log::{warn};
use log::warn;

/// Wraps a call to a "result-returning function", allowing it to specify an
/// error receiver and (optionally) result receiver.
Expand Down Expand Up @@ -426,7 +426,7 @@ macro_rules! validate_str_param_null {
///
/// The CString pointer must be valid
/// The CString pointer must not be used after calling this function
#[export_name = "ffi_cstring_free"]
#[export_name = "ffi_cstring_free"]
pub unsafe extern "C" fn ffi_cstring_free(cstring: *mut c_char) {
if cstring.is_null() {
warn!("Attempted to free a NULL CString pointer. Please report this at:: https://github.com/Cisco-Talos/clamav/issues");
Expand Down
2 changes: 1 addition & 1 deletion libclamav_rust/src/fuzzy_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub unsafe extern "C" fn _fuzzy_hash_load_subsignature(
subsig_id: u32,
err: *mut *mut FFIError,
) -> bool {
let hexsig = validate_str_param!(hexsig, err=err);
let hexsig = validate_str_param!(hexsig, err = err);

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

Expand Down
5 changes: 1 addition & 4 deletions libclamav_rust/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,7 @@ pub unsafe fn scan_archive_metadata(
///
/// No parameters may be NULL.
#[export_name = "glob_rm"]
pub unsafe extern "C" fn glob_rm(
glob_str: *const c_char,
err: *mut *mut FFIError,
) -> bool {
pub unsafe extern "C" fn glob_rm(glob_str: *const c_char, err: *mut *mut FFIError) -> bool {
let glob_str = validate_str_param!(glob_str);

for entry in glob(glob_str).expect("Failed to read glob pattern") {
Expand Down
4 changes: 2 additions & 2 deletions unit_tests/check_clamav.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ START_TEST(test_cl_load)
struct cl_engine *engine;
unsigned int sigs = 0;
const char *testfile;
const char* cvdcertsdir;
const char *cvdcertsdir;

ret = cl_init(CL_INIT_DEFAULT);
ck_assert_msg(ret == CL_SUCCESS, "cl_init failed: %s", cl_strerror(ret));
Expand All @@ -443,7 +443,7 @@ START_TEST(test_cl_cvdverify)
FILE *orig_fs;
FILE *new_fs;
char cvd_bytes[5000];
const char* cvdcertsdir;
const char *cvdcertsdir;

cvdcertsdir = getenv("CVD_CERTS_DIR");
ck_assert_msg(cvdcertsdir != NULL, "CVD_CERTS_DIR not set");
Expand Down

0 comments on commit 70d078d

Please sign in to comment.