]> www.infradead.org Git - mtd-utils.git/commitdiff
ubi-utils: use common.h in libubi
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 17 Apr 2008 13:43:20 +0000 (16:43 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Thu, 17 Apr 2008 13:46:23 +0000 (16:46 +0300)
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
ubi-utils/new-utils/src/common.h
ubi-utils/new-utils/src/libubi.c
ubi-utils/new-utils/src/libubi_int.h
ubi-utils/new-utils/src/ubinfo.c
ubi-utils/new-utils/src/ubinize.c

index a3fc51f6dcbb014adbca68d5e1af3d4a8ed1bade..bd99341c8a6a72629c55883ed66de3593d067199 100644 (file)
@@ -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, ...)  ({                                              \
index f0cbc9ec9298d855d416e0055226038552709cbc..5e6f9b1b595f55dd2b6c77effa3abeea55b8cbb3 100644 (file)
@@ -32,6 +32,9 @@
 #include <limits.h>
 #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;
        }
 
index f52797a49cb987aace4504d7d089581ac43150ce..2e664b8750627937194e052fee463d74bce33f89 100644 (file)
 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.
  *
index a71f087eabe84ef1e39165d455fb24618c53d93f..fdf169a6613a64f5dd184537338ff0ba6ad2397b 100644 (file)
@@ -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
index a78199e3a0c9562fc61b3f1f050d3232b8380993..bd1b07b22511eda8b957b8ea410c47aef977ef80 100644 (file)
@@ -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 {