LCOV - code coverage report
Current view: top level - glib/glib - gspawn-private.h (source / functions) Hit Total Coverage
Test: unnamed Lines: 10 40 25.0 %
Date: 2024-03-26 05:16:46 Functions: 2 2 100.0 %
Branches: 5 20 25.0 %

           Branch data     Line data    Source code
       1                 :            : /* gspawn.c - Process launching
       2                 :            :  *
       3                 :            :  *  Copyright 2000 Red Hat, Inc.
       4                 :            :  *  g_execvpe implementation based on GNU libc execvp:
       5                 :            :  *   Copyright 1991, 92, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
       6                 :            :  *
       7                 :            :  * SPDX-License-Identifier: LGPL-2.1-or-later
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2.1 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  * This library is distributed in the hope that it will be useful,
      15                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      16                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      17                 :            :  * Lesser General Public License for more details.
      18                 :            :  *
      19                 :            :  * You should have received a copy of the GNU Lesser General Public License
      20                 :            :  * along with this library; if not, see <http://www.gnu.org/licenses/>.
      21                 :            :  */
      22                 :            : 
      23                 :            : #include "config.h"
      24                 :            : 
      25                 :            : #include <errno.h>
      26                 :            : 
      27                 :            : #include "glibintl.h"
      28                 :            : #include "gspawn.h"
      29                 :            : 
      30                 :            : static inline gint
      31                 :          8 : _g_spawn_exec_err_to_g_error (gint en)
      32                 :            : {
      33   [ -  -  -  -  :          8 :   switch (en)
          -  +  -  -  -  
          -  -  -  -  -  
                   -  - ]
      34                 :            :     {
      35                 :            : #ifdef EACCES
      36                 :          0 :     case EACCES:
      37                 :          0 :       return G_SPAWN_ERROR_ACCES;
      38                 :            : #endif
      39                 :            : 
      40                 :            : #ifdef EPERM
      41                 :          0 :     case EPERM:
      42                 :          0 :       return G_SPAWN_ERROR_PERM;
      43                 :            : #endif
      44                 :            : 
      45                 :            : #ifdef E2BIG
      46                 :          0 :     case E2BIG:
      47                 :          0 :       return G_SPAWN_ERROR_TOO_BIG;
      48                 :            : #endif
      49                 :            : 
      50                 :            : #ifdef ENOEXEC
      51                 :          0 :     case ENOEXEC:
      52                 :          0 :       return G_SPAWN_ERROR_NOEXEC;
      53                 :            : #endif
      54                 :            : 
      55                 :            : #ifdef ENAMETOOLONG
      56                 :          0 :     case ENAMETOOLONG:
      57                 :          0 :       return G_SPAWN_ERROR_NAMETOOLONG;
      58                 :            : #endif
      59                 :            : 
      60                 :            : #ifdef ENOENT
      61                 :          8 :     case ENOENT:
      62                 :          8 :       return G_SPAWN_ERROR_NOENT;
      63                 :            : #endif
      64                 :            : 
      65                 :            : #ifdef ENOMEM
      66                 :          0 :     case ENOMEM:
      67                 :          0 :       return G_SPAWN_ERROR_NOMEM;
      68                 :            : #endif
      69                 :            : 
      70                 :            : #ifdef ENOTDIR
      71                 :          0 :     case ENOTDIR:
      72                 :          0 :       return G_SPAWN_ERROR_NOTDIR;
      73                 :            : #endif
      74                 :            : 
      75                 :            : #ifdef ELOOP
      76                 :          0 :     case ELOOP:
      77                 :          0 :       return G_SPAWN_ERROR_LOOP;
      78                 :            : #endif
      79                 :            : 
      80                 :            : #ifdef ETXTBUSY
      81                 :            :     case ETXTBUSY:
      82                 :            :       return G_SPAWN_ERROR_TXTBUSY;
      83                 :            : #endif
      84                 :            : 
      85                 :            : #ifdef EIO
      86                 :          0 :     case EIO:
      87                 :          0 :       return G_SPAWN_ERROR_IO;
      88                 :            : #endif
      89                 :            : 
      90                 :            : #ifdef ENFILE
      91                 :          0 :     case ENFILE:
      92                 :          0 :       return G_SPAWN_ERROR_NFILE;
      93                 :            : #endif
      94                 :            : 
      95                 :            : #ifdef EMFILE
      96                 :          0 :     case EMFILE:
      97                 :          0 :       return G_SPAWN_ERROR_MFILE;
      98                 :            : #endif
      99                 :            : 
     100                 :            : #ifdef EINVAL
     101                 :          0 :     case EINVAL:
     102                 :          0 :       return G_SPAWN_ERROR_INVAL;
     103                 :            : #endif
     104                 :            : 
     105                 :            : #ifdef EISDIR
     106                 :          0 :     case EISDIR:
     107                 :          0 :       return G_SPAWN_ERROR_ISDIR;
     108                 :            : #endif
     109                 :            : 
     110                 :            : #ifdef ELIBBAD
     111                 :          0 :     case ELIBBAD:
     112                 :          0 :       return G_SPAWN_ERROR_LIBBAD;
     113                 :            : #endif
     114                 :            : 
     115                 :          0 :     default:
     116                 :          0 :       return G_SPAWN_ERROR_FAILED;
     117                 :            :     }
     118                 :            : }
     119                 :            : 
     120                 :            : static inline gboolean
     121                 :       4299 : _g_spawn_invalid_source_fd (gint         fd,
     122                 :            :                             const gint  *source_fds,
     123                 :            :                             gsize        n_fds,
     124                 :            :                             GError     **error)
     125                 :            : {
     126                 :            :   gsize i;
     127                 :            : 
     128         [ +  + ]:       4362 :   for (i = 0; i < n_fds; i++)
     129         [ +  + ]:         64 :     if (fd == source_fds[i])
     130                 :            :       {
     131                 :          1 :         g_set_error (error,
     132                 :            :                      G_SPAWN_ERROR,
     133                 :            :                      G_SPAWN_ERROR_INVAL,
     134                 :            :                      _("Invalid source FDs argument"));
     135                 :          1 :         return TRUE;
     136                 :            :       }
     137                 :            : 
     138                 :       4298 :   return FALSE;
     139                 :            : }

Generated by: LCOV version 1.14