ACK: [PATCH] sbbr: fadt: clean up major/minor version checking
ivanhu
ivan.hu at canonical.com
Wed Jan 16 01:53:20 UTC 2019
On 1/15/19 7:13 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Static analysis by smatch is warning about the minor version, clean
> this up by making a major/minor uint16_t value that allows comparisons
> without this warning. Also add minor clean up of the major/minor
> initializations.
>
> Cleans up warning:
> warn: always true condition '(minor >= SBBR_LATEST_MINOR) => (0-255 >= 0)'
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/sbbr/fadt/fadt.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/src/sbbr/fadt/fadt.c b/src/sbbr/fadt/fadt.c
> index 91e3233c..23ca1a03 100644
> --- a/src/sbbr/fadt/fadt.c
> +++ b/src/sbbr/fadt/fadt.c
> @@ -59,21 +59,22 @@ static int fadt_sbbr_init(fwts_framework *fw)
> return FWTS_OK;
> }
>
> +#define SBBR_VERSION(major, minor) ((((uint16_t)(major)) << 8) | (minor))
> +
> static int fadt_sbbr_revision_test1(fwts_framework *fw)
> {
> const uint8_t SBBR_LATEST_MAJOR = 6;
> const uint8_t SBBR_LATEST_MINOR = 0;
> - uint8_t major;
> - uint8_t minor;
> + uint8_t major = fadt->header.revision;
> + uint8_t minor = 0;
>
> - major = fadt->header.revision;
> - minor = 0;
> - if (major >= 5 && fadt->header.length >= 268)
> + if ((major >= 5) && (fadt->header.length >= 268))
> minor = fadt->minor_version; /* field added ACPI 5.1 */
>
> fwts_log_info(fw, "FADT revision: %" PRIu8 ".%" PRIu8, major, minor);
>
> - if (major >= SBBR_LATEST_MAJOR && minor >= SBBR_LATEST_MINOR)
> + if (SBBR_VERSION(major, minor) >=
> + SBBR_VERSION(SBBR_LATEST_MAJOR, SBBR_LATEST_MINOR))
> fwts_passed(fw, "FADT revision is up to date.");
> else {
> fwts_failed(fw, LOG_LEVEL_CRITICAL, "fadt_revision:",
Acked-by: Ivan Hu <ivan.hu at canonical.com>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.ubuntu.com/archives/fwts-devel/attachments/20190116/7b9c4194/attachment.sig>
More information about the fwts-devel
mailing list