Errors while testing Nagios
Andreas Ericsson
ae at op5.se
Mon Oct 25 14:40:09 CEST 2010
On 10/25/2010 02:07 PM, Jochen Bern wrote:
> On 10/25/2010 12:00 PM, Andreas Ericsson wrote:
>> On 10/25/2010 11:00 AM, Ton Voon wrote:
>>> I had an idea to try a different technique (include the
>>> source, but override some specific functions), but I couldn't redefine
>>> functions in C without the compiler complaining.
>> There's no sane way to do that. The un-sane way is to sed out the functions
>> you want to replace and then source the sed'ed source-file.
>
> Well, if you want only *mild* insanity, look no further than at the
> preprocessor. ;-)
>
Mild insanity is to mark code in emails with the default character for
marking replies. It will look as if I wrote the examples you posted.
Anyways...
That works well when we control the program doing the calling, but since
we want it to work the other way around, we can't macro away functions
that are defined (and declared) and called in the same file.
Take this as example:
sched_api.c:
int sapi_isscheduled(const char *what)
{
return !!hash_find(sometable, what);
}
int sapi_reschedule(const char *what, time_t when)
{
if (sapi_isscheduled(what))
return -1;
do { things(); } while (stuff);
return 0;
}
There's no way to hijack the sapi_isscheduled() call from
sapi_reschedule() without also changing its callsite to call the
new name. Not without writing into the code segment anyway, and
that's just silly and extremely non-portable even between compiler
versions.
This ofcourse assumes that we don't modify the core files for the
sole purpose of being able to test them. If we set that assumption
aside we won't need macro magic to take care of it.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
------------------------------------------------------------------------------
Nokia and AT&T present the 2010 Calling All Innovators-North America contest
Create new apps & games for the Nokia N8 for consumers in U.S. and Canada
$10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing
Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store
http://p.sf.net/sfu/nokia-dev2dev
More information about the Developers
mailing list