On 11/16/2009 03:30 PM, Peter Jones wrote: > On 11/13/2009 11:22 AM, Ales Kozumplik wrote: >> This is to avoid having to copy-paste the asprintf-log-abort if branch all the time. >> --- >> loader/loader.h | 6 +++ >> loader/nfsinstall.c | 125 +++++++++++++-------------------------------------- >> 2 files changed, 38 insertions(+), 93 deletions(-) >> >> diff --git a/loader/loader.h b/loader/loader.h >> index f942b7e..039c72a 100644 >> --- a/loader/loader.h >> +++ b/loader/loader.h >> @@ -185,4 +185,10 @@ struct loaderData_s { >> #define LIBPATH "/lib:/usr/lib:/usr/X11R6/lib:/usr/kerberos/lib:/mnt/usr/lib:/mnt/sysimage/lib:/mnt/sysimage/usr/lib" >> #endif >> >> +#define CHECKED_ASPRINTF(...) \ >> + if (asprintf( __VA_ARGS__ ) == -1) { \ >> + logMessage(CRITICAL, "%s: %d: %m", __func__, __LINE__); \ >> + abort(); \ >> + } >> + >> #endif > > So, the big problem with doing this is that it will call the error message This should read "cause the error message". Sorry. > to be incorrect. If you're going to do this, you actually need to do: > > #define checked_asprintf(...) ({ \ > char *_f = __func__; int _l = __LINE__; \ > if (asprintf( __VA_ARGS__ ) == -1) { \ > logMessage(CRITICAL, "%s: %d: %m", _f, _d); \ > abort(); \ > } \ > }) > > Or else the line number in the log file will be a line _after_ the > checked_asprintf() call. > > This is why I don't like tricky macros. > -- Peter Space, is big. Really big. You just won't believe how vastly hugely mindbogglingly big it is. I mean you may think it's a long way down the road to the chemist, but that's just peanuts to space. -- The Hitchhiker's Guide to the Galaxy _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list