SolidSyslog coverage report
Current view: top level - Core/Source - SolidSyslogNullStore.c (source / functions) Coverage Total Hit
Test: SolidSyslog Lines: 100.0 % 17 17
Test Date: 2026-11-12 23:14:35 Functions: 100.0 % 8 8

            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 "SolidSyslogNullStore.h"
       6              : 
       7              : #include <stdbool.h>
       8              : #include <stddef.h>
       9              : 
      10              : #include "SolidSyslogStoreDefinition.h"
      11              : 
      12              : static enum SolidSyslogStoreWriteResult NullStore_Write(struct SolidSyslogStore* base, const void* data, size_t size);
      13              : static bool NullStore_ReadNextUnsent(struct SolidSyslogStore* base, void* data, size_t maxSize, size_t* bytesRead);
      14              : static void NullStore_MarkSent(struct SolidSyslogStore* base);
      15              : static bool NullStore_HasUnsent(struct SolidSyslogStore* base);
      16              : static size_t NullStore_GetTotalBytes(struct SolidSyslogStore* base);
      17              : static size_t NullStore_GetUsedBytes(struct SolidSyslogStore* base);
      18              : static bool NullStore_IsTransient(struct SolidSyslogStore* base);
      19              : 
      20        80275 : struct SolidSyslogStore* SolidSyslogNullStore_Get(void)
      21              : {
      22              :     static struct SolidSyslogStore instance = {
      23              :         .Write = NullStore_Write,
      24              :         .ReadNextUnsent = NullStore_ReadNextUnsent,
      25              :         .MarkSent = NullStore_MarkSent,
      26              :         .HasUnsent = NullStore_HasUnsent,
      27              :         .GetTotalBytes = NullStore_GetTotalBytes,
      28              :         .GetUsedBytes = NullStore_GetUsedBytes,
      29              :         .IsTransient = NullStore_IsTransient
      30              :     };
      31        80275 :     return &instance;
      32              : }
      33              : 
      34              : /* NullStore never retains, so the eager-drain loop in ProcessMessages takes
      35              :  * the direct-send path - NullStore + real-buffer + UDP is the
      36              :  * constrained-system "one attempt per message, no buffering" configuration. */
      37         3237 : static enum SolidSyslogStoreWriteResult NullStore_Write(struct SolidSyslogStore* base, const void* data, size_t size)
      38              : {
      39              :     (void) base;
      40              :     (void) data;
      41              :     (void) size;
      42         3237 :     return SOLIDSYSLOG_STORE_WRITE_NOT_RETAINED;
      43              : }
      44              : 
      45          700 : static bool NullStore_ReadNextUnsent(struct SolidSyslogStore* base, void* data, size_t maxSize, size_t* bytesRead)
      46              : {
      47              :     (void) base;
      48              :     (void) data;
      49              :     (void) maxSize;
      50          700 :     *bytesRead = 0;
      51          700 :     return false;
      52              : }
      53              : 
      54            2 : static void NullStore_MarkSent(struct SolidSyslogStore* base)
      55              : {
      56              :     (void) base;
      57            2 : }
      58              : 
      59         5813 : static bool NullStore_HasUnsent(struct SolidSyslogStore* base)
      60              : {
      61              :     (void) base;
      62         5813 :     return false;
      63              : }
      64              : 
      65            1 : static size_t NullStore_GetTotalBytes(struct SolidSyslogStore* base)
      66              : {
      67              :     (void) base;
      68            1 :     return 0;
      69              : }
      70              : 
      71            1 : static size_t NullStore_GetUsedBytes(struct SolidSyslogStore* base)
      72              : {
      73              :     (void) base;
      74            1 :     return 0;
      75              : }
      76              : 
      77              : /* NullStore retains nothing - a NullStore_Write rejection means "I never had it,
      78              :  * please try the sender." Service's DrainBufferIntoStore consults this
      79              :  * to know it's safe to fall through to direct-send. */
      80         2950 : static bool NullStore_IsTransient(struct SolidSyslogStore* base)
      81              : {
      82              :     (void) base;
      83         2950 :     return true;
      84              : }
        

Generated by: LCOV version 2.0-1