SolidSyslog coverage report
Current view: top level - Platform/VxWorks64/Source - SolidSyslogVxWorks64TcpStreamStatic.c (source / functions) Coverage Total Hit
Test: SolidSyslog Lines: 100.0 % 25 25
Test Date: 2026-11-12 23:14:35 Functions: 100.0 % 4 4
Branches: 100.0 % 12 12

             Branch data     Line data    Source code
       1                 :             : /* SPDX-FileCopyrightText: Copyright 2026 Cozens Software Solutions Limited
       2                 :             :  * SPDX-License-Identifier: PolyForm-Noncommercial-1.0.0 OR LicenseRef-PolyForm-Internal-Use-1.0.0 OR LicenseRef-COSOSO-Commercial
       3                 :             :  */
       4                 :             : 
       5                 :             : #include "SolidSyslogVxWorks64TcpStream.h"
       6                 :             : 
       7                 :             : #include <stdbool.h>
       8                 :             : #include <stddef.h>
       9                 :             : 
      10                 :             : #include "SolidSyslogError.h"
      11                 :             : #include "SolidSyslogErrorCategory.h"
      12                 :             : #include "SolidSyslogNullStream.h"
      13                 :             : #include "SolidSyslogPoolAllocator.h"
      14                 :             : #include "SolidSyslogStreamDefinition.h"
      15                 :             : #include "SolidSyslogTunables.h"
      16                 :             : #include "SolidSyslogVxWorks64TcpStreamErrors.h"
      17                 :             : #include "SolidSyslogVxWorks64TcpStreamPrivate.h"
      18                 :             : 
      19                 :             : static inline size_t VxWorks64TcpStream_IndexFromHandle(const struct SolidSyslogStream* base);
      20                 :             : static inline void VxWorks64TcpStream_CleanupAtIndex(size_t index, void* context);
      21                 :             : 
      22                 :             : static bool VxWorks64TcpStream_InUse[SOLIDSYSLOG_TCP_STREAM_POOL_SIZE];
      23                 :             : static struct SolidSyslogVxWorks64TcpStream VxWorks64TcpStream_Pool[SOLIDSYSLOG_TCP_STREAM_POOL_SIZE];
      24                 :             : static struct SolidSyslogPoolAllocator VxWorks64TcpStream_Allocator = {
      25                 :             :     VxWorks64TcpStream_InUse,
      26                 :             :     SOLIDSYSLOG_TCP_STREAM_POOL_SIZE
      27                 :             : };
      28                 :             : 
      29                 :         124 : struct SolidSyslogStream* SolidSyslogVxWorks64TcpStream_Create(const struct SolidSyslogVxWorks64TcpStreamConfig* config)
      30                 :             : {
      31                 :         124 :     size_t index = SolidSyslogPoolAllocator_AcquireFirstFree(&VxWorks64TcpStream_Allocator);
      32                 :         124 :     struct SolidSyslogStream* handle = SolidSyslogNullStream_Get();
      33         [ +  + ]:         124 :     if (SolidSyslogPoolAllocator_IndexIsValid(&VxWorks64TcpStream_Allocator, index) == true)
      34                 :             :     {
      35                 :         121 :         SolidSyslogVxWorks64TcpStream_Initialise(&VxWorks64TcpStream_Pool[index].Base, config);
      36                 :         121 :         handle = &VxWorks64TcpStream_Pool[index].Base;
      37                 :             :     }
      38                 :             :     else
      39                 :             :     {
      40                 :           3 :         VxWorks64TcpStream_Report(
      41                 :             :             SOLIDSYSLOG_POOL_EXHAUSTED_SEVERITY,
      42                 :             :             SOLIDSYSLOG_CAT_POOL_EXHAUSTED,
      43                 :             :             SOLIDSYSLOG_TCP_STREAM_ERROR_POOL_EXHAUSTED
      44                 :             :         );
      45                 :             :     }
      46                 :         124 :     return handle;
      47                 :             : }
      48                 :             : 
      49                 :         129 : void SolidSyslogVxWorks64TcpStream_Destroy(struct SolidSyslogStream* base)
      50                 :             : {
      51                 :         129 :     size_t index = VxWorks64TcpStream_IndexFromHandle(base);
      52   [ +  +  +  + ]:         251 :     bool released = SolidSyslogPoolAllocator_IndexIsValid(&VxWorks64TcpStream_Allocator, index) &&
      53                 :         122 :                     SolidSyslogPoolAllocator_FreeIfInUse(
      54                 :             :                         &VxWorks64TcpStream_Allocator,
      55                 :             :                         index,
      56                 :             :                         VxWorks64TcpStream_CleanupAtIndex,
      57                 :             :                         NULL
      58                 :             :                     );
      59         [ +  + ]:         129 :     if (!released)
      60                 :             :     {
      61                 :           8 :         VxWorks64TcpStream_Report(
      62                 :             :             SOLIDSYSLOG_UNKNOWN_DESTROY_SEVERITY,
      63                 :             :             SOLIDSYSLOG_CAT_UNKNOWN_DESTROY,
      64                 :             :             SOLIDSYSLOG_TCP_STREAM_ERROR_UNKNOWN_DESTROY
      65                 :             :         );
      66                 :             :     }
      67                 :         129 : }
      68                 :             : 
      69                 :         129 : static inline size_t VxWorks64TcpStream_IndexFromHandle(const struct SolidSyslogStream* base)
      70                 :             : {
      71                 :         129 :     size_t result = SOLIDSYSLOG_TCP_STREAM_POOL_SIZE;
      72         [ +  + ]:         146 :     for (size_t poolIndex = 0U; poolIndex < SOLIDSYSLOG_TCP_STREAM_POOL_SIZE; poolIndex++)
      73                 :             :     {
      74         [ +  + ]:         139 :         if (base == &VxWorks64TcpStream_Pool[poolIndex].Base)
      75                 :             :         {
      76                 :         122 :             result = poolIndex;
      77                 :         122 :             break;
      78                 :             :         }
      79                 :             :     }
      80                 :         129 :     return result;
      81                 :             : }
      82                 :             : 
      83                 :         121 : static inline void VxWorks64TcpStream_CleanupAtIndex(size_t index, void* context)
      84                 :             : {
      85                 :             :     (void) context;
      86                 :         121 :     SolidSyslogVxWorks64TcpStream_Cleanup(&VxWorks64TcpStream_Pool[index].Base);
      87                 :         121 : }
        

Generated by: LCOV version 2.0-1