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)
Dec 23 2023, 1:18 AM
Unknown Object (File)
Jul 8 2023, 10:41 PM
Unknown Object (File)
May 5 2023, 3:11 PM
Unknown Object (File)
Jan 10 2023, 8:47 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.