[prev in list] [next in list] [prev in thread] [next in thread] 

List:       flashrom
Subject:    Re: [flashrom] [PATCH 2/2] convert general print messages to msg_g*
From:       Sean Nelson <audiohacked () gmail ! com>
Date:       2010-03-31 0:55:12
Message-ID: 4BB29D70.9080705 () gmail ! com
[Download RAW message or body]

Update to include only flashrom.c, since I agree that the other files 
don't exactly need changing.

["0002-convert-general-print-messages-to-msg_g.patch" (text/plain)]

From cb50fde37199960e1d4411748874e3766fd477c9 Mon Sep 17 00:00:00 2001
From: Sean Nelson <audiohacked@gmail.com>
Date: Tue, 30 Mar 2010 17:07:07 -0700
Subject: [PATCH 2/2] convert general print messages to msg_g*


Signed-off-by: Sean Nelson <audiohacked@gmail.com>
---
 flashrom.c |  142 ++++++++++++++++++++++++++++++------------------------------
 1 files changed, 71 insertions(+), 71 deletions(-)

diff --git a/flashrom.c b/flashrom.c
index 2450dee..87ad066 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -500,56 +500,56 @@ char *extract_param(char **haystack, char *needle, char *delim)
 		if (strchr(delim, *(param_pos - 1)))
 			break;
 		/* Continue searching. */
 		param_pos++;
 		param_pos = strstr(param_pos, needle);
 	} while (1);
 		
 	if (param_pos) {
 		param_pos += strlen(needle);
 		devlen = strcspn(param_pos, delim);
 		if (devlen) {
 			dev = malloc(devlen + 1);
 			if (!dev) {
-				fprintf(stderr, "Out of memory!\n");
+				msg_gerr("Out of memory!\n");
 				exit(1);
 			}
 			strncpy(dev, param_pos, devlen);
 			dev[devlen] = '\0';
 		}
 		rest = param_pos + devlen;
 		rest += strspn(rest, delim);
 		param_pos -= strlen(needle);
 		memmove(param_pos, rest, strlen(rest) + 1);
 		tmp = realloc(*haystack, strlen(*haystack) + 1);
 		if (!tmp) {
-			fprintf(stderr, "Out of memory!\n");
+			msg_gerr("Out of memory!\n");
 			exit(1);
 		}
 		*haystack = tmp;
 	}
 	
 
 	return dev;
 }
 
 /* start is an offset to the base address of the flash chip */
 int check_erased_range(struct flashchip *flash, int start, int len)
 {
 	int ret;
 	uint8_t *cmpbuf = malloc(len);
 
 	if (!cmpbuf) {
-		fprintf(stderr, "Could not allocate memory!\n");
+		msg_gerr("Could not allocate memory!\n");
 		exit(1);
 	}
 	memset(cmpbuf, 0xff, len);
 	ret = verify_range(flash, cmpbuf, start, len, "ERASE");
 	free(cmpbuf);
 	return ret;
 }
 
 /**
  * @cmpbuf	buffer to compare against, cmpbuf[0] is expected to match the
 		flash content at location start
  * @start	offset to the base address of the flash chip
  * @len		length of the verified area
@@ -557,36 +557,36 @@ int check_erased_range(struct flashchip *flash, int start, int \
                len)
  * @return	0 for success, -1 for failure
  */
 int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char \
