Hi,
I have a few comments regarding the code of void report(). This function
is available in very similar form in modem_run.c, pppoa2.c and pppoa3.c.
For my examples I'll use pppoa3.c.
First it is not clear to me why everything is logged with log level
LOG_INFO in case REPORT_DUMP is not set. I do believe one also wants log
level separation in case REPORT_DUMP is not set. In that case the logging
code would be identical whether REPORT_DUMP is set or not. Only the
initialisation of buffer and length should be done in the if block.
My second comment regards the order of the variables passed to report().
It seems a bit unlogical to pass the format parameter as the last variable
in case REPORT_DUMP is set. If the order of the parameters is rearranged so
the format parameter comes directly after the format variable (ie it is the
fourth parameter independent of whether REPORT_DUMP is set) the setting of
buffer and length can be done directly before dump() in the same if block.
In that case the whole section between /* Prints log message */ and /*
UnLock the report mutex */ can then be simplified to:
#ifndef USE_SYSLOG
vfprintf(log, format, ap);
#else
char msg[256];
vsnprintf(msg, 256, format, ap);
if(flags&REPORT_ERROR)
syslog(LOG_ERR, msg);
else if (flags&REPORT_INFO)
syslog(LOG_INFO, msg);
else if (flags&REPORT_DEBUG)
syslog(LOG_DEBUG, msg);
#endif
#ifndef USE_SYSLOG
/* If needed we include the strerror from libc */
if(flags & REPORT_PERROR)
fprintf(log, "Reason : %s\n", strerror(errno));
#endif
if(flags & REPORT_DUMP) {
buffer = va_arg(ap, char*);
length = va_arg(ap, int);
dump(buffer, length);
}
va_end(ap);
I am happy to supply a patch that fixes this for modem_run.c, pppoa2.c and
pppoa3.c.
Bye,
Leonard.
--
How clean is a war when you shoot around nukelar waste?
Stop the use of depleted uranium ammo!
End all weapons of mass destruction.
Liste de diffusion modem ALCATEL SpeedTouch USB
Pour se d�sinscrire : mailto:[EMAIL PROTECTED]