LCOV - code coverage report
Current view: top level - lib/util - tevent_unix.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 22 29 75.9 %
Date: 2024-04-21 15:09:00 Functions: 3 3 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Wrap unix errno around tevent_req
       4             :    Copyright (C) Volker Lendecke 2009
       5             : 
       6             :      ** NOTE! The following LGPL license applies to the tevent_unix
       7             :      ** helper library. This does NOT imply that all of Samba is released
       8             :      ** under the LGPL
       9             : 
      10             :    This library is free software; you can redistribute it and/or
      11             :    modify it under the terms of the GNU Lesser General Public
      12             :    License as published by the Free Software Foundation; either
      13             :    version 3 of the License, or (at your option) any later version.
      14             : 
      15             :    This library is distributed in the hope that it will be useful,
      16             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      17             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      18             :    Library General Public License for more details.
      19             : 
      20             :    You should have received a copy of the GNU Lesser General Public License
      21             :    along with this program.  If not, see <http://www.gnu.org/licenses/>.
      22             : */
      23             : 
      24             : #include "../replace/replace.h"
      25             : #include "tevent_unix.h"
      26             : 
      27    12387480 : bool tevent_req_is_unix_error(struct tevent_req *req, int *perrno)
      28             : {
      29      204770 :         enum tevent_req_state state;
      30      204770 :         uint64_t err;
      31             : 
      32    12387480 :         if (!tevent_req_is_error(req, &state, &err)) {
      33    12163156 :                 return false;
      34             :         }
      35       19556 :         switch (state) {
      36          33 :         case TEVENT_REQ_TIMED_OUT:
      37          33 :                 *perrno = ETIMEDOUT;
      38          33 :                 break;
      39           0 :         case TEVENT_REQ_NO_MEMORY:
      40           0 :                 *perrno = ENOMEM;
      41           0 :                 break;
      42       19523 :         case TEVENT_REQ_USER_ERROR:
      43       19523 :                 *perrno = err;
      44       19523 :                 break;
      45           0 :         default:
      46           0 :                 *perrno = EINVAL;
      47           0 :                 break;
      48             :         }
      49       19554 :         return true;
      50             : }
      51             : 
      52      373259 : int tevent_req_simple_recv_unix(struct tevent_req *req)
      53             : {
      54      373259 :         int err = 0;
      55             : 
      56             :         /*
      57             :          * Ignore result of tevent_req_is_unix_error, we're only interested in
      58             :          * the status
      59             :          */
      60      373259 :         tevent_req_is_unix_error(req, &err);
      61      373259 :         tevent_req_received(req);
      62      373259 :         return err;
      63             : }
      64             : 
      65       47814 : bool tevent_req_poll_unix(struct tevent_req *req, struct tevent_context *ev,
      66             :                           int *err)
      67             : {
      68       47814 :         bool ret = tevent_req_poll(req, ev);
      69       47739 :         if (!ret) {
      70           0 :                 *err = errno;
      71             :         }
      72       47739 :         return ret;
      73             : }

Generated by: LCOV version 1.14