From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=pass header.i=@linaro.org header.s=google header.b=uPVjpXAG; spf=pass (domain: linaro.org, ip: 209.85.128.50, mailfrom: leif.lindholm@linaro.org) Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by groups.io with SMTP; Thu, 13 Jun 2019 09:18:40 -0700 Received: by mail-wm1-f50.google.com with SMTP id g135so10843044wme.4 for ; Thu, 13 Jun 2019 09:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=IhXMiF/W8QDARp1XrtfZNHaE9Q3v3vjD3c82jScO2RI=; b=uPVjpXAGnLJuiBc7zRXBhwAXlks/KfA3eY1Qvhi3thD9vOoeBFXCbb8aq2nyWUIsXM KIlx754oEZdKgVu9PHiGj5EnCAHGjtANN04kbdcn6g4RBWlmHhCkJgO9xnPT1KDTexLx 2nGWmqzzskJQiRKRaIwNGkV49Srp2oddiVrXlVBZMMIAy+uh2S0TbHyxnHyn3L1+TP9H mkNDZ9NqWMXAqH+V2MITp+vi2TLwTk+DWifXWIT2OnbB/eBOF/biJxUJiGUFm5FWAIQg e7kl9R/53hZD6GPmV/FZXerzWYx/1fI9CwZGLjHT73A33DDribqnKvyZA2c9XmVU33Du NDRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=IhXMiF/W8QDARp1XrtfZNHaE9Q3v3vjD3c82jScO2RI=; b=gApXUN7WTsifS44EFPvY3ZAOjuCpYdyx8StUkrXh5QmbGiZ2kSor6DX9UkiQSC27YX olFejFM0UJ1P2DQ2KeJVbzYz7aITDxZe46LteltvIIL+jDeyQDG3Mq4++Y3XdVaatVp6 cOxW/aC45xVw3HX7ZLyBpjqMYSq/silZbCdW8xhPM99tnOCtnrNwTZn3rA0y+FT+ko2A P1aYdIUx6P9k2v/WIMJIVPY7ApsQc7rg+NzN33hXU5JvG+FDLEmGK7AIyQqhtg1CwbxF KU9GqmqxKJeGqq6yhGEjAxS7V6N06IAJEr192tjd+us14KV84YMmAIeT4P8xNVop8FmM u5CA== X-Gm-Message-State: APjAAAV57mQxKy7y410YUX8VzNqZkIxw5ZsQynp3I7AfQ9gB0CFRFFWh 7vubB0+QqiVs6XIP5yQPvWu5tT+HetC/zg== X-Google-Smtp-Source: APXvYqwPr7KdxqgMhbbMvQUxIbExKFvDm7dp99J5p4NE1YGKPE3M7BDG4lEpEhPOh1HZeVb3ZCUuQg== X-Received: by 2002:a1c:7604:: with SMTP id r4mr4493301wmc.89.1560442718106; Thu, 13 Jun 2019 09:18:38 -0700 (PDT) Return-Path: Received: from vanye.hemma.eciton.net (cpc92302-cmbg19-2-0-cust304.5-4.cable.virginm.net. [82.1.209.49]) by smtp.gmail.com with ESMTPSA id s10sm171671wrw.45.2019.06.13.09.18.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jun 2019 09:18:37 -0700 (PDT) From: "Leif Lindholm" To: devel@edk2.groups.io Cc: ard.biesheuvel@linaro.org, Alexei Fedorov Subject: [PATCH 2/2] EmbeddedPkg: improve TimeBaseLib type safety Date: Thu, 13 Jun 2019 17:18:33 +0100 Message-Id: <20190613161833.30102-3-leif.lindholm@linaro.org> X-Mailer: git-send-email 2.11.0 EfiTimeToEpoch currently returns a UINTN. Also, some internal calculations was using UINTN for fixed-width. Both of these lead to warnings/errors with VS2017. Replace with appropriate fixed-size types. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=997 Cc: Alexei Fedorov Signed-off-by: Leif Lindholm --- EmbeddedPkg/Include/Library/TimeBaseLib.h | 4 ++-- EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/EmbeddedPkg/Include/Library/TimeBaseLib.h b/EmbeddedPkg/Include/Library/TimeBaseLib.h index d51059cb1f7d..4103c89b3891 100644 --- a/EmbeddedPkg/Include/Library/TimeBaseLib.h +++ b/EmbeddedPkg/Include/Library/TimeBaseLib.h @@ -1,7 +1,7 @@ /** @file * * Copyright (c) 2016, Hisilicon Limited. All rights reserved. -* Copyright (c) 2016, Linaro Limited. All rights reserved. +* Copyright (c) 2016-2019, Linaro Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -53,7 +53,7 @@ EpochToEfiTime ( /** Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) **/ -UINTN +UINT32 EFIAPI EfiTimeToEpoch ( IN EFI_TIME *Time diff --git a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c index 662cbdd5da99..136ce8a51e86 100644 --- a/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c +++ b/EmbeddedPkg/Library/TimeBaseLib/TimeBaseLib.c @@ -1,7 +1,7 @@ /** @file * * Copyright (c) 2016, Hisilicon Limited. All rights reserved. -* Copyright (c) 2016, Linaro Limited. All rights reserved. +* Copyright (c) 2016-2019, Linaro Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -53,9 +53,9 @@ EpochToEfiTime ( m = (((da * 5) + 308) / 153) - 2; d = da - (((m + 4) * 153) / 5) + 122; - Time->Year = y - 4800 + ((m + 2) / 12); + Time->Year = (UINT16)(y - 4800 + ((m + 2) / 12)); Time->Month = ((m + 2) % 12) + 1; - Time->Day = d + 1; + Time->Day = (UINT8)(d + 1); ss = EpochSeconds % 60; a = (EpochSeconds - ss) / 60; @@ -63,9 +63,9 @@ EpochToEfiTime ( b = (a - mm) / 60; hh = b % 24; - Time->Hour = hh; - Time->Minute = mm; - Time->Second = ss; + Time->Hour = (UINT8)hh; + Time->Minute = (UINT8)mm; + Time->Second = (UINT8)ss; Time->Nanosecond = 0; } @@ -99,14 +99,14 @@ EfiGetEpochDays ( /** Converts EFI_TIME to Epoch seconds (elapsed since 1970 JANUARY 01, 00:00:00 UTC) **/ -UINTN +UINT32 EFIAPI EfiTimeToEpoch ( IN EFI_TIME *Time ) { - UINTN EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY - UINTN EpochSeconds; + UINT32 EpochDays; // Number of days elapsed since EPOCH_JULIAN_DAY + UINT32 EpochSeconds; EpochDays = EfiGetEpochDays (Time); -- 2.11.0