Re: Compiling SAMBA with better options

2003-03-28 Thread John E. Malmberg
From: B. Z. Lederman wrote:

I've been looking more at the source code and the way it's
 compiled. 

/STANDARD=VAXC is really not a good choice.  It covers up too
 many real and potential problems in the code.
Use /STANDARD=PORTABLE.  Do not use /STANDARD=VAXC

Use /WARN=ENABLE=(LEVEL4, QUESTCODE) for the diagnostic level.

You can use more strict /STANDARD or /warn and other checking if you 
wish, but the two settings above are the minimum needed to both find 
common bugs, and to be compatable with common programming practices.

If the /warn=enable=(LEVEL4, QUESTCODE) and /STANDARD=PORTABLE does not 
compile a UNIX samba module, try it again by adding /ACCEPT=NOVAXC

If that does not fix it, then update the source and send a explanation 
of the bug fix allong with a submit a gdiff -u output of the change to 
the SAMBA-TECHNICAL list so it can be fixed in the source for all platforms.

If you have not submitted patches to the SAMBA-TECHNICAL list before, I 
recommend posting just the lines that you think needing fixing both old 
and new to this list for review.  Please be brief.

There is also a question of what to do with names that are
 longer than 31 characters.
I put #define statements in the config.h or equivalent.

Having the names truncated will cause duplicate symbol errors in SAMBA.

The only thing that I can find in the standard is that only 8 characters 
 for external names are guaranteed to be available on all platforms, 
and obviously most code needs more than that.

The other option is to allow the compiler to mangle names.  I prefer not 
to do that as then I can not always predict what name will show up in 
the debugger.  Particularly if the demangle database is cleared.

[SAMBA-2_2_7A-SRC.SOURCE.SMBD] CLOSE.C

because it calls sys$open, sys$close, etc. without the
 functions being defined.  Modules that call these functions are
 better off if they #include starlet.h to define the function
 prototypes. There are a couple of other modules where this should
 be done. 
I personally find that the #include files for the system service modules 
to not be accurate because they do not use the const modifier where 
they should and they tend to use void *, which will accept anything 
with out a complaint.

So I usually prototype the system services manually, like I did in 
Frontport.  That way the compiler is more likely to find bugs.

The use of the const modifier on variables passed by address also 
allows the compiler to optimize more effienciently, which means faster 
and smaller code.  It's use should be greatly encouraged.

An unknown person wrote: (post is not in the digest)

| I quite agree with your remarks, but I fear that you seem to forget a very
| important point : Samba/VMS is a port from a quite complicated software that
| comes from Unix, and is quite often updated. If you multiply the #ifdef
| for VMS specifics, you begin to have a lot of work each time a new release
| comes in, if you want to follow the Unix updates. So I tend to limit the VMS
| specific changes to truly functional ones, not for the intellectual benefit
| of removing warning or informational messages.
That is why I did the SAMBA 2.0.6 port the way I did.  Amost no #ifdef 
__VMS is in the code.  Carl Perkins has supplied me with a fix to 
Frontport that probably eliminates all but one of the #ifdef __VMS.

Use of the compiler options that I listed earlier should allows SAMBA to 
compile unless there is a real bug in the source code.

I add a /DEFINE=(MOD_modulename) to the MMS C compiler rule so that I 
can put things that are specific to a module in the config.h or 
equivalent.  That way I can override a local routine with out having to 
edit any source code.

The MMS definition is below, and it is easy to do this with DCL command 
procedures.

MODN =MOD_'f$element(0,-,f$parse($*,,,NAME))'

So in the config.h or equivalent, (Since I am now generating the 
config.h from a command procedure that knows how to read the config.h.in 
and configure.in files, and search the DECC images and libraries, I now 
put all the manual edits in config_vms.h)

#ifdef MOD_LOADPARM
   /* Change the name for a VMS specific wrapper */
  /**/
#define lp_load samba_lp_load
#endif
This allows me to scan the VMS specific SAMBA logical names every time 
that SAMBA scans the smb.conf file for changes.

And if a module informational diagnostics that I do not want to
submit a fix for, I can supress those on a per module basis.
#ifdef MOD_IPC
 /* suppress messages about using -1 as third arg to SSVALS() macro */
#pragma message disable intconstsign
#endif
This is a case where they are using a -1 instead of 0xFFF.  The 
problem with fixing this is that the size of an unsigned int is platform 
specific, so it really should be ~0 instead.  However if I remember 
correclty that also generates a diagnostic.

So I just supress the diagnostic for now.

An unknown person wrote: (post is not in 

RE : Compiling SAMBA with better options

2003-03-27 Thread B. Z. Lederman

| I quite agree with your remarks, but I fear that you seem to forget a very
| important point : Samba/VMS is a port from a quite complicated software that
| comes from Unix, and is quite often updated. If you multiply the #ifdef
| for VMS specifics, you begin to have a lot of work each time a new release
| comes in, if you want to follow the Unix updates. So I tend to limit the VMS
| specific changes to truly functional ones, not for the intellectual benefit
| of removing warning or informational messages.

I do know where the code comes from, and I'm not proposing the
 addition of any #ifdef s at all.

The modules that should be including STARLET.H are VMS only or
 are already conditionalized for VMS, because only VMS-specific
 code will be calling sys$open, sys$truncate, etc.

As for the other warnings: they are indications of problems in
 the common code.  Comparing an unsigned integer to a signed value
 is something that should not be done on any platform.  The
 OpenVMS C compiler is warning of things that should be fixed on
 all platforms in the common code.

| them on the Internet. I was not too much enthusiast, but I eventually
| agreed, and since then I try to do my best to help other users who encounter
| problems. May I say that since the beginning of this Samba/VMS version (more
| or less 1 year ago), not a single problem was due to the /STAND=VAXC option
| ?

I'm sure your efforts are appreciated. Unfortunately, you
 can't be sure you don't have problems due to the compiler
 options. Compiling /STAND=VAXC means that warning messages about
 code that could be causing problems are not seen.  You are also
 losing out on improvements the compiler can make to the code.

I'm trying to make the results of my compilation run available
 to everyone who wants it.  I hope someone would know how to pass
 back the information to the people who are 'responsible' for the
 common code so the major problems can be fixed.

I also think the improved compiler switches would be good for
 everybody running on OpenVMS.

PLEASE READ THIS IMPORTANT ETIQUETTE MESSAGE BEFORE POSTING:

http://www.catb.org/~esr/faqs/smart-questions.html