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

Vorobiev Maksim MVorobiev at croc.ru
Tue Jun 28 08:18:10 EDT 2005


Good day.

But it still has a problem in map.c for function int
Mono_Posix_FromSyslogFacility (int x, int *r).
It checks for constants via &-mask: search for first occurrence. The
next code:
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;}

will be TRUE for all constants, which ends with "8"
(Mono_Posix_SyslogFacility_LOG_DAEMON and so on - "even ones"). Here
should be another way for testing. BTW, why to look throght all possible
constants? Since these are not flags, where could be only one possible
value. So, function should return after first found. And IMHO test
should be performed like this:

if ((x & Mono_Posix_SyslogFacility_ALL) ==
Mono_Posix_SyslogFacility_LOG_USRE)
#ifdef LOG_USRE
		{*r = LOG_USRE;return 0;}
#else /* def LOG_USRE */
		{errno = EINVAL; return -1;}

Where Mono_Posix_SyslogFacility_ALL = Mono_Posix_SyslogFacility_LOG_KERN
| Mono_Posix_SyslogFacility_LOG_USRE | ....

Thank you for your answer.


On Mon, 2005-06-27 at 18:35 +0400, Vorobiev Maksim wrote:
> 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.

It's nice to know someone is testing it. :-)

> 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

Oops, my bad.  Fixed in svn-trunk (r46637,r46638).

> 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?

This was fixed on June 15 in svn-trunk.

> 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?

No, it's my mistake.  Fixed in svn-trunk.

Thank you for the help.

 - Jon



_______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list



More information about the Mono-devel-list mailing list