Vitezslav Samel <vitezslav(a)samel.cz> writes:
On Wed, May 07, 2014 at 06:35:29PM +1200, Nikola Pajkovsky wrote:
> Vitezslav Samel <vitezslav(a)samel.cz> writes:
>
> > 1) dissect declaration and initialization of struct pkt_hdr
> > 2) rename PACKET_INIT_STRUCT() to packet_init()
> > 3) un-inline packet_init(): it's not used on any fast path so there's
no
> > need to be inlined
> > 4) capture-pkt.c: rename p to pkt to have it consistent with other uses
> >
> > Signed-off-by: Vitezslav Samel <vitezslav(a)samel.cz>
> > ---
> > src/capture-pkt.c | 10 ++++++----
> > src/detstats.c | 4 +++-
> > src/hostmon.c | 4 +++-
> > src/ifstats.c | 4 +++-
> > src/itrafmon.c | 4 +++-
> > src/packet.c | 13 +++++++++++++
> > src/packet.h | 16 +---------------
> > src/pktsize.c | 4 +++-
> > src/serv.c | 4 +++-
> > 9 files changed, 38 insertions(+), 25 deletions(-)
> >
> > +int packet_init(struct pkt_hdr *pkt)
> > +{
> > + pkt->pkt_bufsize = MAX_PACKET_SIZE;
> > + pkt->pkt_payload = NULL;
> > + pkt->ethhdr = NULL;
> > + pkt->fddihdr = NULL;
> > + pkt->iphdr = NULL;
> > + pkt->ip6_hdr = NULL;
> > + pkt->pkt_len = 0; /* signalize we have no packet prepared */
> > +
> > + return 0; /* all O.K. */
> > +}
> > +
> > void pkt_cleanup(void)
> > {
> > destroyfraglist();
> > diff --git a/src/packet.h b/src/packet.h
> > index 895d63b..e8811e6 100644
> > --- a/src/packet.h
> > +++ b/src/packet.h
> > @@ -38,21 +38,6 @@ struct pkt_hdr {
> > char pkt_buf[MAX_PACKET_SIZE];
> > };
> >
> > -static inline void PACKET_INIT_STRUCT(struct pkt_hdr *p)
> > -{
> > - p->pkt_bufsize = MAX_PACKET_SIZE;
> > - p->pkt_payload = NULL;
> > - p->ethhdr = NULL;
> > - p->fddihdr = NULL;
> > - p->iphdr = NULL;
> > - p->ip6_hdr = NULL;
> > - p->pkt_len = 0; /* signalize we have no packet prepared */
> > -}
> > -
> > -#define PACKET_INIT(packet) \
> > - struct pkt_hdr packet; \
> > - PACKET_INIT_STRUCT(&packet)
>
> yeah, I have messed up the initialization. What I wanted to have one
> initialization for compiler time and one for run time.
>
> struct pkt_hdr pkt = PKT_INIT;
>
> where PKT_INIT is macro
>
> #define PKT_INIT { .pkt_bufsize = MAX_PACKET_SIZE, .pkt_payload
> = NULL ... }
>
> and one you have written for run time. that would be ideal.
>
> hmm?
Why should we have 2 init routines? In the case packet mmap() case
even the compile time initialization will be moved to run time init.
I think my patch does this the right way.
yeah, I have realize that after I have finished the review.
--
Nikola