Move main macro body one indentation level out

This commit is contained in:
Matt Bilker 2021-09-17 09:14:54 +00:00
parent 4a73f9376d
commit e121e65859
No known key found for this signature in database
GPG Key ID: 69ADF8AEB6C8B5D1

View File

@ -314,8 +314,7 @@ 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),*$(,)?) => { ($field:ident) => {
$(
if let Some(value) = config_override.$field { if let Some(value) = config_override.$field {
info!( info!(
"Patching nvidia-{}/{}: {} -> {}", "Patching nvidia-{}/{}: {} -> {}",
@ -327,12 +326,15 @@ fn apply_profile_override(config: &mut VgpuConfig) -> bool {
config.$field = value; config.$field = value;
} }
};
($($field:ident),*$(,)?) => {
$(
handle_copy_overrides!($field);
)* )*
}; };
} }
macro_rules! handle_str_overrides { macro_rules! handle_str_overrides {
($($field:ident),*$(,)?) => { ($field:ident) => {
$(
if let Some(value) = config_override.$field { if let Some(value) = config_override.$field {
let value_bytes = value.as_bytes(); let value_bytes = value.as_bytes();
@ -355,20 +357,23 @@ fn apply_profile_override(config: &mut VgpuConfig) -> bool {
value value
); );
// Zero out the field first // Zero out the field first.
config.$field.fill(0); config.$field.fill(0);
// Write the string bytes.
let _ = config.$field[..].as_mut().write_all(value_bytes); let _ = config.$field[..].as_mut().write_all(value_bytes);
} }
} }
};
($($field:ident),*$(,)?) => {
$(
handle_str_overrides!($field);
)* )*
} };
} }
/* // 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,