Simplify using designated initializers

Change-Id: I73d666a0aa4a41e8e73cb701161be1da6fd59d0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179942
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Mike Kaganski
2025-01-08 09:58:22 +01:00
parent f468593d90
commit e143c83b1c
11 changed files with 15 additions and 37 deletions

View File

@ -179,12 +179,8 @@ WinLaunchChild(const wchar_t *exePath,
return FALSE;
}
STARTUPINFOW si;
std::memset(&si, 0, sizeof si);
si.cb = sizeof(STARTUPINFOW);
si.lpDesktop = const_cast<LPWSTR>(L"winsta0\\Default");
PROCESS_INFORMATION pi;
std::memset(&pi, 0, sizeof pi);
STARTUPINFOW si{ .cb = sizeof(si), .lpDesktop = const_cast<LPWSTR>(L"winsta0\\Default") };
PROCESS_INFORMATION pi{};
if (userToken == nullptr)
{

View File

@ -59,10 +59,7 @@ static bool launchSoffice( )
imagename[_MAX_PATH] = 0;
_snwprintf(imagename, _MAX_PATH, L"\"%s\" --quickstart", filename );
STARTUPINFOW aStartupInfo;
ZeroMemory(&aStartupInfo, sizeof(aStartupInfo));
aStartupInfo.cb = sizeof(aStartupInfo);
aStartupInfo.wShowWindow = SW_SHOW;
STARTUPINFOW aStartupInfo{ .cb = sizeof(aStartupInfo), .wShowWindow = SW_SHOW };
PROCESS_INFORMATION aProcessInfo;
bool bSuccess = CreateProcessW(filename, imagename, nullptr, nullptr, TRUE, 0, nullptr, nullptr, &aStartupInfo, &aProcessInfo);
if ( !bSuccess )

View File

@ -29,7 +29,7 @@ extern "C" int APIENTRY wWinMain( HINSTANCE, HINSTANCE, LPWSTR, int )
{
// Retrieve startup info
STARTUPINFOW aStartupInfo{ sizeof(aStartupInfo) };
STARTUPINFOW aStartupInfo{ .cb = sizeof(aStartupInfo) };
GetStartupInfoW( &aStartupInfo );
// Retrieve command line

View File

@ -206,9 +206,7 @@ int officeloader_impl(bool bAllowConsole)
{
const auto& [szTargetFileName, szIniDirectory] = extendLoaderEnvironment();
STARTUPINFOW aStartupInfo;
ZeroMemory(&aStartupInfo, sizeof(aStartupInfo));
aStartupInfo.cb = sizeof(aStartupInfo);
STARTUPINFOW aStartupInfo{ .cb = sizeof(aStartupInfo) };
// Create process with same command line, environment and stdio handles which
// are directed to the created pipes
@ -380,8 +378,7 @@ int unopkgloader_impl(bool bAllowConsole)
{
const auto& [szTargetFileName, szIniDirectory] = extendLoaderEnvironment();
STARTUPINFOW aStartupInfo{};
aStartupInfo.cb = sizeof(aStartupInfo);
STARTUPINFOW aStartupInfo{ .cb = sizeof(aStartupInfo) };
GetStartupInfoW(&aStartupInfo);
DWORD dwExitCode = DWORD(-1);

View File

@ -264,8 +264,7 @@ void Twain::ShimListenerThread::execute()
// We need a WinAPI HANDLE of the process to be able to wait on it and detect the process
// termination; so use WinAPI to start the process, not osl_executeProcess.
STARTUPINFOW si{};
si.cb = sizeof(si);
STARTUPINFOW si{ .cb = sizeof(si) };
PROCESS_INFORMATION pi;
if (!CreateProcessW(nullptr, const_cast<LPWSTR>(o3tl::toW(sCmdLine.getStr())), nullptr,

View File

@ -189,9 +189,7 @@ int wmain(int argc, wchar_t ** argv, wchar_t **) {
exit(EXIT_FAILURE);
}
}
STARTUPINFOW startinfo;
ZeroMemory(&startinfo, sizeof (STARTUPINFOW));
startinfo.cb = sizeof (STARTUPINFOW);
STARTUPINFOW startinfo{ .cb = sizeof(startinfo) };
PROCESS_INFORMATION procinfo;
if (!CreateProcessW(
pythonexe.data(), cl, nullptr, nullptr, FALSE, CREATE_UNICODE_ENVIRONMENT, nullptr,

View File

@ -467,10 +467,9 @@ oslProcessError SAL_CALL osl_executeProcess_WithRedirectedIO(
if ((Options & osl_Process_DETACHED) && !(flags & CREATE_NEW_CONSOLE))
flags |= DETACHED_PROCESS;
STARTUPINFOW startup_info = {};
startup_info.cb = sizeof(startup_info);
startup_info.dwFlags = STARTF_USESHOWWINDOW;
startup_info.lpDesktop = const_cast<LPWSTR>(L"");
STARTUPINFOW startup_info{ .cb = sizeof(startup_info),
.lpDesktop = const_cast<LPWSTR>(L""),
.dwFlags = STARTF_USESHOWWINDOW };
/* Create pipes for redirected IO */
HANDLE hInputRead = nullptr;

View File

@ -162,8 +162,7 @@ void RegDLL(MSIHANDLE hInst, const std::wstring& sArgs, bool bUnreg)
sCmd += sArgs;
WriteLog(hInst, "Prepared regsvr32 command:", sCmd);
STARTUPINFOW si{};
si.cb = sizeof(si);
STARTUPINFOW si{ .cb = sizeof(si) };
PROCESS_INFORMATION pi{};
if (!CreateProcessW(sRegSvr32.c_str(), const_cast<LPWSTR>(sCmd.c_str()), nullptr, nullptr,
FALSE, CREATE_NO_WINDOW, nullptr, nullptr, &si, &pi))

View File

@ -26,10 +26,7 @@ HRESULT LOStart(Args... args)
std::wstring sCmdLine((quote(GetHelperExe()) + ... + (L" " + quote(args))));
LPWSTR pCmdLine = const_cast<LPWSTR>(sCmdLine.c_str());
STARTUPINFOW si = {};
si.cb = sizeof si;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
STARTUPINFOW si{ .cb = sizeof(si), .dwFlags = STARTF_USESHOWWINDOW, .wShowWindow = SW_SHOW };
PROCESS_INFORMATION pi = {};
if (!CreateProcessW(nullptr, pCmdLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi))
return HRESULT_FROM_WIN32(GetLastError());

View File

@ -126,10 +126,7 @@ DWORD LOStart(const wchar_t* sModeArg, const wchar_t* sFilePath)
+ o3tl::toU(sFilePath) + "\"";
LPWSTR pCmdLine = const_cast<LPWSTR>(o3tl::toW(sCmdLine.getStr()));
STARTUPINFOW si = {};
si.cb = sizeof si;
si.dwFlags = STARTF_USESHOWWINDOW;
si.wShowWindow = SW_SHOW;
STARTUPINFOW si{ .cb = sizeof(si), .dwFlags = STARTF_USESHOWWINDOW, .wShowWindow = SW_SHOW };
PROCESS_INFORMATION pi{};
if (!CreateProcessW(nullptr, pCmdLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi))
{

View File

@ -332,8 +332,7 @@ VCLPLUG_WIN_PUBLIC SalInstance* create_SalInstance()
{
SalData* pSalData = new SalData();
STARTUPINFOW aSI;
aSI.cb = sizeof( aSI );
STARTUPINFOW aSI{ .cb = sizeof(aSI) };
GetStartupInfoW( &aSI );
pSalData->mhInst = GetModuleHandleW( nullptr );
pSalData->mnCmdShow = aSI.wShowWindow;