core/flash: Ignore prefix when comparing versions.

Message ID 20181010063240.32331-1-sam@mendozajonas.com
State Accepted
Headers show
Series
  • core/flash: Ignore prefix when comparing versions.
Related show

Checks

Context Check Description
snowpatch_ozlabs/make_check success Test make_check on branch master
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Samuel Mendoza-Jonas Oct. 10, 2018, 6:32 a.m.
The Skiboot version can include a "skiboot-" prefix if built with
something like Buildroot. The property being compared against won't
include this so ignore it.

Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
---
 core/flash.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

Comments

Vasant Hegde Oct. 12, 2018, 6:49 a.m. | #1
On 10/10/2018 12:02 PM, Samuel Mendoza-Jonas wrote:
> The Skiboot version can include a "skiboot-" prefix if built with
> something like Buildroot. The property being compared against won't
> include this so ignore it.
> 
> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>

Looks good.

Reviewed-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>

-Vasant
Stewart Smith Oct. 16, 2018, 8 a.m. | #2
Samuel Mendoza-Jonas <sam@mendozajonas.com> writes:
> The Skiboot version can include a "skiboot-" prefix if built with
> something like Buildroot. The property being compared against won't
> include this so ignore it.
>
> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
> ---
>  core/flash.c | 18 ++++++++++++++++--
>  1 file changed, 16 insertions(+), 2 deletions(-)

Thanks, merged to master as of c0375a62396d09874b4dd84a13904b89e6f96b60

Patch

diff --git a/core/flash.c b/core/flash.c
index 8e7b90e6..b4bf5516 100644
--- a/core/flash.c
+++ b/core/flash.c
@@ -160,6 +160,7 @@  static void __flash_dt_add_fw_version(struct dt_node *fw_version, char* data)
 	char *prop;
 	int version_len, i;
 	int len = strlen(data);
+	const char *skiboot_version;
 	const char * version_str[] = {"open-power", "buildroot", "skiboot",
 				      "hostboot-binaries", "hostboot", "linux",
 				      "petitboot", "occ", "capp-ucode", "sbe",
@@ -213,9 +214,22 @@  static void __flash_dt_add_fw_version(struct dt_node *fw_version, char* data)
 		prop = data + version_len + 1;
 		dt_add_property_string(fw_version, version_str[i], prop);
 
-		if (strncmp(version_str[i], "skiboot", strlen("skiboot")) == 0)
-			if (strncmp(prop, version, strlen(version)) != 0)
+		/* Sanity check against what Skiboot thinks its version is. */
+		if (strncmp(version_str[i], "skiboot",
+					strlen("skiboot")) == 0) {
+			/*
+			 * If Skiboot was built with Buildroot its version may
+			 * include a 'skiboot-' prefix; ignore it.
+			 */
+			if (strncmp(version, "skiboot-",
+						strlen("skiboot-")) == 0)
+				skiboot_version = version + strlen("skiboot-");
+			else
+				skiboot_version = version;
+			if (strncmp(prop, skiboot_version,
+						strlen(skiboot_version)) != 0)
 				prlog(PR_WARNING, "WARNING! Skiboot version does not match VERSION partition!\n");
+		}
 	}
 }