The branch main has been updated by kp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=207f938bc56338e6ff41e10b16610a236e1c6270

commit 207f938bc56338e6ff41e10b16610a236e1c6270
Author:     Kristof Provost <k...@freebsd.org>
AuthorDate: 2025-02-21 08:25:57 +0000
Commit:     Kristof Provost <k...@freebsd.org>
CommitDate: 2025-02-21 08:25:57 +0000

    snmp_pf: address Coverity remarks about time_t
    
    On most platforms time_t is 64 bits wide, but we assign it to 32 bits
    variables. Unfortunately these are SNMP fields that are defined to be 32 
bits
    wide, so we cannot change this. We are similarly unable to prevent the 
passage
    of time, meaning that time_t must remain 64 bits wide as well.
    
    Explicitly cast to tell Coverity that we're aware of these limitations and 
do
    not wish to be reminded of them.
    
    CID:            1553869
    CID:            1557025
    CID:            1592232
    CID:            1592234
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
---
 usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c 
b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
index 9f7e6d4f31cb..782e5503c8a3 100644
--- a/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
+++ b/usr.sbin/bsnmpd/modules/snmp_pf/pf_snmp.c
@@ -171,7 +171,7 @@ pf_status(struct snmp_context __unused *ctx, struct 
snmp_value *val,
                        case LEAF_pfStatusRuntime:
                            runtime = (pfs->since > 0) ?
                                time(NULL) - pfs->since : 0;
-                           val->v.uint32 = runtime * 100;
+                           val->v.uint32 = (uint32_t)(runtime * 100);
                            break;
                        case LEAF_pfStatusDebug:
                            val->v.uint32 = pfs->debug;
@@ -586,7 +586,7 @@ pf_iftable(struct snmp_context __unused *ctx, struct 
snmp_value *val,
                        break;
                case LEAF_pfInterfacesIfTZero:
                        val->v.uint32 =
-                           (time(NULL) - e->pfi.pfik_tzero) * 100;
+                           (uint32_t)(time(NULL) - e->pfi.pfik_tzero) * 100;
                        break;
                case LEAF_pfInterfacesIfRefsRule:
                        val->v.uint32 = e->pfi.pfik_rulerefs;
@@ -733,7 +733,7 @@ pf_tbltable(struct snmp_context __unused *ctx, struct 
snmp_value *val,
                        break;
                case LEAF_pfTablesTblTZero:
                        val->v.uint32 =
-                           (time(NULL) - e->pft.pfrts_tzero) * 100;
+                           (uint32_t)(time(NULL) - e->pft.pfrts_tzero) * 100;
                        break;
                case LEAF_pfTablesTblRefsAnchor:
                        val->v.integer =
@@ -862,7 +862,7 @@ pf_tbladdr(struct snmp_context __unused *ctx, struct 
snmp_value __unused *val,
                        break;
                case LEAF_pfTablesAddrTZero:
                        val->v.uint32 =
-                           (time(NULL) - e->pfas.pfras_tzero) * 100;
+                           (uint32_t)(time(NULL) - e->pfas.pfras_tzero) * 100;
                        break;
                case LEAF_pfTablesAddrBytesInPass:
                        val->v.counter64 =

Reply via email to