functions returning structs: is it perfectly legal and how efficient?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Good morning.

Suppose we have a very little data structure - in kernel space - :

typedef struct
{
  __u32 saddr, daddr;
  __u16 sport, dport;
  short int valid;
} net_quadruplet;


net_quadruplet get_quad_from_skb(const struct sk_buff* skb)
{
	net_quadruplet netquad;
	memset(&netquad, 0, sizeof(net_quadruplet));
        netquad.valid = 1;
        ...
        return netquad;
}

Is it perfectly legal?

Would it be more efficient

int get_quad_from_skb(const struct sk_buff* skb, net_quadruplet* nquad)
{
   int return_value = 0;
   /* modify nquad
      .....
   */
   return return_value;
}

?

Thank you very much for your attention.

Giacomo

-- 
Giacomo S.
http://www.giacomos.it

- - - - - - - - - - - - - - - - - - - - - -

* Aprile 2008: iqfire-wall, un progetto
  open source che implementa un
  filtro di pacchetti di rete per Linux,
  e` disponibile per il download qui:
  http://sourceforge.net/projects/ipfire-wall

* Informazioni e pagina web ufficiale:
  http://www.giacomos.it/iqfire/index.html

- - - - - - - - - - - - - - - - - - - - - -

 . ''  `.
:   :'    :
 `.  ` '
    `- Debian GNU/Linux -- The power of freedom
        http://www.debian.org
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux