LCOV - code coverage report
Current view: directory - src/trusted/desc/posix - nacl_makeboundsock.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 18 13 72.2 %
Date: 2012-02-16 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright 2010 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can
       4                 :  * be 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              36 : int32_t NaClCommonDescMakeBoundSock(struct NaClDesc *pair[2]) {
      15              36 :   struct NaClDescConnCapFd *conn_cap = NULL;
      16              36 :   struct NaClDescImcBoundDesc *bound_sock = NULL;
      17                 :   NaClHandle fd_pair[2];
      18                 : 
      19              36 :   if (NaClSocketPair(fd_pair) != 0) {
      20               0 :     return -NACL_ABI_EMFILE;
      21                 :   }
      22                 : 
      23              36 :   conn_cap = malloc(sizeof(*conn_cap));
      24              36 :   if (NULL == conn_cap) {
      25               0 :     NaClLog(LOG_FATAL, "NaClCommonDescMakeBoundSock: allocation failed");
      26                 :   }
      27              36 :   if (!NaClDescConnCapFdCtor(conn_cap, fd_pair[0])) {
      28               0 :     NaClLog(LOG_FATAL,
      29                 :             "NaClCommonDescMakeBoundSock: NaClDescConnCapFdCtor failed");
      30                 :   }
      31                 : 
      32              36 :   bound_sock = malloc(sizeof(*bound_sock));
      33              36 :   if (NULL == bound_sock) {
      34               0 :     NaClLog(LOG_FATAL, "NaClCommonDescMakeBoundSock: allocation failed");
      35                 :   }
      36              36 :   if (!NaClDescImcBoundDescCtor(bound_sock, fd_pair[1])) {
      37               0 :     NaClLog(LOG_FATAL, "NaClCommonDescMakeBoundSock: NaClDescCtor failed");
      38                 :   }
      39                 : 
      40              36 :   pair[0] = &bound_sock->base;
      41              36 :   pair[1] = &conn_cap->base;
      42              36 :   return 0;
      43                 : }

Generated by: LCOV version 1.7