
#include <legato.h>
#include <thread>
#include <string>
#include <list>
#include <iostream>


#ifndef MUST_BE_DEFINED
#error MUST_BE_DEFINED was not defined.
#endif


COMPONENT_INIT
{
    LE_INFO("Hello world, from thread 1.");

    std::thread newThread([]()
        {
            le_thread_InitLegatoThreadData("thread 2");

            // This will crash if the Legato thread-specific data has not been initialized.
            le_thread_GetCurrent();

            LE_INFO("Hello world, from %s.", le_thread_GetMyName());

            le_thread_CleanupLegatoThreadData();
        });

    LE_INFO("Thead 2 stared, and waiting for it to complete.");
    newThread.join();

    LE_INFO("Thead 2 ended, all done with init.");

    std::list<std::string> stuff;

    // C++ 11
    for (auto const &s : stuff)
    {
        std::cout << "stuff: " << s << std::endl;
    }

    exit(EXIT_SUCCESS);
}


#include <legato.h>
#include <thread>
#include <string>
#include <list>
#include <iostream>


#ifndef MUST_BE_DEFINED
#error MUST_BE_DEFINED was not defined.
#endif


COMPONENT_INIT
{
    LE_INFO("Hello world, from thread 1.");

    std::thread newThread([]()
        {
            le_thread_InitLegatoThreadData("thread 2");

            // This will crash if the Legato thread-specific data has not been initialized.
            le_thread_GetCurrent();

            LE_INFO("Hello world, from %s.", le_thread_GetMyName());

            le_thread_CleanupLegatoThreadData();
        });

    LE_INFO("Thead 2 stared, and waiting for it to complete.");
    newThread.join();

    LE_INFO("Thead 2 ended, all done with init.");

    std::list<std::string> stuff;

    // C++ 11
    for (auto s : stuff)
    {
        std::cout << "stuff: " << s << std::endl;
    }

    exit(EXIT_SUCCESS);
}

--- 
+++ 
@@ -35,7 +35,7 @@
     std::list<std::string> stuff;
 
     // C++ 11
-    for (auto s : stuff)
+    for (auto const &s : stuff)
     {
         std::cout << "stuff: " << s << std::endl;
     }
Fix klocwork issues with uninitialized variables in the "apps" module.

Resolves: LE-9400
Change-Id: I4500613cf3d1f7f849b3f0b74ca6f5b3485757c3
