From 86af65cc32f2902e1f8b3bb5d8f2ce0412a94217 Mon Sep 17 00:00:00 2001 From: Roland Lutz Date: Wed, 7 Jun 2017 19:41:35 +0200 Subject: iceprog: Check for non-applicable options --- iceprog/iceprog.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'iceprog/iceprog.c') diff --git a/iceprog/iceprog.c b/iceprog/iceprog.c index 7886811..31b7a2f 100644 --- a/iceprog/iceprog.c +++ b/iceprog/iceprog.c @@ -433,7 +433,25 @@ int main(int argc, char **argv) errx(EXIT_FAILURE, "options `-b' and `-n' are mutually exclusive"); + if (bulk_erase && (read_mode || check_mode || prog_sram || test_mode)) + errx(EXIT_FAILURE, + "option `-b' only valid in programming mode"); + if (dont_erase && (read_mode || check_mode || prog_sram || test_mode)) + errx(EXIT_FAILURE, + "option `-n' only valid in programming mode"); + + if (rw_offset != 0 && prog_sram) + errx(EXIT_FAILURE, "option `-o' not supported in SRAM mode"); + if (rw_offset != 0 && test_mode) + errx(EXIT_FAILURE, "option `-o' not supported in test mode"); + if (optind + 1 == argc) { + if (test_mode) { + warnx("test mode doesn't take a file name"); + fprintf(stderr, "Try `%s --help' " + "for more information.\n", argv[0]); + return EXIT_FAILURE; + } filename = argv[optind]; } else if (optind != argc) { warnx("too many arguments"); -- cgit v1.2.3