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
Unknown Object (File)
Fri, Dec 26, 2:35 AM
Unknown Object (File)
Thu, Dec 25, 12:58 PM
Unknown Object (File)
Sun, Dec 21, 2:40 AM
Unknown Object (File)
Nov 26 2025, 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
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

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 29967
Build 27780: arc lint + arc unit

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.