Stefan Reinauer has submitted this change. ( https://review.coreboot.org/c/em100/+/37493 )
Change subject: Database update: Sanitize first download ......................................................................
Database update: Sanitize first download
Output a sensible message with the new version number even when there is no old database downloaded already.
Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org Change-Id: If05a12715ea2813e1748dd9c5d96d739c82470e0 Reviewed-on: https://review.coreboot.org/c/em100/+/37493 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Patrick Georgi pgeorgi@google.com Reviewed-by: Angel Pons th3fanbus@gmail.com --- M curl.c 1 file changed, 10 insertions(+), 14 deletions(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved Angel Pons: Looks good to me, approved
diff --git a/curl.c b/curl.c index 6895c62..747a98d 100644 --- a/curl.c +++ b/curl.c @@ -133,26 +133,20 @@
int update_all_files(void) { - long old_time, new_time; + long old_time = 0, new_time = 0; char old_version[256] = "<unknown>", new_version[256] = "<unknown>";
/* Read existing version and timestamp */ char *my_version_name = get_em100_file(version_name); FILE *old = fopen(my_version_name, "r"); - if (!old) { - free(my_version_name); - /* We probably don't have any files yet. Try to - * download everything. - */ - goto download_all; + if (old) { + if (fscanf(old, "Time: %ld\nVersion: %255s\n", + &old_time, old_version) != 2) + printf("Parse error in %s.\n", my_version_name); + fclose(old); }
- if (fscanf(old, "Time: %ld\nVersion: %255s\n", - &old_time, old_version) != 2) - printf("Parse error in %s.\n", my_version_name); - free(my_version_name); - fclose(old);
/* Read upstream version and timestamp */ char *tmp_version = get_em100_file(".VERSION.new"); @@ -177,9 +171,11 @@ return 0; }
-download_all: /* Download everything */ - printf("Update available: %s (installed: %s)\n", new_version, old_version); + if (old_time == 0) + printf("Downloading latest version: %s\n", new_version); + else + printf("Update available: %s (installed: %s)\n", new_version, old_version); download(version_name, version_id); download(configs_name, configs_id); download(firmware_name, firmware_id);