*message)  {
 	int i, j, starthere, lenhere, ret = 0;
 	int page_size = flash->page_size;
 	uint8_t *readbuf = malloc(page_size);
 	int failcount = 0;
 
 	if (!len)
 		goto out_free;
 
 	if (!flash->read) {
-		fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n");
+		msg_gerr("ERROR: flashrom has no read function for this flash chip.\n");
 		return 1;
 	}
 	if (!readbuf) {
-		fprintf(stderr, "Could not allocate memory!\n");
+		msg_gerr("Could not allocate memory!\n");
 		exit(1);
 	}
 
 	if (start + len > flash->total_size * 1024) {
-		fprintf(stderr, "Error: %s called with start 0x%x + len 0x%x >"
+		msg_gerr("Error: %s called with start 0x%x + len 0x%x >"
 			" total_size 0x%x\n", __func__, start, len,
 			flash->total_size * 1024);
 		ret = -1;
 		goto out_free;
 	}
 	if (!message)
 		message = "VERIFY";
 	
 	/* Warning: This loop has a very unusual condition and body.
 	 * The loop needs to go through each page with at least one affected
 	 * byte. The lowest page number is (start / page_size) since that
 	 * division rounds down. The highest page number we want is the page
 	 * where the last byte of the range lives. That last byte has the
@@ -594,36 +594,36 @@ int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int \
                start, int len, c
 	 * (start + len - 1) / page_size. Since we want to include that last
 	 * page as well, the loop condition uses <=.
 	 */
 	for (i = start / page_size; i <= (start + len - 1) / page_size; i++) {
 		/* Byte position of the first byte in the range in this page. */
 		starthere = max(start, i * page_size);
 		/* Length of bytes in the range in this page. */
 		lenhere = min(start + len, (i + 1) * page_size) - starthere;
 		flash->read(flash, readbuf, starthere, lenhere);
 		for (j = 0; j < lenhere; j++) {
 			if (cmpbuf[starthere - start + j] != readbuf[j]) {
 				/* Only print the first failure. */
 				if (!failcount++)
-					fprintf(stderr, "%s FAILED at 0x%08x! "
+					msg_cerr("%s FAILED at 0x%08x! "
 						"Expected=0x%02x, Read=0x%02x,",
 						message, starthere + j,
 						cmpbuf[starthere - start + j],
 						readbuf[j]);
 			}
 		}
 	}
 	if (failcount) {
-		fprintf(stderr, " failed byte count from 0x%08x-0x%08x: 0x%x\n",
+		msg_cerr(" failed byte count from 0x%08x-0x%08x: 0x%x\n",
 			start, start + len - 1, failcount);
 		ret = -1;
 	}
 
 out_free:
 	free(readbuf);
 	return ret;
 }
 
 /**
  * Check if the buffer @have can be programmed to the content of @want without
  * erasing. This is only possible if all chunks of size @gran are either kept
  * as-is or changed from an all-ones state to any other state.
@@ -728,27 +728,27 @@ int need_erase(uint8_t *have, uint8_t *want, int len, enum \
                write_granularity gra
  * Patterns 10-11 are special purpose for detecting subblock aliasing with
  * block sizes >256 bytes (some Dataflash chips etc.)
  * AND Pattern 8/9 == Pattern 12
  * AND Pattern 10/11 == Pattern 12
  * Pattern 13 is the completely erased state.
  * None of the patterns can detect aliasing at boundaries which are a multiple
  * of 16 MBytes (but such chips do not exist anyway for Parallel/LPC/FWH/SPI).
  */
 int generate_testpattern(uint8_t *buf, uint32_t size, int variant)
 {
 	int i;
 
 	if (!buf) {
-		fprintf(stderr, "Invalid buffer!\n");
+		msg_gerr("Invalid buffer!\n");
 		return 1;
 	}
 
 	switch (variant) {
 	case 0:
 		for (i = 0; i < size; i++)
 			buf[i] = (i & 0xf) << 4 | 0x5;
 		break;
 	case 1:
 		for (i = 0; i < size; i++)
 			buf[i] = (i & 0xf) << 4 | 0xa;
 		break;
 	case 2:
@@ -816,64 +816,64 @@ int generate_testpattern(uint8_t *buf, uint32_t size, int \
variant)  buf[i * 256 + 255] = i & 0xff;
 		}
 	}
 
 	return 0;
 }
 
 int check_max_decode(enum chipbustype buses, uint32_t size)
 {
 	int limitexceeded = 0;
 	if ((buses & CHIP_BUSTYPE_PARALLEL) &&
 	    (max_rom_decode.parallel < size)) {
 		limitexceeded++;
-		printf_debug("Chip size %u kB is bigger than supported "
+		msg_gdbg("Chip size %u kB is bigger than supported "
 			     "size %u kB of chipset/board/programmer "
 			     "for %s interface, "
 			     "probe/read/erase/write may fail. ", size / 1024,
 			     max_rom_decode.parallel / 1024, "Parallel");
 	}
 	if ((buses & CHIP_BUSTYPE_LPC) && (max_rom_decode.lpc < size)) {
 		limitexceeded++;
-		printf_debug("Chip size %u kB is bigger than supported "
+		msg_gdbg("Chip size %u kB is bigger than supported "
 			     "size %u kB of chipset/board/programmer "
 			     "for %s interface, "
 			     "probe/read/erase/write may fail. ", size / 1024,
 			     max_rom_decode.lpc / 1024, "LPC");
 	}
 	if ((buses & CHIP_BUSTYPE_FWH) && (max_rom_decode.fwh < size)) {
 		limitexceeded++;
-		printf_debug("Chip size %u kB is bigger than supported "
+		msg_gdbg("Chip size %u kB is bigger than supported "
 			     "size %u kB of chipset/board/programmer "
 			     "for %s interface, "
 			     "probe/read/erase/write may fail. ", size / 1024,
 			     max_rom_decode.fwh / 1024, "FWH");
 	}
 	if ((buses & CHIP_BUSTYPE_SPI) && (max_rom_decode.spi < size)) {
 		limitexceeded++;
-		printf_debug("Chip size %u kB is bigger than supported "
+		msg_gdbg("Chip size %u kB is bigger than supported "
 			     "size %u kB of chipset/board/programmer "
 			     "for %s interface, "
 			     "probe/read/erase/write may fail. ", size / 1024,
 			     max_rom_decode.spi / 1024, "SPI");
 	}
 	if (!limitexceeded)
 		return 0;
 	/* Sometimes chip and programmer have more than one bus in common,
 	 * and the limit is not exceeded on all buses. Tell the user.
 	 */
 	if (bitcount(buses) > limitexceeded)
 		/* FIXME: This message is designed towards CLI users. */
-		printf_debug("There is at least one common chip/programmer "
+		msg_gdbg("There is at least one common chip/programmer "
 			     "interface which can support a chip of this size. "
 			     "You can try --force at your own risk.\n");
 	return 1;
 }
 
 struct flashchip *probe_flash(struct flashchip *first_flash, int force)
 {
 	struct flashchip *flash;
 	unsigned long base = 0;
 	uint32_t size;
 	enum chipbustype buses_common;
 	char *tmp;
 
@@ -914,78 +914,78 @@ struct flashchip *probe_flash(struct flashchip *first_flash, \
int force)  goto notfound;
 
 		if (first_flash == flashchips
 		    || flash->model_id != GENERIC_DEVICE_ID)
 			break;
 
 notfound:
 		programmer_unmap_flash_region((void *)flash->virtual_memory, size);
 	}
 
 	if (!flash || !flash->name)
 		return NULL;
 
-	printf("Found chip \"%s %s\" (%d KB, %s) at physical address 0x%lx.\n",
+	msg_cinfo("Found chip \"%s %s\" (%d KB, %s) at physical address 0x%lx.\n",
 	       flash->vendor, flash->name, flash->total_size,
 	       flashbuses_to_text(flash->bustype), base);
 
 	if (flash->printlock)
 		flash->printlock(flash);
 
 	return flash;
 }
 
 int verify_flash(struct flashchip *flash, uint8_t *buf)
 {
 	int ret;
 	int total_size = flash->total_size * 1024;
 
-	printf("Verifying flash... ");
+	msg_cinfo("Verifying flash... ");
 
 	ret = verify_range(flash, buf, 0, total_size, NULL);
 
 	if (!ret)
-		printf("VERIFIED.          \n");
+		msg_cinfo("VERIFIED.          \n");
 
 	return ret;
 }
 
 int read_flash(struct flashchip *flash, char *filename)
 {
 	unsigned long numbytes;
 	FILE *image;
 	unsigned long size = flash->total_size * 1024;
 	unsigned char *buf = calloc(size, sizeof(char));
 
 	if (!filename) {
-		printf("Error: No filename specified.\n");
+		msg_gerr("Error: No filename specified.\n");
 		return 1;
 	}
 	if ((image = fopen(filename, "wb")) == NULL) {
 		perror(filename);
 		exit(1);
 	}
-	printf("Reading flash... ");
+	msg_cinfo("Reading flash... ");
 	if (!flash->read) {
-		printf("FAILED!\n");
-		fprintf(stderr, "ERROR: flashrom has no read function for this flash chip.\n");
+		msg_cinfo("FAILED!\n");
+		msg_cerr("ERROR: flashrom has no read function for this flash chip.\n");
 		return 1;
 	} else
 		flash->read(flash, buf, 0, size);
 
 	numbytes = fwrite(buf, 1, size, image);
 	fclose(image);
 	free(buf);
-	printf("%s.\n", numbytes == size ? "done" : "FAILED");
+	msg_cinfo("%s.\n", numbytes == size ? "done" : "FAILED");
 	if (numbytes != size)
 		return 1;
 	return 0;
 }
 
 /* This function shares a lot of its structure with erase_flash().
  * Even if an error is found, the function will keep going and check the rest.
  */
 int selfcheck_eraseblocks(struct flashchip *flash)
 {
 	int i, j, k;
 	int ret = 0;
 
@@ -1007,27 +1007,27 @@ int selfcheck_eraseblocks(struct flashchip *flash)
 			if (!eraser.eraseblocks[i].count &&
 			    eraser.eraseblocks[i].size) {
 				msg_gerr("ERROR: Flash chip %s erase function "
 					"%i region %i has count 0. Please report"
 					" a bug at flashrom@flashrom.org\n",
 					flash->name, k, i);
 				ret = 1;
 			}
 			done += eraser.eraseblocks[i].count *
 				eraser.eraseblocks[i].size;
 		}
 		/* Empty eraseblock definition with erase function.  */
 		if (!done && eraser.block_erase)
-			msg_pspew("Strange: Empty eraseblock definition with "
+			msg_gspew("Strange: Empty eraseblock definition with "
 				"non-empty erase function. Not an error.\n");
 		if (!done)
 			continue;
 		if (done != flash->total_size * 1024) {
 			msg_gerr("ERROR: Flash chip %s erase function %i "
 				"region walking resulted in 0x%06x bytes total,"
 				" expected 0x%06x bytes. Please report a bug at"
 				" flashrom@flashrom.org\n", flash->name, k,
 				done, flash->total_size * 1024);
 			ret = 1;
 		}
 		if (!eraser.block_erase)
 			continue;
@@ -1044,106 +1044,106 @@ int selfcheck_eraseblocks(struct flashchip *flash)
 					flash->name, k, j);
 				ret = 1;
 			}
 		}
 	}
 	return ret;
 }
 
 int erase_flash(struct flashchip *flash)
 {
 	int i, j, k, ret = 0, found = 0;
 	unsigned int start, len;
 
-	printf("Erasing flash chip... ");
+	msg_cinfo("Erasing flash chip... ");
 	for (k = 0; k < NUM_ERASEFUNCTIONS; k++) {
 		unsigned int done = 0;
 		struct block_eraser eraser = flash->block_erasers[k];
 
-		printf_debug("Looking at blockwise erase function %i... ", k);
+		msg_cdbg("Looking at blockwise erase function %i... ", k);
 		if (!eraser.block_erase && !eraser.eraseblocks[0].count) {
-			printf_debug("not defined. "
+			msg_cdbg("not defined. "
 				"Looking for another erase function.\n");
 			continue;
 		}
 		if (!eraser.block_erase && eraser.eraseblocks[0].count) {
-			printf_debug("eraseblock layout is known, but no "
+			msg_cdbg("eraseblock layout is known, but no "
 				"matching block erase function found. "
 				"Looking for another erase function.\n");
 			continue;
 		}
 		if (eraser.block_erase && !eraser.eraseblocks[0].count) {
-			printf_debug("block erase function found, but "
+			msg_cdbg("block erase function found, but "
 				"eraseblock layout is unknown. "
 				"Looking for another erase function.\n");
 			continue;
 		}
 		found = 1;
-		printf_debug("trying... ");
+		msg_cdbg("trying... ");
 		for (i = 0; i < NUM_ERASEREGIONS; i++) {
 			/* count==0 for all automatically initialized array
 			 * members so the loop below won't be executed for them.
 			 */
 			for (j = 0; j < eraser.eraseblocks[i].count; j++) {
 				start = done + eraser.eraseblocks[i].size * j;
 				len = eraser.eraseblocks[i].size;
-				printf_debug("0x%06x-0x%06x, ", start,
+				msg_cdbg("0x%06x-0x%06x, ", start,
 					     start + len - 1);
 				ret = eraser.block_erase(flash, start, len);
 				if (ret)
 					break;
 			}
 			if (ret)
 				break;
 			done += eraser.eraseblocks[i].count *
 				eraser.eraseblocks[i].size;
 		}
-		printf_debug("\n");
+		msg_cdbg("\n");
 		/* If everything is OK, don't try another erase function. */
 		if (!ret)
 			break;
 	}
 	if (!found) {
-		fprintf(stderr, "ERROR: flashrom has no erase function for this flash chip.\n");
+		msg_cerr("ERROR: flashrom has no erase function for this flash chip.\n");
 		return 1;
 	}
 
 	if (ret) {
-		fprintf(stderr, "FAILED!\n");
+		msg_cerr("FAILED!\n");
 	} else {
-		printf("SUCCESS.\n");
+		msg_cinfo("SUCCESS.\n");
 	}
 	return ret;
 }
 
 void emergency_help_message(void)
 {
-	fprintf(stderr, "Your flash chip is in an unknown state.\n"
+	msg_gerr("Your flash chip is in an unknown state.\n"
 		"Get help on IRC at irc.freenode.net (channel #flashrom) or\n"
 		"mail flashrom@flashrom.org!\n--------------------"
 		"-----------------------------------------------------------\n"
 		"DO NOT REBOOT OR POWEROFF!\n");
 }
 
 /* The way to go if you want a delimited list of programmers*/
 void list_programmers(char *delim)
 {
 	enum programmer p;
 	for (p = 0; p < PROGRAMMER_INVALID; p++) {
-		printf("%s", programmer_table[p].name);
+		msg_ginfo("%s", programmer_table[p].name);
 		if (p < PROGRAMMER_INVALID - 1)
-			printf("%s", delim);
+			msg_ginfo("%s", delim);
 	}
-	printf("\n");	
+	msg_ginfo("\n");	
 }
 
 void print_sysinfo(void)
 {
 #if HAVE_UTSNAME == 1
 	struct utsname osinfo;
 	uname(&osinfo);
 
 	msg_ginfo(" on %s %s (%s)", osinfo.sysname, osinfo.release,
 		  osinfo.machine);
 #else
 	msg_ginfo(" on unknown machine");
 #endif
@@ -1162,91 +1162,91 @@ void print_sysinfo(void)
 #ifdef __VERSION__
 	msg_ginfo(" %s", __VERSION__);
 #else
 	msg_ginfo(" unknown version");
 #endif
 #else
 	msg_ginfo(" unknown compiler");
 #endif
 	msg_ginfo("\n");
 }
 
 void print_version(void)
 {
-	printf("flashrom v%s", flashrom_version);
+	msg_ginfo("flashrom v%s\n", flashrom_version);
 	print_sysinfo();
 }
 
 int selfcheck(void)
 {
 	int ret = 0;
 	struct flashchip *flash;
 
 	/* Safety check. Instead of aborting after the first error, check
 	 * if more errors exist.
 	 */
 	if (ARRAY_SIZE(programmer_table) - 1 != PROGRAMMER_INVALID) {
-		fprintf(stderr, "Programmer table miscompilation!\n");
+		msg_gerr("Programmer table miscompilation!\n");
 		ret = 1;
 	}
 	if (spi_programmer_count - 1 != SPI_CONTROLLER_INVALID) {
-		fprintf(stderr, "SPI programmer table miscompilation!\n");
+		msg_gerr("SPI programmer table miscompilation!\n");
 		ret = 1;
 	}
 #if BITBANG_SPI_SUPPORT == 1
 	if (bitbang_spi_master_count - 1 != BITBANG_SPI_INVALID) {
-		fprintf(stderr, "Bitbanging SPI master table miscompilation!\n");
+		msg_gerr("Bitbanging SPI master table miscompilation!\n");
 		ret = 1;
 	}
 #endif
 	for (flash = flashchips; flash && flash->name; flash++)
 		if (selfcheck_eraseblocks(flash))
 			ret = 1;
 	return ret;
 }
 
 void check_chip_supported(struct flashchip *flash)
 {
 	if (TEST_OK_MASK != (flash->tested & TEST_OK_MASK)) {
-		printf("===\n");
+		msg_cinfo("===\n");
 		if (flash->tested & TEST_BAD_MASK) {
-			printf("This flash part has status NOT WORKING for operations:");
+			msg_cinfo("This flash part has status NOT WORKING for operations:");
 			if (flash->tested & TEST_BAD_PROBE)
-				printf(" PROBE");
+				msg_cinfo(" PROBE");
 			if (flash->tested & TEST_BAD_READ)
-				printf(" READ");
+				msg_cinfo(" READ");
 			if (flash->tested & TEST_BAD_ERASE)
-				printf(" ERASE");
+				msg_cinfo(" ERASE");
 			if (flash->tested & TEST_BAD_WRITE)
-				printf(" WRITE");
-			printf("\n");
+				msg_cinfo(" WRITE");
+			msg_cinfo("\n");
 		}
 		if ((!(flash->tested & TEST_BAD_PROBE) && !(flash->tested & TEST_OK_PROBE)) ||
 		    (!(flash->tested & TEST_BAD_READ) && !(flash->tested & TEST_OK_READ)) ||
 		    (!(flash->tested & TEST_BAD_ERASE) && !(flash->tested & TEST_OK_ERASE)) ||
 		    (!(flash->tested & TEST_BAD_WRITE) && !(flash->tested & TEST_OK_WRITE))) {
-			printf("This flash part has status UNTESTED for operations:");
+			msg_cinfo("This flash part has status UNTESTED for operations:");
 			if (!(flash->tested & TEST_BAD_PROBE) && !(flash->tested & TEST_OK_PROBE))
-				printf(" PROBE");
+				msg_cinfo(" PROBE");
 			if (!(flash->tested & TEST_BAD_READ) && !(flash->tested & TEST_OK_READ))
-				printf(" READ");
+				msg_cinfo(" READ");
 			if (!(flash->tested & TEST_BAD_ERASE) && !(flash->tested & TEST_OK_ERASE))
-				printf(" ERASE");
+				msg_cinfo(" ERASE");
 			if (!(flash->tested & TEST_BAD_WRITE) && !(flash->tested & TEST_OK_WRITE))
-				printf(" WRITE");
-			printf("\n");
+				msg_cinfo(" WRITE");
+			msg_cinfo("\n");
 		}
 		/* FIXME: This message is designed towards CLI users. */
-		printf("Please email a report to flashrom@flashrom.org if any "
+		msg_cinfo("Please email a report to flashrom@flashrom.org if any "
 		       "of the above operations\nwork correctly for you with "
 		       "this flash part. Please include the flashrom\noutput "
 		       "with the additional -V option for all operations you "
 		       "tested (-V, -rV,\n-wV, -EV), and mention which "
 		       "mainboard or programmer you tested.\nThanks for your "
 		       "help!\n===\n");
 	}
 }
 
 int main(int argc, char *argv[])
 {
 	return cli_classic(argc, argv);
 }
@@ -1257,127 +1257,127 @@ int main(int argc, char *argv[])
 int doit(struct flashchip *flash, int force, char *filename, int read_it, int \
write_it, int erase_it, int verify_it)  {
 	uint8_t *buf;
 	unsigned long numbytes;
 	FILE *image;
 	int ret = 0;
 	unsigned long size;
 
 	size = flash->total_size * 1024;
 	buf = (uint8_t *) calloc(size, sizeof(char));
 
 	if (erase_it) {
 		if (flash->tested & TEST_BAD_ERASE) {
-			fprintf(stderr, "Erase is not working on this chip. ");
+			msg_cerr("Erase is not working on this chip. ");
 			if (!force) {
-				fprintf(stderr, "Aborting.\n");
+				msg_cerr("Aborting.\n");
 				programmer_shutdown();
 				return 1;
 			} else {
-				fprintf(stderr, "Continuing anyway.\n");
+				msg_cerr("Continuing anyway.\n");
 			}
 		}
 		if (flash->unlock)
 			flash->unlock(flash);
 
 		if (erase_flash(flash)) {
 			emergency_help_message();
 			programmer_shutdown();
 			return 1;
 		}
 	} else if (read_it) {
 		if (flash->unlock)
 			flash->unlock(flash);
 
 		if (read_flash(flash, filename)) {
 			programmer_shutdown();
 			return 1;
 		}
 	} else {
 		struct stat image_stat;
 
 		if (flash->unlock)
 			flash->unlock(flash);
 
 		if (flash->tested & TEST_BAD_ERASE) {
-			fprintf(stderr, "Erase is not working on this chip "
+			msg_cerr("Erase is not working on this chip "
 				"and erase is needed for write. ");
 			if (!force) {
-				fprintf(stderr, "Aborting.\n");
+				msg_cerr("Aborting.\n");
 				programmer_shutdown();
 				return 1;
 			} else {
-				fprintf(stderr, "Continuing anyway.\n");
+				msg_cerr("Continuing anyway.\n");
 			}
 		}
 		if (flash->tested & TEST_BAD_WRITE) {
-			fprintf(stderr, "Write is not working on this chip. ");
+			msg_cerr("Write is not working on this chip. ");
 			if (!force) {
-				fprintf(stderr, "Aborting.\n");
+				msg_cerr("Aborting.\n");
 				programmer_shutdown();
 				return 1;
 			} else {
-				fprintf(stderr, "Continuing anyway.\n");
+				msg_cerr("Continuing anyway.\n");
 			}
 		}
 		if ((image = fopen(filename, "rb")) == NULL) {
 			perror(filename);
 			programmer_shutdown();
 			exit(1);
 		}
 		if (fstat(fileno(image), &image_stat) != 0) {
 			perror(filename);
 			programmer_shutdown();
 			exit(1);
 		}
 		if (image_stat.st_size != flash->total_size * 1024) {
-			fprintf(stderr, "Error: Image size doesn't match\n");
+			msg_gerr("Error: Image size doesn't match\n");
 			programmer_shutdown();
 			exit(1);
 		}
 
 		numbytes = fread(buf, 1, size, image);
 #if INTERNAL_SUPPORT == 1
 		show_id(buf, size, force);
 #endif
 		fclose(image);
 		if (numbytes != size) {
-			fprintf(stderr, "Error: Failed to read file. Got %ld bytes, wanted %ld!\n", \
numbytes, size); +			msg_gerr("Error: Failed to read file. Got %ld bytes, wanted \
%ld!\n", numbytes, size);  programmer_shutdown();
 			return 1;
 		}
 	}
 
 	// This should be moved into each flash part's code to do it 
 	// cleanly. This does the job.
 	handle_romentries(buf, flash);
 
 	// ////////////////////////////////////////////////////////////
 
 	if (write_it) {
-		printf("Writing flash chip... ");
+		msg_cinfo("Writing flash chip... ");
 		if (!flash->write) {
-			fprintf(stderr, "Error: flashrom has no write function for this flash chip.\n");
+			msg_cerr("Error: flashrom has no write function for this flash chip.\n");
 			programmer_shutdown();
 			return 1;
 		}
 		ret = flash->write(flash, buf);
 		if (ret) {
-			fprintf(stderr, "FAILED!\n");
+			msg_cerr("FAILED!\n");
 			emergency_help_message();
 			programmer_shutdown();
 			return 1;
 		} else {
-			printf("COMPLETE.\n");
+			msg_cinfo("COMPLETE.\n");
 		}
 	}
 
 	if (verify_it) {
 		/* Work around chips which need some time to calm down. */
 		if (write_it)
 			programmer_delay(1000*1000);
 		ret = verify_flash(flash, buf);
 		/* If we tried to write, and verification now fails, we
 		 * might have an emergency situation.
 		 */
 		if (ret && write_it)
 			emergency_help_message();
-- 
1.6.6



_______________________________________________
flashrom mailing list
flashrom@flashrom.org
http://www.flashrom.org/mailman/listinfo/flashrom

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic