Skip to content

Commit 9b4dbb1

Browse files
d-e-s-odanielocfb
authored andcommitted
Let rustfmt take care of wrapping comments
It turns out rustfmt can ensure a consistent comment length by applying automatic wrapping. Let's enable the functionality to get some more consistency into the code base and ensure that pull requests adhere to a basic standard in the process. Also set a two other options that don't exactly change anything at this point but are nice to have and give us more flexibility in the future. Signed-off-by: Daniel Müller <[email protected]>
1 parent 0ffc319 commit 9b4dbb1

File tree

8 files changed

+19
-16
lines changed

8 files changed

+19
-16
lines changed

.rustfmt.toml

+4
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
blank_lines_upper_bound = 2
12
imports_granularity = "item"
3+
trailing_semicolon = false
4+
wrap_comments = true
5+
comment_width = 100

libbpf-cargo/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
//!
3838
//! * source file names must be in the `<NAME>.bpf.c` format
3939
//! * object file names will be generated in `<NAME>.bpf.o` format
40-
//! * there may not be any two identical `<NAME>.bpf.c` file names in any two projects in a
41-
//! cargo workspace
40+
//! * there may not be any two identical `<NAME>.bpf.c` file names in any two projects in a cargo
41+
//! workspace
4242
//!
4343
//! ## gen
4444
//!

libbpf-rs/src/btf/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ pub struct BtfType<'btf> {
458458
/// type_: u32,
459459
/// }
460460
/// ```
461-
///
462461
ty: &'btf libbpf_sys::btf_type,
463462
}
464463

libbpf-rs/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
//! 2. Create directory `$PROJ_PATH/src/bpf`
1717
//! 3. Write CO-RE bpf code in `$PROJ_PATH/src/bpf/${MYFILE}.bpf.c`, where `$MYFILE` may be any
1818
//! valid filename. Note the `.bpf.c` extension is required.
19-
//! 4. Create a [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html)
20-
//! that builds and generates a skeleton module using `libbpf_cargo::SkeletonBuilder`
19+
//! 4. Create a [build script](https://doc.rust-lang.org/cargo/reference/build-scripts.html) that
20+
//! builds and generates a skeleton module using `libbpf_cargo::SkeletonBuilder`
2121
//! 5. Write your userspace code by importing and using the generated module. Import the
2222
//! module by using the [path
2323
//! attribute](https://doc.rust-lang.org/reference/items/modules.html#the-path-attribute).

libbpf-rs/src/map.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -229,8 +229,9 @@ where
229229
Ok(ncpu * aligned_val_size)
230230
}
231231

232-
/// Apply a key check and return a null pointer in case of dealing with queue/stack/bloom-filter map,
233-
/// before passing the key to the bpf functions that support the map of type queue/stack/bloom-filter.
232+
/// Apply a key check and return a null pointer in case of dealing with queue/stack/bloom-filter
233+
/// map, before passing the key to the bpf functions that support the map of type
234+
/// queue/stack/bloom-filter.
234235
fn map_key<M>(map: &M, key: &[u8]) -> *const c_void
235236
where
236237
M: MapCore + ?Sized,

libbpf-rs/src/program.rs

-2
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,6 @@ impl OpenProgram {
213213
/// Note: Keep in mind, libbpf can modify the program's instructions
214214
/// and consequently its instruction count, as it processes the BPF object file.
215215
/// So [`OpenProgram::insn_cnt`] and [`Program::insn_cnt`] may return different values.
216-
///
217216
pub fn insn_cnt(&self) -> usize {
218217
unsafe { libbpf_sys::bpf_program__insn_cnt(self.ptr.as_ptr()) as usize }
219218
}
@@ -1067,7 +1066,6 @@ impl Program {
10671066
/// Gives read-only access to BPF program's underlying BPF instructions.
10681067
///
10691068
/// Please see note in [`OpenProgram::insns`].
1070-
///
10711069
pub fn insns(&self) -> &[libbpf_sys::bpf_insn] {
10721070
let count = self.insn_cnt();
10731071
let ptr = unsafe { libbpf_sys::bpf_program__insns(self.ptr.as_ptr()) };

libbpf-rs/src/skeleton.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,8 @@ impl Drop for ObjectSkeletonConfig<'_> {
339339

340340
/// A trait for skeleton builder.
341341
pub trait SkelBuilder<'a> {
342-
/// Define that when BPF object is opened, the returned type should implement the [`OpenSkel`] trait
342+
/// Define that when BPF object is opened, the returned type should implement the [`OpenSkel`]
343+
/// trait
343344
type Output: OpenSkel;
344345

345346
/// Open eBPF object and return [`OpenSkel`]

libbpf-rs/src/util.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ pub fn create_bpf_entity_checked<B: 'static, F: FnOnce() -> *mut B>(f: F) -> Res
8383
io::ErrorKind::Other,
8484
format!(
8585
"bpf call {:?} returned NULL",
86-
type_name::<F>() // this is usually a library bug, hopefully this will
87-
// help diagnose the bug.
88-
//
89-
// One way to fix the bug might be to change to calling
90-
// create_bpf_entity_checked_opt and handling Ok(None)
91-
// as a meaningful value.
86+
type_name::<F>() /* this is usually a library bug, hopefully this will
87+
* help diagnose the bug.
88+
*
89+
* One way to fix the bug might be to change to calling
90+
* create_bpf_entity_checked_opt and handling Ok(None)
91+
* as a meaningful value. */
9292
),
9393
)
9494
})

0 commit comments

Comments
 (0)