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
F132443947: D24089.id69575.diff
Fri, Oct 17, 12:09 AM
F132443941: D24089.id69579.diff
Fri, Oct 17, 12:09 AM
F132443939: D24089.id.diff
Fri, Oct 17, 12:09 AM
Unknown Object (File)
Thu, Oct 16, 3:19 PM
Unknown Object (File)
Thu, Oct 16, 3:03 AM
Unknown Object (File)
Sun, Oct 12, 4:31 AM
Unknown Object (File)
Mon, Sep 22, 10:04 PM
Unknown Object (File)
Sep 10 2025, 10:10 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.