[PATCH 1/3] mtd-utils: new memory wrappers

Artem Bityutskiy dedekind1 at gmail.com
Thu Sep 30 00:59:45 EDT 2010


On Wed, 2010-09-29 at 19:30 -0400, Mike Frysinger wrote:
> The mkfs.jffs2 program has local wrappers for memory related functions
> that are useful beyond mkfs.jffs2, so break them out into a common header.
> 
> Signed-off-by: Mike Frysinger <vapier at gentoo.org>
> ---
>  include/common.h |    8 +++++
>  include/xalloc.h |   80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  mkfs.jffs2.c     |   41 ---------------------------
>  3 files changed, 88 insertions(+), 41 deletions(-)
>  create mode 100644 include/xalloc.h
> 
> diff --git a/include/common.h b/include/common.h
> index 472315e..6e27d62 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -58,6 +58,9 @@ extern "C" {
>  	fprintf(stderr, "%s: error!: " fmt "\n", PROGRAM_NAME, ##__VA_ARGS__); \
>  	-1;                                                                 \
>  })
> +#define errmsg_and_die(fmt, ...) do {                                       \
> +	exit(errmsg(fmt, ##__VA_ARGS__));                                   \
> +} while(0)
>  
>  /* System error messages */
>  #define sys_errmsg(fmt, ...)  ({                                            \
> @@ -69,6 +72,9 @@ extern "C" {
>  	fprintf(stderr, "error %d (%s)\n", _err, strerror(_err));           \
>  	-1;                                                                 \
>  })
> +#define sys_errmsg_and_die(fmt, ...) do {                                   \
> +	exit(sys_errmsg(fmt, ##__VA_ARGS__));                               \
> +} while(0)

Often these funcs are used with longish strings, so it is better to try
keeping the function names short. Thus, I suggest you to use
'err_msg_die()' etc. IOW, without the '_and' part.

If you are OK with this, I can just tweak your patch. But you can also
re-send it - whatever you prefer.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)




More information about the linux-mtd mailing list