Skip to content

Commit d955157

Browse files
committed
treewide: fix too-long-lines checkpatch.pl warnings
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
1 parent f87f7e0 commit d955157

File tree

4 files changed

+64
-32
lines changed

4 files changed

+64
-32
lines changed

rust/kernel/file.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,8 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
326326
offset: *mut bindings::loff_t,
327327
) -> core::ffi::c_ssize_t {
328328
from_kernel_result! {
329-
let mut data = unsafe { UserSlicePtr::new(buf as *mut core::ffi::c_void, len).writer() };
329+
let mut data =
330+
unsafe { UserSlicePtr::new(buf as *mut core::ffi::c_void, len).writer() };
330331
// SAFETY: `private_data` was initialised by `open_callback` with a value returned by
331332
// `T::Data::into_pointer`. `T::Data::from_pointer` is only called by the
332333
// `release` callback, which the C API guarantees that will be called only when all
@@ -374,7 +375,8 @@ impl<A: OpenAdapter<T::OpenData>, T: Operations> OperationsVtable<A, T> {
374375
offset: *mut bindings::loff_t,
375376
) -> core::ffi::c_ssize_t {
376377
from_kernel_result! {
377-
let mut data = unsafe { UserSlicePtr::new(buf as *mut core::ffi::c_void, len).reader() };
378+
let mut data =
379+
unsafe { UserSlicePtr::new(buf as *mut core::ffi::c_void, len).reader() };
378380
// SAFETY: `private_data` was initialised by `open_callback` with a value returned by
379381
// `T::Data::into_pointer`. `T::Data::from_pointer` is only called by the
380382
// `release` callback, which the C API guarantees that will be called only when all

rust/macros/module.rs

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,15 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
388388
let read_func = if permissions_are_readonly(&param_permissions) {
389389
format!(
390390
"
391-
fn read(&self) -> &<{param_type_internal} as kernel::module_param::ModuleParam>::Value {{
392-
// SAFETY: Parameters do not need to be locked because they are read only or sysfs is not enabled.
393-
unsafe {{ <{param_type_internal} as kernel::module_param::ModuleParam>::value(&__{name}_{param_name}_value) }}
391+
fn read(&self)
392+
-> &<{param_type_internal} as kernel::module_param::ModuleParam>::Value {{
393+
// SAFETY: Parameters do not need to be locked because they are
394+
// read only or sysfs is not enabled.
395+
unsafe {{
396+
<{param_type_internal} as kernel::module_param::ModuleParam>::value(
397+
&__{name}_{param_name}_value
398+
)
399+
}}
394400
}}
395401
",
396402
name = info.name,
@@ -400,9 +406,14 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
400406
} else {
401407
format!(
402408
"
403-
fn read<'lck>(&self, lock: &'lck kernel::KParamGuard) -> &'lck <{param_type_internal} as kernel::module_param::ModuleParam>::Value {{
409+
fn read<'lck>(&self, lock: &'lck kernel::KParamGuard)
410+
-> &'lck <{param_type_internal} as kernel::module_param::ModuleParam>::Value {{
404411
// SAFETY: Parameters are locked by `KParamGuard`.
405-
unsafe {{ <{param_type_internal} as kernel::module_param::ModuleParam>::value(&__{name}_{param_name}_value) }}
412+
unsafe {{
413+
<{param_type_internal} as kernel::module_param::ModuleParam>::value(
414+
&__{name}_{param_name}_value
415+
)
416+
}}
406417
}}
407418
",
408419
name = info.name,
@@ -413,13 +424,15 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
413424
let kparam = format!(
414425
"
415426
kernel::bindings::kernel_param__bindgen_ty_1 {{
416-
arg: unsafe {{ &__{name}_{param_name}_value }} as *const _ as *mut core::ffi::c_void,
427+
arg: unsafe {{ &__{name}_{param_name}_value }}
428+
as *const _ as *mut core::ffi::c_void,
417429
}},
418430
",
419431
name = info.name,
420432
param_name = param_name,
421433
);
422-
write!(modinfo.buffer,
434+
write!(
435+
modinfo.buffer,
423436
"
424437
static mut __{name}_{param_name}_value: {param_type_internal} = {param_default};
425438
@@ -443,26 +456,30 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
443456
}}
444457
445458
#[cfg(not(MODULE))]
446-
const __{name}_{param_name}_name: *const core::ffi::c_char = b\"{name}.{param_name}\\0\" as *const _ as *const core::ffi::c_char;
459+
const __{name}_{param_name}_name: *const core::ffi::c_char =
460+
b\"{name}.{param_name}\\0\" as *const _ as *const core::ffi::c_char;
447461
448462
#[cfg(MODULE)]
449-
const __{name}_{param_name}_name: *const core::ffi::c_char = b\"{param_name}\\0\" as *const _ as *const core::ffi::c_char;
463+
const __{name}_{param_name}_name: *const core::ffi::c_char =
464+
b\"{param_name}\\0\" as *const _ as *const core::ffi::c_char;
450465
451466
#[link_section = \"__param\"]
452467
#[used]
453-
static __{name}_{param_name}_struct: __{name}_{param_name}_RacyKernelParam = __{name}_{param_name}_RacyKernelParam(kernel::bindings::kernel_param {{
454-
name: __{name}_{param_name}_name,
455-
// SAFETY: `__this_module` is constructed by the kernel at load time and will not be freed until the module is unloaded.
456-
#[cfg(MODULE)]
457-
mod_: unsafe {{ &kernel::bindings::__this_module as *const _ as *mut _ }},
458-
#[cfg(not(MODULE))]
459-
mod_: core::ptr::null_mut(),
460-
ops: unsafe {{ &{ops} }} as *const kernel::bindings::kernel_param_ops,
461-
perm: {permissions},
462-
level: -1,
463-
flags: 0,
464-
__bindgen_anon_1: {kparam}
465-
}});
468+
static __{name}_{param_name}_struct: __{name}_{param_name}_RacyKernelParam =
469+
__{name}_{param_name}_RacyKernelParam(kernel::bindings::kernel_param {{
470+
name: __{name}_{param_name}_name,
471+
// SAFETY: `__this_module` is constructed by the kernel at load time
472+
// and will not be freed until the module is unloaded.
473+
#[cfg(MODULE)]
474+
mod_: unsafe {{ &kernel::bindings::__this_module as *const _ as *mut _ }},
475+
#[cfg(not(MODULE))]
476+
mod_: core::ptr::null_mut(),
477+
ops: unsafe {{ &{ops} }} as *const kernel::bindings::kernel_param_ops,
478+
perm: {permissions},
479+
level: -1,
480+
flags: 0,
481+
__bindgen_anon_1: {kparam}
482+
}});
466483
",
467484
name = info.name,
468485
param_type_internal = param_type_internal,
@@ -472,7 +489,8 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
472489
ops = ops,
473490
permissions = param_permissions,
474491
kparam = kparam,
475-
).unwrap();
492+
)
493+
.unwrap();
476494
}
477495
}
478496

@@ -513,11 +531,16 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
513531
514532
static mut __MOD: Option<{type_}> = None;
515533
516-
// SAFETY: `__this_module` is constructed by the kernel at load time and will not be freed until the module is unloaded.
534+
// SAFETY: `__this_module` is constructed by the kernel at load time and will not be
535+
// freed until the module is unloaded.
517536
#[cfg(MODULE)]
518-
static THIS_MODULE: kernel::ThisModule = unsafe {{ kernel::ThisModule::from_ptr(&kernel::bindings::__this_module as *const _ as *mut _) }};
537+
static THIS_MODULE: kernel::ThisModule = unsafe {{
538+
kernel::ThisModule::from_ptr(&kernel::bindings::__this_module as *const _ as *mut _)
539+
}};
519540
#[cfg(not(MODULE))]
520-
static THIS_MODULE: kernel::ThisModule = unsafe {{ kernel::ThisModule::from_ptr(core::ptr::null_mut()) }};
541+
static THIS_MODULE: kernel::ThisModule = unsafe {{
542+
kernel::ThisModule::from_ptr(core::ptr::null_mut())
543+
}};
521544
522545
// Loadable modules need to export the `{{init,cleanup}}_module` identifiers.
523546
#[cfg(MODULE)]
@@ -597,7 +620,9 @@ pub(crate) fn module(ts: TokenStream) -> TokenStream {
597620
modinfo = modinfo.buffer,
598621
generated_array_types = generated_array_types,
599622
initcall_section = ".initcall6.init"
600-
).parse().expect("Error parsing formatted string into token stream.")
623+
)
624+
.parse()
625+
.expect("Error parsing formatted string into token stream.")
601626
}
602627

