[PATCH] group_mapping: Avoid a talloc

Volker Lendecke Volker.Lendecke at SerNet.DE
Thu Jan 9 00:24:44 MST 2014


On Thu, Jan 09, 2014 at 09:22:42AM +1300, Andrew Bartlett wrote:
> I can see the argument for stuff in tight inner loops, but I'm very,

My point is -- you never know where stuff ends up in the
future. Sure, clear one-time initialization is one thing.
The negprot string, sure, we don't do negprot too often. But
for anything that is just one level below it can happen that
it pops up in hot loops at some point after refactoring of
stuff.

Also, I would like to emphasize that I much more value clean
and simple code over highly optimized but complex code. But
if we just want to print something into a temporary string
that absolutely never will overflow an fstring, we should
use an fstring.

Look for example at wcache_fetch_seqnum: There we have a
talloc_asprintf. I am 100% sure that we will never see
domain names in real life that would overflow an
fstr_sprintf, but in this case I would not touch it without
it showing up high in profiles, and I would much rather do
the same thing that I did with full_path_tos: Provide a safe
way to overflow a given buffer.

However the group_mapping thing is different: Here we do
have a fixed maximum string size that we even have a #define
for. And we have a string that is only ever used for a very
short code snippet. Here for me it's clear a fixed string is
the right thing to do. Also, innocent as it might look it
could easily be called in a tight inner loop, for example
when converting a big NT acl coming in from the network. You
never know.

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de


More information about the samba-technical mailing list