Page MenuHomeFreeBSD

Remove misleading / redundant bzero in callout_callwheel_init
ClosedPublic

Authored by cem on Mar 16 2020, 9:21 PM.
Tags
None
Referenced Files
F140172927: D24089.diff
Sun, Dec 21, 2:40 AM
Unknown Object (File)
Wed, Nov 26, 1:17 PM
Unknown Object (File)
Nov 20 2025, 3:09 PM
Unknown Object (File)
Nov 20 2025, 3:07 PM
Unknown Object (File)
Nov 20 2025, 3:06 PM
Unknown Object (File)
Nov 20 2025, 2:57 PM
Unknown Object (File)
Nov 18 2025, 7:47 AM
Unknown Object (File)
Nov 8 2025, 12:39 AM
Subscribers

Details

Summary

The intent seems to be zeroing all of the cc_cpu array, or its singleton on
such platforms. The assumption made is that (1), the BSP is always zero
(true enough), and (2), that passing a pointer of limited scope (element
zero) to memset() will correctly zero the entire array, rather than invoke
nasal demons.

So, more succinctly, the expression could be: memset(cc_cpu,0,sizeof(cc_cpu)).

However, there's no point. cc_cpu lives in the data section and has a zero
initial value already. So this revision just removes the line.

No functional change. Appeases a (false positive, ish) Coverity CID.

CID: 1383567
Reported by: Puneeth Jothaiah <puneethkumar.jothaia AT dell.com>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

I do not understand what are you trying to say by the item 2.

The weirdness came in from r326218.

This revision is now accepted and ready to land.Mar 16 2020, 9:42 PM

Thanks for taking a quick look.

Re (2), I believe I was confusing pointers to struct members with pointers to array elements. I will drop it from the commit message.

I.e., I believe the following is UB:

struct foo { int a; int b; };
void myfoo(void) {
  struct foo bar;
  int *baz;

  baz = &bar.a;
  memset(baz, 0, sizeof(bar));
}

But not for arrays, like cc_cpu. In this case it is just code smell.