summaryrefslogtreecommitdiff
path: root/mtd_debug.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2010-09-26 14:48:51 -0400
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2010-09-27 09:31:10 +0300
commite960f7eb17f8d72f00364e9fc9f9a27b5563e318 (patch)
tree9c64699e742b6d220539a8827e29a662d9629fb7 /mtd_debug.c
parent6edaa0c971aab663cda573ded5013b3b998ee5d4 (diff)
mtd-utils: standardize PROGRAM_NAME
Make sure all the utils define PROGRAM_NAME and do so at the start of the file so that sub-headers may assume it exists. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'mtd_debug.c')
-rw-r--r--mtd_debug.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/mtd_debug.c b/mtd_debug.c
index 928cb5a..b82dabe 100644
--- a/mtd_debug.c
+++ b/mtd_debug.c
@@ -27,6 +27,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define PROGRAM_NAME "mtd_debug"
+
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
@@ -347,17 +349,14 @@ int showinfo (int fd)
return (0);
}
-void showusage (const char *progname)
+void showusage(void)
{
fprintf (stderr,
- "usage: %s info <device>\n"
- " %s read <device> <offset> <len> <dest-filename>\n"
- " %s write <device> <offset> <len> <source-filename>\n"
- " %s erase <device> <offset> <len>\n",
- progname,
- progname,
- progname,
- progname);
+ "usage: %1$s info <device>\n"
+ " %1$s read <device> <offset> <len> <dest-filename>\n"
+ " %1$s write <device> <offset> <len> <source-filename>\n"
+ " %1$s erase <device> <offset> <len>\n",
+ PROGRAM_NAME);
exit (1);
}
@@ -368,10 +367,8 @@ void showusage (const char *progname)
int main (int argc,char *argv[])
{
- const char *progname;
int err = 0,fd,option = OPT_INFO;
int open_flag;
- (progname = strrchr (argv[0],'/')) ? progname++ : (progname = argv[0]);
/* parse command-line options */
if (argc == 3 && !strcmp (argv[1],"info"))
@@ -383,7 +380,7 @@ int main (int argc,char *argv[])
else if (argc == 5 && !strcmp (argv[1],"erase"))
option = OPT_ERASE;
else
- showusage (progname);
+ showusage();
/* open device */
open_flag = (option==OPT_INFO || option==OPT_READ) ? O_RDONLY : O_RDWR;