From: Thomas Jarosch <thomas.jarosch@intra2net.com>
To: Jan Engelhardt <jengelh@medozas.de>
Cc: hadi@cyberus.ca, Patrick McHardy <kaber@trash.net>,
Pablo Neira Ayuso <pablo@netfilter.org>,
netfilter-devel@vger.kernel.org
Subject: Re: [PATCH] libxtables: Dont initialize global xt_params
Date: Thu, 12 Feb 2009 16:41:53 +0100 [thread overview]
Message-ID: <200902121641.54430.thomas.jarosch@intra2net.com> (raw)
In-Reply-To: <alpine.LSU.2.00.0902121612200.5658@fbirervta.pbzchgretzou.qr>
On Thursday, 12. February 2009 16:14:23 Jan Engelhardt wrote:
> >1. Other people which don't know this "trick" will think
> >the variable is not initialized -> Hard to read.
>
> Well, maybe then they should get a better C book --
> automatic initialization is said to be(*) part of the C standard.
> And one should know the standard of a language IMHO.
>
> (*) Because it is not free, it remains a saga from people who do
> have access to it. :p
That is completly true. OTOH avoid the dark corners of the language.
> >2. If that variable gets moved f.e. inside a function, it will become
> >uninitialized. Also I'm not sure if the savings are even measurable...
>
> It seems to be for the Linux kernel. Especially when you happen
> to have large globals (both a lot of them, and large; e.g.
> foo[NR_CUPS]) this becomes a concern.
Well, I guess that's a job for the compiler/optimizer. I did a quick test by
writing two versions of a small program initializing a static variable with
zero and one version that doesn't (=zeroed in .bss). Guess what,
the size of the resulting executable stays the same.
When I initialize the variable with a non-zero value, then the program size
increases. I tested "-O2", "-O0" and "-Os" and the results where the same.
Feel free to look at the assembler output, though I guess this optimization
is not measurable and makes the code harder to read :o)
Thomas
next prev parent reply other threads:[~2009-02-12 15:41 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-12 14:16 [PATCH] libxtables: Dont initialize global xt_params jamal
2009-02-12 15:09 ` Thomas Jarosch
2009-02-12 15:14 ` Jan Engelhardt
2009-02-12 15:41 ` Thomas Jarosch [this message]
2009-02-13 13:49 ` jamal
2009-02-13 18:11 ` Thomas Jarosch
2009-02-16 4:51 ` Philip Craig
2009-02-16 10:38 ` Patrick McHardy
2009-02-17 14:46 ` Thomas Jarosch
2009-02-17 14:54 ` Patrick McHardy
2009-02-12 16:39 ` jamal
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=200902121641.54430.thomas.jarosch@intra2net.com \
--to=thomas.jarosch@intra2net.com \
--cc=hadi@cyberus.ca \
--cc=jengelh@medozas.de \
--cc=kaber@trash.net \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.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).