LCOV - code coverage report
Current view: directory - src/trusted/desc/posix - nacl_makeboundsock.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 24 15 62.5 %
Date: 2014-06-18 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2010 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : #include "native_client/src/shared/platform/nacl_log.h"
       8                 : #include "native_client/src/trusted/desc/nacl_desc_base.h"
       9                 : #include "native_client/src/trusted/desc/nacl_desc_conn_cap.h"
      10                 : #include "native_client/src/trusted/desc/nacl_desc_imc_bound_desc.h"
      11                 : #include "native_client/src/trusted/service_runtime/include/sys/errno.h"
      12                 : 
      13                 : 
      14             590 : int32_t NaClCommonDescMakeBoundSock(struct NaClDesc *pair[2]) {
      15             590 :   struct NaClDescConnCapFd *conn_cap = NULL;
      16             590 :   struct NaClDescImcBoundDesc *bound_sock = NULL;
      17             590 :   NaClHandle fd_pair[2];
      18                 : 
      19             590 :   if (NaClSocketPair(fd_pair) != 0) {
      20               0 :     return -NACL_ABI_EMFILE;
      21                 :   }
      22                 : 
      23             590 :   conn_cap = malloc(sizeof(*conn_cap));
      24             590 :   if (NULL == conn_cap) {
      25               0 :     NaClLog(LOG_FATAL, "NaClCommonDescMakeBoundSock: allocation failed\n");
      26               0 :   }
      27             590 :   if (!NaClDescConnCapFdCtor(conn_cap, fd_pair[0])) {
      28               0 :     NaClLog(LOG_FATAL,
      29                 :             "NaClCommonDescMakeBoundSock: NaClDescConnCapFdCtor failed\n");
      30               0 :   }
      31                 : 
      32             590 :   bound_sock = malloc(sizeof(*bound_sock));
      33             590 :   if (NULL == bound_sock) {
      34               0 :     NaClLog(LOG_FATAL, "NaClCommonDescMakeBoundSock: allocation failed\n");
      35               0 :   }
      36             590 :   if (!NaClDescImcBoundDescCtor(bound_sock, fd_pair[1])) {
      37               0 :     NaClLog(LOG_FATAL,
      38                 :             "NaClCommonDescMakeBoundSock: NaClDescImcBoundDescCtor failed\n");
      39               0 :   }
      40                 : 
      41             590 :   pair[0] = &bound_sock->base;
      42             590 :   pair[1] = &conn_cap->base;
      43             590 :   return 0;
      44             590 : }

Generated by: LCOV version 1.7