From 49953500edc32e949b5f567fca67ed5430a68540 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Thu, 17 Apr 2008 16:43:20 +0300 Subject: ubi-utils: use common.h in libubi Signed-off-by: Artem Bityutskiy --- ubi-utils/new-utils/src/common.h | 5 ++++- ubi-utils/new-utils/src/libubi.c | 8 +++++--- ubi-utils/new-utils/src/libubi_int.h | 14 -------------- ubi-utils/new-utils/src/ubinfo.c | 2 +- ubi-utils/new-utils/src/ubinize.c | 5 ++--- 5 files changed, 12 insertions(+), 22 deletions(-) (limited to 'ubi-utils/new-utils') diff --git a/ubi-utils/new-utils/src/common.h b/ubi-utils/new-utils/src/common.h index a3fc51f..bd99341 100644 --- a/ubi-utils/new-utils/src/common.h +++ b/ubi-utils/new-utils/src/common.h @@ -1,5 +1,5 @@ /* - * Copyright (c) Artem Bityutskiy, 2007 + * Copyright (c) Artem Bityutskiy, 2007, 2008 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,6 +40,9 @@ extern "C" { #define normsg(fmt, ...) do { \ printf(PROGRAM_NAME ": " fmt "\n", ##__VA_ARGS__); \ } while(0) +#define normsg_cont(fmt, ...) do { \ + printf(PROGRAM_NAME ": " fmt, ##__VA_ARGS__); \ +} while(0) /* Error messages */ #define errmsg(fmt, ...) ({ \ diff --git a/ubi-utils/new-utils/src/libubi.c b/ubi-utils/new-utils/src/libubi.c index f0cbc9e..5e6f9b1 100644 --- a/ubi-utils/new-utils/src/libubi.c +++ b/ubi-utils/new-utils/src/libubi.c @@ -32,6 +32,9 @@ #include #include "libubi.h" #include "libubi_int.h" +#include "common.h" + +#define PROGRAM_NAME "libubi" /** * mkpath - compose full path from 2 given components. @@ -628,9 +631,8 @@ libubi_t libubi_open(int required) if (read_positive_int(lib->ubi_version, &version)) goto out_error; if (version != LIBUBI_UBI_VERSION) { - fprintf(stderr, "LIBUBI: this library was made for UBI version " - "%d, but UBI version %d is detected\n", - LIBUBI_UBI_VERSION, version); + errmsg("this library was made for UBI version %d, but UBI " + "version %d is detected\n", LIBUBI_UBI_VERSION, version); goto out_error; } diff --git a/ubi-utils/new-utils/src/libubi_int.h b/ubi-utils/new-utils/src/libubi_int.h index f52797a..2e664b8 100644 --- a/ubi-utils/new-utils/src/libubi_int.h +++ b/ubi-utils/new-utils/src/libubi_int.h @@ -30,20 +30,6 @@ extern "C" { #endif -/* Error messages */ -#define errmsg(fmt, ...) ({ \ - fprintf(stderr, "libubi error: " fmt "\n", ##__VA_ARGS__); \ - -1; \ -}) - -/* System error messages */ -#define sys_errmsg(fmt, ...) ({ \ - int _err = errno; \ - fprintf(stderr, "libubi error: " fmt "\n", ##__VA_ARGS__); \ - fprintf(stderr, "error %d (%s)\n", _err, strerror(_err)); \ - -1; \ -}) - /* * The below are pre-define UBI file and directory names. * diff --git a/ubi-utils/new-utils/src/ubinfo.c b/ubi-utils/new-utils/src/ubinfo.c index a71f087..fdf169a 100644 --- a/ubi-utils/new-utils/src/ubinfo.c +++ b/ubi-utils/new-utils/src/ubinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007 Nokia Corporation. + * Copyright (C) 2007, 2008 Nokia Corporation. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 as published by diff --git a/ubi-utils/new-utils/src/ubinize.c b/ubi-utils/new-utils/src/ubinize.c index a78199e..bd1b07b 100644 --- a/ubi-utils/new-utils/src/ubinize.c +++ b/ubi-utils/new-utils/src/ubinize.c @@ -322,8 +322,7 @@ int read_section(const char *sname, struct ubigen_vol_info *vi, if (vi->bytes == 0) return errmsg("file \"%s\" referred from section \"%s\" is empty", *img, sname); - printf(PROGRAM_NAME ": volume size was not specified in" - "section \"%s\", assume ", sname); + normsg_cont("volume size was not specified in section \"%s\", assume ", sname); ubiutils_print_bytes(vi->bytes, 1); printf("\n"); } @@ -332,7 +331,7 @@ int read_section(const char *sname, struct ubigen_vol_info *vi, sprintf(buf, "%s:vol_type", sname); p = iniparser_getstring(args.dict, buf, NULL); if (!p) { - normsg(": volume type was not specified in " + normsg("volume type was not specified in " "section \"%s\", assume \"dynamic\"\n", sname); vi->type = UBI_VID_DYNAMIC; } else { -- cgit v1.2.3