[PATCH 1/3] mtd-utils: new memory wrappers
Mike Frysinger
vapier at gentoo.org
Thu Sep 30 01:15:35 EDT 2010
On Thu, Sep 30, 2010 at 00:59, Artem Bityutskiy wrote:
> 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.
>> ---
>> 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.
as i'm sure you noticed, i didnt make these up. i simply moved them
from existing mtd-utils code.
> If you are OK with this, I can just tweak your patch. But you can also
> re-send it - whatever you prefer.
since this cascades into another patch, i'll resubmit
-mike
More information about the linux-mtd
mailing list