LCOV - code coverage report
Current view: top level - src - directory_open_root.c (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 7 7
Test Date: 2026-07-12 01:01:34 Functions: 100.0 % 1 1
Branches: 100.0 % 2 2

             Branch data     Line data    Source code
       1                 :             : #include "precizer.h"
       2                 :             : #include <errno.h>
       3                 :             : 
       4                 :             : /**
       5                 :             :  * @brief Open a traversal root and remember an opening failure
       6                 :             :  *
       7                 :             :  * @details
       8                 :             :  * Opens a root directory that will be used as the base for traversal-relative
       9                 :             :  * access checks. When the root cannot be opened, the function prints one
      10                 :             :  * plain warning immediately and saves the same warning for the final
      11                 :             :  * "Warnings and errors encountered" summary
      12                 :             :  *
      13                 :             :  * @param[in] root_path Descriptor containing the traversal root path
      14                 :             :  * @param[out] root_directory_fd_out Receives the opened descriptor
      15                 :             :  * @return Status returned by directory_open()
      16                 :             :  */
      17                 :         480 : FileAccessStatus directory_open_root(
      18                 :             :         const memory *root_path,
      19                 :             :         int          *root_directory_fd_out)
      20                 :             : {
      21                 :         480 :         const FileAccessStatus root_access_status = directory_open(root_path,root_directory_fd_out);
      22                 :             : 
      23         [ +  + ]:         480 :         if(root_access_status != FILE_ACCESS_ALLOWED)
      24                 :             :         {
      25                 :           8 :                 const int root_open_errno = errno;
      26                 :             : 
      27                 :           8 :                 slog(EVERY|UNDECOR|REMEMBER,
      28                 :             :                         "Unable to open traversal root %s: %s\n",
      29                 :             :                         m_text(root_path),
      30                 :             :                         strerror(root_open_errno));
      31                 :             : 
      32                 :             :                 /*
      33                 :             :                  * The caller may skip this root immediately, before later traversal
      34                 :             :                  * code has a chance to request the final warning summary. Enable
      35                 :             :                  * that summary here so the message saved by REMEMBER is shown again
      36                 :             :                  * at exit
      37                 :             :                  */
      38                 :           8 :                 config->show_remembered_messages_at_exit = true;
      39                 :             :         }
      40                 :             : 
      41                 :         480 :         return(root_access_status);
      42                 :             : }
        

Generated by: LCOV version 2.0-1