Skip to content

Commit a9aa217

Browse files
committed
events: do not derive Default on event sections
It is not required by the core or by any other piece of infrastructure. Only some events need to derive from Default because of the way they are constructed. Signed-off-by: Adrian Moreno <[email protected]>
1 parent f1be0fd commit a9aa217

File tree

9 files changed

+8
-3
lines changed

9 files changed

+8
-3
lines changed

retis-derive/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pub fn event_section(
2626
let id: syn::Expr = syn::parse(args).expect("Invalid event id");
2727

2828
let output = quote! {
29-
#[derive(Default)]
3029
#[crate::event_type]
3130
#input
3231

retis-events/src/common.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ pub struct TaskEvent {
3434

3535
/// Common event section.
3636
#[event_section(SectionId::Common)]
37+
#[derive(Default)]
3738
pub struct CommonEvent {
3839
/// Timestamp of when the event was generated.
3940
pub timestamp: u64,

retis-events/src/kernel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use super::*;
44
use crate::{event_section, event_type, Formatter};
55

66
#[event_section(SectionId::Kernel)]
7+
#[derive(Default)]
78
pub struct KernelEvent {
89
/// Kernel symbol name associated with the event (i.e. which probe generated
910
/// the event).

retis-events/src/nft.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use crate::{event_section, Formatter};
55

66
/// Nft event section
77
#[event_section(SectionId::Nft)]
8+
#[derive(Default)]
89
pub struct NftEvent {
910
pub table_name: String,
1011
pub chain_name: String,

retis-events/src/ovs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use super::*;
77
use crate::{event_section, event_type, Formatter};
88

99
///The OVS Event
10-
#[derive(PartialEq)]
1110
#[event_section(SectionId::Ovs)]
11+
#[derive(Default, PartialEq)]
1212
pub struct OvsEvent {
1313
/// Event data
1414
#[serde(flatten)]

retis-events/src/skb.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use crate::{event_section, event_type, Formatter};
88

99
/// Skb event section.
1010
#[event_section(SectionId::Skb)]
11+
#[derive(Default)]
1112
pub struct SkbEvent {
1213
/// Ethernet fields, if any.
1314
pub eth: Option<SkbEthEvent>,

retis-events/src/skb_tracking.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ use crate::{event_section, Formatter};
1414
///
1515
/// Tl;dr; the tracking unique id is `(timestamp, orig_head)` and `skb` can be
1616
/// used to distinguished between clones.
17-
#[derive(Copy, PartialEq)]
1817
#[event_section(SectionId::SkbTracking)]
18+
#[derive(Default, Copy, PartialEq)]
1919
#[repr(C)]
2020
pub struct SkbTrackingEvent {
2121
/// Head of buffer (`skb->head`) when the packet was first seen by the

retis/src/collect/collector.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,7 @@ mod tests {
612612
}
613613

614614
#[event_section(SectionId::Common)]
615+
#[derive(Default)]
615616
struct TestEvent {}
616617

617618
impl EventFmt for TestEvent {

retis/src/core/events/bpf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ mod tests {
644644
const DATA_TYPE_U128: u8 = 2;
645645

646646
#[event_section(SectionId::Common)]
647+
#[derive(Default)]
647648
struct TestEvent {
648649
field0: Option<u64>,
649650
field1: Option<u64>,

0 commit comments

Comments
 (0)