summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeert Uytterhoeven <geert@linux-m68k.org>2010-06-23 21:34:05 +0200
committerGeert Uytterhoeven <geert@linux-m68k.org>2010-06-23 21:36:26 +0200
commit9ba58bee23543aba0d4087dfad65c0489afc6d95 (patch)
treeb794aac21bce11f55cc86b26c48be1a9689eadeb
parentc607b61ecbe30fdf71afca81eb671172208bd234 (diff)
downloadamiga-nvram-9ba58bee23543aba0d4087dfad65c0489afc6d95.tar.gz
Move checksum printing inside nvram_dump()
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
-rw-r--r--amiga-nvram.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/amiga-nvram.c b/amiga-nvram.c
index e21825a..3e9fc04 100644
--- a/amiga-nvram.c
+++ b/amiga-nvram.c
@@ -202,6 +202,7 @@ static uint32_t nvram_get_field(const struct nvram_field *field)
static void nvram_dump(void)
{
unsigned int i;
+ uint8_t sum;
for (i = 0; i < ARRAY_SIZE(nvram_fields); i++) {
const struct nvram_field *field = &nvram_fields[i];
@@ -211,6 +212,12 @@ static void nvram_dump(void)
else
printf("%-23s= %u\n", field->name, val);
}
+ printf("checksum = 0x%02x ", nvram.checksum);
+ sum = nvram_checksum();
+ if (sum == nvram.checksum)
+ puts("[correct]");
+ else
+ printf("[not correct, should be 0x%02x]\n", sum);
}
@@ -236,7 +243,6 @@ int main(int argc, char *argv[])
{
program_name = argv[0];
int error;
- uint8_t sum;
while (argc > 1) {
if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))
@@ -266,20 +272,16 @@ int main(int argc, char *argv[])
if (error)
exit(-1);
- sum = nvram_checksum();
-
if (!opt_quiet) {
nvram_dump();
- printf("checksum = 0x%02x ", nvram.checksum);
- if (sum == nvram.checksum)
- puts("[correct]");
- else
- printf("[not correct, should be 0x%02x]\n", sum);
}
- if (opt_checksum && sum != nvram.checksum) {
- msg("Correcting checksum\n");
- nvram.checksum = sum;
+ if (opt_checksum) {
+ uint8_t sum = nvram_checksum();
+ if (sum != nvram.checksum) {
+ msg("Correcting checksum\n");
+ nvram.checksum = sum;
+ }
}
error = nvram_write();