[Mono-devel-list] problems with Syscall.syslog

Vorobiev Maksim MVorobiev at croc.ru
Mon Jun 27 10:35:07 EDT 2005


Good day.

I've started using Syscall.syslog method and encounted several problems.
It may be errors in mono, or I just missed some details. Please note,
that I use Suse 9.2 linux distribute.

1. In Syscall.cs enumeration SyslogFacility declared with members:

LOG_UUCP = 8 << 3,

LOG_CRON = 8 << 3

But under Suse the same constants declared in /usr/include/sys/syslog.h
as LOG_UUCP = 8 << 3, LOG_CRON = 9 << 3

Is it bug in mono or it worked for some other platforms? I'm going to
fix it in mono for myself...

2. There is no constant LOG_USRE in syslog.h under Suse, but it's
LOG_USER. So, in support/map.c there is a bug (?) - no such definition
found and error returned then code execution steps in this branch. The
question is the same: is it mono problem, or Suse-platform specific
header file?

3. It seems very strange that SyslogFacility enumeration declared with
[Flag] attribute. Members of this enumeration are not "powers of 2", so
their combination via OR-mask is something incorrect. And these
constants should be used independantly, not in combination. Is it true
or I missed something?

4. In Mono_Posix_FromSyslogFacility in support/map.c constants from
SyslogFacility interpreted as flags - they checked with OR-mask. It's
incorrect as I understand, but more then it, there is such branch:

if ((x & Mono_Posix_SyslogFacility_LOG_USRE) ==
Mono_Posix_SyslogFacility_LOG_USRE)

#ifdef LOG_USRE

*r |= LOG_USRE;

#else /* def LOG_USRE */

{errno = EINVAL; return -1;}

#endif /* ndef LOG_USRE */

This is combination of 2) and 3) issues. First of all, undefined macro
LOG_USRE always runs to error return. The second one, that
Mono_Posix_SyslogFacility_LOG_USRE declared as follows:

#define Mono_Posix_SyslogFacility_LOG_USRE 0x00000008

This means, that branch

if ((x & Mono_Posix_SyslogFacility_LOG_USRE) ==
Mono_Posix_SyslogFacility_LOG_USRE)

will becomes true for all constants like #define
Mono_Posix_SyslogFacility_LOG_DAEMON 0x00000018 #define
Mono_Posix_SyslogFacility_LOG_SYSLOG 0x00000028 ...etc

And it always will generate error for Suse.

I'm ready to fix these issues and supply the patch. Is it OK to change
SyslogFacility enumeration to simple enum, not flags? Is it OK to
assume, that LOG_USRE is LOG_USER in real for all platforms?

Is it good to change declaration of LOG_UUCP and LOG_CRON as LOG_UUCP =
8 << 3, LOG_CRON = 9 << 3 ?

Thank you.

 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20050627/ccff57f7/attachment.html 


More information about the Mono-devel-list mailing list