netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Giacomo <delleceste@gmail.com>
To: netfilter-devel@vger.kernel.org
Subject: functions returning structs: is it perfectly legal and how efficient?
Date: Fri, 20 Feb 2009 10:15:57 +0100	[thread overview]
Message-ID: <885896af0902200115t49d86f26t65d981f6fab603cf@mail.gmail.com> (raw)

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

             reply	other threads:[~2009-02-20  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-20  9:15 Giacomo [this message]
2009-02-20 11:00 ` functions returning structs: is it perfectly legal and how efficient? Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=885896af0902200115t49d86f26t65d981f6fab603cf@mail.gmail.com \
    --to=delleceste@gmail.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).