[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [master] Introduces CHECK_ASPRINTF macro that checks asprintfs return value and terminates program in OOM scenarios.



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();                                                    \
> +    }
> +

At least name it in lower case.  Naming macros that behave as functions
in all caps serves no purpose at all, really, except to make it harder
to type and read.

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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]