Samba4 now more than 50% auto-generated

Andrew Tridgell tridge at
Mon Jan 10 22:56:37 GMT 2005

One of the goals of Samba4 has been to use code generation to do a lot
of the hard work, and to make the code easier to maintain, more
reliable and more consistent.

Today we reached an interesting milestone as the C code in Samba4 is
now more than 50% auto-generated.  This figure has been steadily
rising as we have added more IDL code for various RPC interfaces, and
I expect it will go much higher before Samba4 is released. I would not
be surprised if Samba 4.0 is up to 70% auto-generated code.

We have two sources of code generation at the moment. The biggest is
the use of IDL and the pidl IDL compiler to generate code for
DCE/RPC. The second is the use of swig to generate code for
integrating with python scripting.

The huge advantage of auto-generated code was illustrated yesterday
when we converted all our RPC code to handle multiple interface
context_ids on a single RPC pipe (using the "alter_context" DCE/RPC
operation). Adding this required a change to just a handful of lines
in the code generator to immediately make nearly all of our RPC code
aware of the structural changes. If we had to do this using the old
Samba3 approach it would have been a much larger task.

The other really big advantage is in code quality. By auto-generating
we can make certain that every allocation is checked, every marshall
and unmarshall is bounds checked and that every structure is correctly
aligned. While we tried our best with the old hand generated approach
there were inevitable errors, and it was a nightmare to properly

I'd like to give a big thank you to everyone who has helped this part
of Samba4 become a reality. In particular to Metze and Jelmer for
their fantastic work on the RPC infrastructure, to tpot for his work
on the python scripting and the ethereal dissector generation, to
abartlet for his tireless work on the authentication code, to Volker
for his work on the samr IDL and test suites and to everyone else who
has been contributing to this effort over the past few months.

Cheers, Tridge

More information about the samba-technical mailing list