603628
#[cfg(test)]

rust/macros/vtable.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ pub(crate) fn vtable(_attr: TokenStream, ts: TokenStream) -> TokenStream {
5353

5454
let mut const_items;
5555
if is_trait {
56-
const_items = "/// A marker to prevent implementors from forgetting to use [`#[vtable]`](vtable) attribute when implementing this trait.
57-
const USE_VTABLE_ATTR: ();".to_owned();
56+
const_items = "
57+
/// A marker to prevent implementors from forgetting to use [`#[vtable]`](vtable)
58+
/// attribute when implementing this trait.
59+
const USE_VTABLE_ATTR: ();
60+
"
61+
.to_owned();
5862

5963
for f in functions {
6064
let gen_const_name = format!("HAS_{}", f.to_uppercase());

scripts/rust-is-available.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ if [ "$1" = -v ]; then
134134
)
135135
if [ "$clang_version" != "$bindgen_libclang_version" ]; then
136136
echo >&2 "***"
137-
echo >&2 "*** libclang (used by the Rust bindings generator '$BINDGEN') version does not match Clang's. This may be a problem."
137+
echo >&2 "*** libclang (used by the Rust bindings generator '$BINDGEN')"
138+
echo >&2 "*** version does not match Clang's. This may be a problem."
138139
echo >&2 "*** libclang version: $bindgen_libclang_version"
139140
echo >&2 "*** Clang version: $clang_version"
140141
echo >&2 "***"

0 commit comments

Comments
 (0)