From e960f7eb17f8d72f00364e9fc9f9a27b5563e318 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sun, 26 Sep 2010 14:48:51 -0400 Subject: 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 Signed-off-by: Artem Bityutskiy --- flashcp.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'flashcp.c') 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 #include #include @@ -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 \n" "\n" - "usage: %s [ -v | --verbose ] \n" - " %s -h | --help\n" + "usage: %1$s [ -v | --verbose ] \n" + " %1$s -h | --help\n" "\n" " -h | --help Show this help message\n" " -v | --verbose Show progress reports\n" " File which you want to copy to flash\n" " 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); -- cgit v1.2.3