mirror of
https://github.com/mbilker/vgpu_unlock-rs.git
synced 2025-06-08 13:28:23 +02:00
Move main macro body one indentation level out
This commit is contained in:
parent
4a73f9376d
commit
e121e65859
93
src/lib.rs
93
src/lib.rs
@ -314,61 +314,66 @@ fn apply_profile_override(config: &mut VgpuConfig) -> bool {
|
|||||||
let gpu_type = config.gpu_type;
|
let gpu_type = config.gpu_type;
|
||||||
|
|
||||||
macro_rules! handle_copy_overrides {
|
macro_rules! handle_copy_overrides {
|
||||||
|
($field:ident) => {
|
||||||
|
if let Some(value) = config_override.$field {
|
||||||
|
info!(
|
||||||
|
"Patching nvidia-{}/{}: {} -> {}",
|
||||||
|
gpu_type,
|
||||||
|
stringify!($field),
|
||||||
|
config.$field,
|
||||||
|
value
|
||||||
|
);
|
||||||
|
|
||||||
|
config.$field = value;
|
||||||
|
}
|
||||||
|
};
|
||||||
($($field:ident),*$(,)?) => {
|
($($field:ident),*$(,)?) => {
|
||||||
$(
|
$(
|
||||||
if let Some(value) = config_override.$field {
|
handle_copy_overrides!($field);
|
||||||
info!(
|
|
||||||
"Patching nvidia-{}/{}: {} -> {}",
|
|
||||||
gpu_type,
|
|
||||||
stringify!($field),
|
|
||||||
config.$field,
|
|
||||||
value
|
|
||||||
);
|
|
||||||
|
|
||||||
config.$field = value;
|
|
||||||
}
|
|
||||||
)*
|
)*
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
macro_rules! handle_str_overrides {
|
macro_rules! handle_str_overrides {
|
||||||
|
($field:ident) => {
|
||||||
|
if let Some(value) = config_override.$field {
|
||||||
|
let value_bytes = value.as_bytes();
|
||||||
|
|
||||||
|
// Use `len - 1` to account for the required NULL terminator.
|
||||||
|
if value_bytes.len() > config.$field.len() - 1 {
|
||||||
|
error!(
|
||||||
|
"Patching nvidia-{}/{}: value '{}' is too long",
|
||||||
|
gpu_type,
|
||||||
|
stringify!($field),
|
||||||
|
value
|
||||||
|
);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
info!(
|
||||||
|
"Patching nvidia-{}/{}: '{}' -> '{}'",
|
||||||
|
gpu_type,
|
||||||
|
stringify!($field),
|
||||||
|
from_c_str(&config.$field),
|
||||||
|
value
|
||||||
|
);
|
||||||
|
|
||||||
|
// Zero out the field first.
|
||||||
|
config.$field.fill(0);
|
||||||
|
|
||||||
|
// Write the string bytes.
|
||||||
|
let _ = config.$field[..].as_mut().write_all(value_bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
($($field:ident),*$(,)?) => {
|
($($field:ident),*$(,)?) => {
|
||||||
$(
|
$(
|
||||||
if let Some(value) = config_override.$field {
|
handle_str_overrides!($field);
|
||||||
let value_bytes = value.as_bytes();
|
|
||||||
|
|
||||||
// Use `len - 1` to account for the required NULL terminator.
|
|
||||||
if value_bytes.len() > config.$field.len() - 1 {
|
|
||||||
error!(
|
|
||||||
"Patching nvidia-{}/{}: value '{}' is too long",
|
|
||||||
gpu_type,
|
|
||||||
stringify!($field),
|
|
||||||
value
|
|
||||||
);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
info!(
|
|
||||||
"Patching nvidia-{}/{}: '{}' -> '{}'",
|
|
||||||
gpu_type,
|
|
||||||
stringify!($field),
|
|
||||||
from_c_str(&config.$field),
|
|
||||||
value
|
|
||||||
);
|
|
||||||
|
|
||||||
// Zero out the field first
|
|
||||||
config.$field.fill(0);
|
|
||||||
|
|
||||||
let _ = config.$field[..].as_mut().write_all(value_bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)*
|
)*
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// While the following could be done with two statements. I wanted the log statements to be in
|
||||||
* While the following could be done with two statements. I wanted the log statements to be in
|
// field order.
|
||||||
* field order.
|
|
||||||
*/
|
|
||||||
|
|
||||||
handle_copy_overrides! {
|
handle_copy_overrides! {
|
||||||
gpu_type,
|
gpu_type,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user