Fix warning in MicroLock initialization
authorGiuseppe Ottaviano <ott@fb.com>
Sun, 13 Mar 2016 00:12:44 +0000 (16:12 -0800)
committerFacebook Github Bot 9 <facebook-github-bot-9-bot@fb.com>
Sun, 13 Mar 2016 00:20:19 +0000 (16:20 -0800)
commit1c15b5bb9efd09201a956885e863fc8815c67b87
treec76dbf8928831f4af47d82fc8a581ecaff74d1bf
parentb29f38a428c896be68d3c6ddc4f2f2f31de9d3aa
Fix warning in MicroLock initialization

Summary:The `init()` function uses the previous value of `lock_`, but that is
uninitialized and the compiler can issue a warning about it. It is
also potentially undefined behavior because it is not guaranteed that
the address of `lock_` is taken before `init()` (in which case the it
would be just an indeterminate value).

Since it is not very useful to initialize only one slot and leave the
others uninitialized, we can just have a single `init()` that
zero-initializes all the slots.

Reviewed By: dcolascione

Differential Revision: D3042629

fb-gh-sync-id: de1633b02eb1c891e310f2d5d2cfc5376cd41d5f
shipit-source-id: de1633b02eb1c891e310f2d5d2cfc5376cd41d5f
folly/MicroLock.h
folly/test/SmallLocksTest.cpp