openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/rsyslog/8.1903.0-r0/rsyslog-8.1903.0/runtime/msg.c
static void msgSetUUID(smsg_t* const pM)
    {
        size_t lenRes = sizeof(uuid_t) * 2 + 1;
        char hex_char[] = "0123456789ABCDEF";
        unsigned int byte_nbr;
        uuid_t uuid;
        static pthread_mutex_t mutUUID = PTHREAD_MUTEX_INITIALIZER;

        dbgprintf("[MsgSetUUID] START, lenRes %llu\n",
                  (long long unsigned)lenRes);
        assert(pM != NULL);

        if ((pM->pszUUID = (uchar*)malloc(lenRes)) == NULL)
        {
            pM->pszUUID = (uchar*)"";
        }
        else
        {
            pthread_mutex_lock(&mutUUID);
            uuid_generate(uuid);
            pthread_mutex_unlock(&mutUUID);
            for (byte_nbr = 0; byte_nbr < sizeof(uuid_t); byte_nbr++)
            {
                pM->pszUUID[byte_nbr * 2 + 0] = hex_char[uuid[byte_nbr] >> 4];
                pM->pszUUID[byte_nbr * 2 + 1] = hex_char[uuid[byte_nbr] & 15];
            }

            pM->pszUUID[lenRes - 1] = '\0';
            dbgprintf("[MsgSetUUID] UUID : %s LEN: %d \n", pM->pszUUID,
                      (int)lenRes);
        }
        dbgprintf("[MsgSetUUID] END\n");
    }
/* note: libuuid seems not to be thread-safe, so we need
     * to get some safeguards in place.
     */
libuuid seems not to be thread-safe, so we need
to get some safeguards in place.
libuuid seems not to be thread - safe so we need to get some safeguards in place .
static void msgSetUUID(smsg_t* const pM)
    {
        size_t lenRes = sizeof(uuid_t) * 2 + 1;
        char hex_char[] = "0123456789ABCDEF";
        unsigned int byte_nbr;
        uuid_t uuid;
        static pthread_mutex_t mutUUID = PTHREAD_MUTEX_INITIALIZER;
        dbgprintf("[MsgSetUUID] START, lenRes %llu\n",
                  (long long unsigned)lenRes);
        assert(pM != NULL);
        if ((pM->pszUUID = (uchar*)malloc(lenRes)) == NULL)
        {
            pM->pszUUID = (uchar*)"";
        }
        else
        {
            pthread_mutex_lock(&mutUUID);
            uuid_generate(uuid);
            pthread_mutex_unlock(&mutUUID);
            for (byte_nbr = 0; byte_nbr < sizeof(uuid_t); byte_nbr++)
            {
                pM->pszUUID[byte_nbr * 2 + 0] = hex_char[uuid[byte_nbr] >> 4];
                pM->pszUUID[byte_nbr * 2 + 1] = hex_char[uuid[byte_nbr] & 15];
            }
            pM->pszUUID[lenRes - 1] = '\0';
            dbgprintf("[MsgSetUUID] UUID : %s LEN: %d \n", pM->pszUUID,
                      (int)lenRes);
        }
        dbgprintf("[MsgSetUUID] END\n");
    }
static void msgSetUUID ( smsg_t * const pM ) { size_t lenRes = sizeof ( uuid_t ) * 2 + 1 ; char hex_char [ ] = " " ; unsigned int byte_nbr ; uuid_t uuid ; static pthread_mutex_t mutUUID = PTHREAD_MUTEX_INITIALIZER ; dbgprintf ( " \n " , ( long long unsigned ) lenRes ) ; assert ( pM != NULL ) ; if ( ( pM -> pszUUID = ( uchar * ) malloc ( lenRes ) ) == NULL ) { pM -> pszUUID = ( uchar * ) " " ; } else { pthread_mutex_lock ( & mutUUID ) ; uuid_generate ( uuid ) ; pthread_mutex_unlock ( & mutUUID ) ; for ( byte_nbr = 0 ; byte_nbr < sizeof ( uuid_t ) ; byte_nbr ++ ) { pM -> pszUUID [ byte_nbr * 2 + 0 ] = hex_char [ uuid [ byte_nbr ] >> 4 ] ; pM -> pszUUID [ byte_nbr * 2 + 1 ] = hex_char [ uuid [ byte_nbr ] & 15 ] ; } pM -> pszUUID [ lenRes - 1 ] = ' \0 ' ; dbgprintf ( " \n " , pM -> pszUUID , ( int ) lenRes ) ; } dbgprintf ( " \n " ) ; }
note: libuuid seems not to be thread-safe, so we need
 to get some safeguards in place.
note : libuuid seems not to be thread - safe so we need to get some safeguards in place .