aboutsummaryrefslogtreecommitdiff
path: root/flashcp.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 /flashcp.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 'flashcp.c')
-rw-r--r--flashcp.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/flashcp.c b/flashcp.c
index 8775022..d58c81b 100644
--- a/flashcp.c
+++ b/flashcp.c
@@ -29,6 +29,8 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#define PROGRAM_NAME "flashcp"
+
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
@@ -84,7 +86,7 @@ static void log_printf (int level,const char *fmt, ...)
fflush (fp);
}
-static void showusage (const char *progname,bool error)
+static void showusage(bool error)
{
int level = error ? LOG_ERROR : LOG_NORMAL;
@@ -92,15 +94,15 @@ static void showusage (const char *progname,bool error)
"\n"
"Flash Copy - Written by Abraham van der Merwe <abraham@2d3d.co.za>\n"
"\n"
- "usage: %s [ -v | --verbose ] <filename> <device>\n"
- " %s -h | --help\n"
+ "usage: %1$s [ -v | --verbose ] <filename> <device>\n"
+ " %1$s -h | --help\n"
"\n"
" -h | --help Show this help message\n"
" -v | --verbose Show progress reports\n"
" <filename> File which you want to copy to flash\n"
" <device> Flash device to write to (e.g. /dev/mtd0, /dev/mtd1, etc.)\n"
"\n",
- progname,progname);
+ PROGRAM_NAME);
exit (error ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -165,7 +167,7 @@ static void cleanup (void)
int main (int argc,char *argv[])
{
- const char *progname,*filename = NULL,*device = NULL;
+ const char *filename = NULL,*device = NULL;
int i,flags = FLAG_NONE;
ssize_t result;
size_t size,written;
@@ -174,8 +176,6 @@ int main (int argc,char *argv[])
struct stat filestat;
unsigned char src[BUFSIZE],dest[BUFSIZE];
- (progname = strrchr (argv[0],'/')) ? progname++ : (progname = argv[0]);
-
/*********************
* parse cmd-line
*****************/
@@ -206,7 +206,7 @@ int main (int argc,char *argv[])
break;
default:
DEBUG("Unknown parameter: %s\n",argv[option_index]);
- showusage (progname,true);
+ showusage(true);
}
}
if (optind+2 == argc) {
@@ -219,8 +219,8 @@ int main (int argc,char *argv[])
DEBUG("Got device: %s\n",device);
}
- if (flags & FLAG_HELP || progname == NULL || device == NULL)
- showusage (progname,flags != FLAG_HELP);
+ if (flags & FLAG_HELP || device == NULL)
+ showusage(flags != FLAG_HELP);
atexit (cleanup);