From: Brian Norris <computersforpeace@gmail.com>
To: Artem Bityutskiy <dedekind1@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
Brian Norris <computersforpeace@gmail.com>,
linux-mtd@lists.infradead.org,
Mike Frysinger <vapier.adi@gmail.com>,
Kevin Cernekee <cernekee@gmail.com>
Subject: [PATCH 2/2] mtdinfo: provide info when used without arguments
Date: Wed, 16 Nov 2011 12:03:57 -0800 [thread overview]
Message-ID: <1321473837-27891-3-git-send-email-computersforpeace@gmail.com> (raw)
In-Reply-To: <1321473837-27891-1-git-send-email-computersforpeace@gmail.com>
If the user specifies neither a MTD argument nor the `-a' flag, we print
a cryptic message; i.e.,
# mtdinfo
libmtd: error!: cannot get information about "(null)"
error 14 (Bad address)
mtdinfo: error!: cannot get information about MTD device "(null)"
error 14 (Bad address)
This is a regression; previously, mtdinfo would give some short info
about number of devices, etc. when used without arguments. To fix this,
we revert commit d53c03b0989f8354a7e4dbb947a150fc7fe3f6d1 and call
print_general_info() when no device is specified.
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
---
ubi-utils/mtdinfo.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c
index d919673..ead4bce 100644
--- a/ubi-utils/mtdinfo.c
+++ b/ubi-utils/mtdinfo.c
@@ -340,7 +340,8 @@ static int print_dev_info(libmtd_t libmtd, const struct mtd_info *mtd_info, int
return 0;
}
-static int print_general_info(libmtd_t libmtd, const struct mtd_info *mtd_info)
+static int print_general_info(libmtd_t libmtd, const struct mtd_info *mtd_info,
+ int all)
{
int i, err, first = 1;
struct mtd_dev_info mtd;
@@ -367,9 +368,14 @@ static int print_general_info(libmtd_t libmtd, const struct mtd_info *mtd_info)
}
}
printf("\n");
- printf("Sysfs interface supported: %s\n\n",
+ printf("Sysfs interface supported: %s\n",
mtd_info->sysfs_supported ? "yes" : "no");
+ if (!all)
+ return 0;
+
+ printf("\n");
+
for (i = mtd_info->lowest_mtd_num;
i <= mtd_info->highest_mtd_num; i++) {
err = print_dev_info(libmtd, mtd_info, i);
@@ -404,7 +410,7 @@ int main(int argc, char * const argv[])
return sys_errmsg("cannot get MTD information");
}
- if (!args.all) {
+ if (!args.all && args.node) {
int mtdn;
/*
@@ -416,7 +422,7 @@ int main(int argc, char * const argv[])
goto out_libmtd;
err = print_dev_info(libmtd, &mtd_info, mtdn);
} else
- err = print_general_info(libmtd, &mtd_info);
+ err = print_general_info(libmtd, &mtd_info, args.all);
if (err)
goto out_libmtd;
--
1.7.5.4
next prev parent reply other threads:[~2011-11-16 20:04 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-16 20:03 [PATCH 0/2] small mtd-utils fixes Brian Norris
2011-11-16 20:03 ` [PATCH 1/2] mtd-utils: add jffs2reader to .gitignore Brian Norris
2011-11-17 5:40 ` Mike Frysinger
2011-11-16 20:03 ` Brian Norris [this message]
2011-11-17 5:41 ` [PATCH 2/2] mtdinfo: provide info when used without arguments Mike Frysinger
2011-11-17 22:19 ` [PATCH 0/2] small mtd-utils fixes Artem Bityutskiy
2011-11-17 23:56 ` Brian Norris
2011-11-18 22:00 ` Artem Bityutskiy
2011-11-18 22:44 ` Peter Korsgaard
2011-11-18 23:37 ` Brian Norris
2011-11-19 20:47 ` Artem Bityutskiy
2011-11-19 20:55 ` Mike Frysinger
2011-11-19 23:04 ` Artem Bityutskiy
2011-11-20 8:41 ` Mike Frysinger
2011-11-20 13:10 ` Artem Bityutskiy
2011-11-20 11:55 ` David Woodhouse
2011-11-20 13:08 ` Artem Bityutskiy
2011-11-21 4:22 ` Mike Frysinger
2011-11-22 21:38 ` Artem Bityutskiy
2011-11-22 22:21 ` Mike Frysinger
2011-11-23 7:45 ` Artem Bityutskiy
2011-11-24 1:45 ` Mike Frysinger
2011-11-24 7:26 ` Artem Bityutskiy
2011-12-05 0:28 ` Mike Frysinger
2011-12-07 7:12 ` Artem Bityutskiy
2011-11-23 9:38 ` Artem Bityutskiy
2011-11-22 22:21 ` Mike Frysinger
2011-11-23 9:39 ` Artem Bityutskiy
2011-11-17 22:22 ` Artem Bityutskiy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321473837-27891-3-git-send-email-computersforpeace@gmail.com \
--to=computersforpeace@gmail.com \
--cc=cernekee@gmail.com \
--cc=dedekind1@gmail.com \
--cc=dwmw2@infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=vapier.adi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).