LCOV - code coverage report
Current view: top level - src - show_locked_checksum.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 89.5 % 19 17
Test Date: 2026-07-12 01:01:34 Functions: 100.0 % 1 1
Branches: 78.6 % 14 11

             Branch data     Line data    Source code
       1                 :             : #include "precizer.h"
       2                 :             : 
       3                 :             : /**
       4                 :             :  * @brief Show a checksum-locked unavailable violation for one path
       5                 :             :  *
       6                 :             :  * @param[in] relative_path Relative path descriptor being reported. Must not be NULL
       7                 :             :  * @param[in] access_status Unavailable classification for the locked path
       8                 :             :  * @param[in,out] first_iteration Traversal header state or NULL when banner state is unavailable
       9                 :             :  * @param[in,out] summary Traversal summary or NULL when summary tracking is unavailable.
      10                 :             :  *                        Ignored when first_iteration is NULL
      11                 :             :  *
      12                 :             :  * @return Return status code:
      13                 :             :  *         - SUCCESS: The violation line was printed
      14                 :             :  *         - FAILURE: Unsupported access status or summary was omitted while first_iteration was provided
      15                 :             :  */
      16                 :          20 : Return show_locked_checksum_unavailable_violation(
      17                 :             :         const memory           *relative_path,
      18                 :             :         const FileAccessStatus access_status,
      19                 :             :         bool                   *first_iteration,
      20                 :             :         TraversalSummary       *summary)
      21                 :             : {
      22                 :             :         /* This function was reviewed line by line by a human and is not AI-generated
      23                 :             :            Any change to this function requires separate explicit approval */
      24                 :             : 
      25                 :             :         /* Status returned by this function through provide()
      26                 :             :            Default value assumes successful completion */
      27                 :          20 :         Return status = SUCCESS;
      28                 :             : 
      29                 :          20 :         const char *message = NULL;
      30                 :             : 
      31   [ +  +  -  + ]:          20 :         if(first_iteration != NULL && summary == NULL)
      32                 :             :         {
      33                 :           0 :                 provide(FAILURE);
      34                 :             :         }
      35                 :             : 
      36         [ +  + ]:          20 :         if(access_status == FILE_NOT_FOUND)
      37                 :             :         {
      38                 :           6 :                 message = "checksum locked, file disappeared";
      39                 :             : 
      40         [ +  + ]:          14 :         } else if(access_status == FILE_ACCESS_DENIED){
      41                 :           6 :                 message = "checksum locked, access denied";
      42                 :             : 
      43         [ +  - ]:           8 :         } else if(access_status == FILE_ACCESS_ERROR){
      44                 :           8 :                 message = "checksum locked, access check failed";
      45                 :             : 
      46                 :             :         } else {
      47                 :           0 :                 status = FAILURE;
      48                 :             :         }
      49                 :             : 
      50         [ +  - ]:          20 :         if(SUCCESS == status)
      51                 :             :         {
      52                 :          20 :                 const char *runtime_relative_path = m_text(relative_path);
      53                 :             : 
      54         [ +  + ]:          20 :                 if(first_iteration != NULL)
      55                 :             :                 {
      56                 :           8 :                         slog_show(EVERY|UNDECOR|REMEMBER,false,first_iteration,summary,
      57                 :             :                                 RED "%s" RESET " %s\n",message,runtime_relative_path);
      58                 :             : 
      59                 :             :                 } else {
      60                 :          12 :                         slog(EVERY|UNDECOR|REMEMBER,RED "%s" RESET " %s\n",message,runtime_relative_path);
      61                 :             :                 }
      62                 :             : 
      63                 :             :                 /*
      64                 :             :                  * A checksum-locked file that disappears or becomes unreadable is treated as possible data corruption.
      65                 :             :                  * Replay the remembered warning at exit even without --progress so this critical result is not lost among traversal or cleanup messages
      66                 :             :                  */
      67                 :          20 :                 config->show_remembered_messages_at_exit = true;
      68                 :             :         }
      69                 :             : 
      70                 :          20 :         provide(status);
      71                 :             : }
        

Generated by: LCOV version 2.0-1