Skip to content

Commit

Permalink
[win32] Remove unnecessary memset()s of LVITEM and LVCOLUMN.
Browse files Browse the repository at this point in the history
Make sure the iItem and iSubItem fields are initialized.

We don't have to memset() the whole struct; just set the fields
that are needed, based on the mask field.
  • Loading branch information
GerbilSoft committed Dec 7, 2024
1 parent 47fb743 commit 3ad5a7c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/win32/RP_XAttrView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ int RP_XAttrView_Private::loadADS(void)
const XAttrReader::XAttrList &xattrList = xattrReader->genericXAttrs();

LVITEM lvItem;
memset(&lvItem, 0, sizeof(lvItem));
lvItem.mask = LVIF_TEXT;
lvItem.iItem = 0;
for (const auto &xattr : xattrList) {
tstring tstr = U82T_c(xattr.first.c_str());
lvItem.iSubItem = 0;
Expand Down
3 changes: 0 additions & 3 deletions src/win32/config/CacheTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ void CacheTabPrivate::enumDrivesXP(void)
TCHAR path[] = _T("X:\\");
SHFILEINFO sfi;
LVITEM lvi;
memset(&lvi, 0, sizeof(lvi));
lvi.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT;
for (unsigned int i = 0; i < 26 && dwDrives != 0; i++, dwDrives >>= 1) {
// Ignore missing drives and network drives.
Expand Down Expand Up @@ -299,8 +298,6 @@ void CacheTabPrivate::updateDrivesXP(DWORD unitmask)
TCHAR path[] = _T("X:\\");
SHFILEINFO sfi;
LVITEM lviNew, lviCur;
memset(&lviNew, 0, sizeof(lviNew));
memset(&lviCur, 0, sizeof(lviCur));
lviNew.mask = LVIF_IMAGE | LVIF_PARAM | LVIF_TEXT;
lviCur.mask = LVIF_PARAM;

Expand Down
33 changes: 18 additions & 15 deletions src/win32/config/KeyManagerTab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,27 +363,30 @@ void KeyManagerTabPrivate::initDialog(void)
ListView_SetItemCountEx(hListView, keyStore->totalKeyCount(),
LVSICF_NOINVALIDATEALL | LVSICF_NOSCROLL);

// Column title.
// Column title
tstring tsColTitle;

// tr: Column 0: Key Name.
// tr: Column 0: Key Name
tsColTitle = TC_("KeyManagerTab", "Key Name");
LVCOLUMN lvCol;
memset(&lvCol, 0, sizeof(lvCol));
lvCol.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM;
lvCol.fmt = LVCFMT_LEFT;
lvCol.pszText = const_cast<LPTSTR>(tsColTitle.c_str());
ListView_InsertColumn(hListView, 0, &lvCol);

// tr: Column 1: Value.
LVCOLUMN lvColumn;
lvColumn.mask = LVCF_FMT | LVCF_TEXT | LVCF_SUBITEM;
lvColumn.fmt = LVCFMT_LEFT;
lvColumn.pszText = const_cast<LPTSTR>(tsColTitle.c_str());
lvColumn.iItem = 0;
lvColumn.iSubItem = 0;
ListView_InsertColumn(hListView, 0, &lvColumn);

// tr: Column 1: Value
tsColTitle = TC_("KeyManagerTab", "Value");
lvCol.pszText = const_cast<LPTSTR>(tsColTitle.c_str());
ListView_InsertColumn(hListView, 1, &lvCol);
lvColumn.pszText = const_cast<LPTSTR>(tsColTitle.c_str());
lvColumn.iSubItem = 1;
ListView_InsertColumn(hListView, 1, &lvColumn);

// tr: Column 2: Verification status.
// tr: Column 2: Verification status
tsColTitle = TC_("KeyManagerTab", "Valid?");
lvCol.pszText = const_cast<LPTSTR>(tsColTitle.c_str());
ListView_InsertColumn(hListView, 2, &lvCol);
lvColumn.pszText = const_cast<LPTSTR>(tsColTitle.c_str());
lvColumn.iSubItem = 2;
ListView_InsertColumn(hListView, 2, &lvColumn);

if (isComCtl32_v610) {
// Set the IOwnerDataCallback.
Expand Down

0 comments on commit 3ad5a7c

Please sign in to comment.