From fbb9879c0cacca8144ef0faf67d031378febe264 Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Thu, 30 Jan 2020 18:28:02 +0000 Subject: [PATCH] Fix use of an uninitialized variable. ctx (and thus ctx.flags) is stack garbage at the start of this function, so initialize ctx.flags to an explicit value instead of using binary operations on the garbage. Reported by: gcc9 Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D23368 --- sys/kern/subr_stats.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sys/kern/subr_stats.c b/sys/kern/subr_stats.c index a212f739deca..6181cf7bad74 100644 --- a/sys/kern/subr_stats.c +++ b/sys/kern/subr_stats.c @@ -1583,9 +1583,7 @@ stats_v1_blob_iter(struct statsblobv1 *sb, stats_v1_blob_itercb_t icb, int i, j, firstvoi; ctx.usrctx = usrctx; - ctx.flags |= SB_IT_FIRST_CB; - ctx.flags &= ~(SB_IT_FIRST_VOI | SB_IT_LAST_VOI | SB_IT_FIRST_VOISTAT | - SB_IT_LAST_VOISTAT); + ctx.flags = SB_IT_FIRST_CB; firstvoi = 1; for (i = 0; i < NVOIS(sb); i++) {