NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/58380: net_stats.h is type-unsafe due to unnecessary void *



>Number:         58380
>Category:       kern
>Synopsis:       net_stats.h is type-unsafe due to unnecessary void *
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jun 29 11:25:00 +0000 2024
>Originator:     Taylor R Campbell
>Release:        current, 10
>Organization:
The NetBSD void*ation
>Environment:
>Description:
sys/net/net_stats.h defines

typedef void *net_stat_ref_t;

which hides type errors in usage of any API routines that accept net_stat_ref_t.

For example, in if_scx.c, we have:

   1402 				if_statinc_ref(ifp, if_oerrors);

https://nxr.netbsd.org/xref/src/sys/arch/arm/sociox/if_scx.c?r=1.43#1402

This compiles just fine, but won't work very well at runtime!
>How-To-Repeat:
code inspection
>Fix:
typedef struct net_stat_ref {
	uint64_t nsr_stat[];
} *net_stat_ref_t;

Also maybe make the macros in net_stats.h be inline functions instead -- I don't see any reason why they need to be macros.



Home | Main Index | Thread Index | Old Index