|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH] Cast Name to a ULONG before checking its valid
On 12/10/2026 14:28, Owen Smith wrote:
> MSVC treats all unscoped enums as an int, so the signed value needs
> casting to an unsigned before only checking against the maximum enum
> value.
> Fixes
> warning C33010: Unchecked lower bound for enum Name used as index
>
> Signed-off-by: Owen Smith <owen.smith@xxxxxxxxxx>
Reviewed-by: Tu Dinh <ngoc-tu.dinh@xxxxxxxxxx>
> ---
> src/xenvif/frontend.c | 6 +++---
> src/xenvif/vif.c | 2 +-
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/src/xenvif/frontend.c b/src/xenvif/frontend.c
> index 4b4e69f..b1701cf 100644
> --- a/src/xenvif/frontend.c
> +++ b/src/xenvif/frontend.c
> @@ -1797,11 +1797,11 @@ __FrontendQueryStatistic(
> {
> ULONG Index;
>
> - ASSERT3U(Name, <, XENVIF_VIF_STATISTIC_COUNT);
> + ASSERT3U((ULONG)Name, <, XENVIF_VIF_STATISTIC_COUNT);
>
> *Value = 0;
>
> - if (Name >= XENVIF_VIF_STATISTIC_COUNT)
> + if ((ULONG)Name >= XENVIF_VIF_STATISTIC_COUNT)
> return;
>
> for (Index = 0; Index < Frontend->StatisticsCount; Index++) {
> @@ -1833,7 +1833,7 @@ FrontendIncrementStatistic(
> PXENVIF_FRONTEND_STATISTICS Statistics;
> KIRQL Irql;
>
> - ASSERT3U(Name, <, XENVIF_VIF_STATISTIC_COUNT);
> + ASSERT3U((ULONG)Name, <, XENVIF_VIF_STATISTIC_COUNT);
>
> KeRaiseIrql(DISPATCH_LEVEL, &Irql);
>
> diff --git a/src/xenvif/vif.c b/src/xenvif/vif.c
> index 7328543..4937bb6 100644
> --- a/src/xenvif/vif.c
> +++ b/src/xenvif/vif.c
> @@ -521,7 +521,7 @@ VifQueryStatistic(
> NTSTATUS status;
>
> status = STATUS_INVALID_PARAMETER;
> - if (Index >= XENVIF_VIF_STATISTIC_COUNT)
> + if ((ULONG)Index >= XENVIF_VIF_STATISTIC_COUNT)
> goto done;
>
> AcquireMrswLockShared(&Context->Lock);
--
Ngoc Tu Dinh | Vates XCP-ng Developer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |