Bug Summary

File:libports/create-internal.c
Location:line 109, column 3
Description:Value stored to 'err' is never read

Annotated Source Code

1/*
2 Copyright (C) 1996,2001 Free Software Foundation, Inc.
3 Written by Michael I. Bushnell, p/BSG.
4
5 This file is part of the GNU Hurd.
6
7 The GNU Hurd is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
11
12 The GNU Hurd is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
20
21#include <assert.h>
22#include <hurd/ihash.h>
23#include "ports.h"
24
25/* Create and return in RESULT a new port in CLASS and BUCKET; SIZE
26 bytes will be allocated to hold the port structure and whatever
27 private data the user desires. If INSTALL is set, put the port
28 right into BUCKET's port set. */
29error_t
30_ports_create_port_internal (struct port_class *class,
31 struct port_bucket *bucket,
32 size_t size, void *result,
33 int install)
34{
35 mach_port_t port;
36 error_t err;
37 struct port_info *pi;
38
39 err = mach_port_allocate (mach_task_self ()((__mach_task_self_ + 0)), MACH_PORT_RIGHT_RECEIVE((mach_port_right_t) 1),
40 &port);
41 if (err)
42 return err;
43
44 if (size < sizeof (struct port_info))
45 size = sizeof (struct port_info);
46
47 pi = malloc (size);
48 if (! pi)
49 {
50 err = mach_port_mod_refs (mach_task_self ()((__mach_task_self_ + 0)), port,
51 MACH_PORT_RIGHT_RECEIVE((mach_port_right_t) 1), -1);
52 assert_perror (err)(!(err) ? (void) (0) : __assert_perror_fail ((err), "create-internal.c"
, 52, __PRETTY_FUNCTION__))
;
53 return ENOMEM((0x10 << 26) | ((12) & 0x3fff));
54 }
55
56 pi->class = class;
57 pi->refcnt = 1;
58 pi->weakrefcnt = 0;
59 pi->cancel_threshold = 0;
60 pi->mscount = 0;
61 pi->flags = 0;
62 pi->port_right = port;
63 pi->current_rpcs = 0;
64 pi->bucket = bucket;
65
66 pthread_mutex_lock (&_ports_lock);
67
68 loop:
69 if (class->flags & PORT_CLASS_NO_ALLOC0x0800)
70 {
71 class->flags |= PORT_CLASS_ALLOC_WAIT0x1000;
72 if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
73 goto cancelled;
74 goto loop;
75 }
76 if (bucket->flags & PORT_BUCKET_NO_ALLOC0x0800)
77 {
78 bucket->flags |= PORT_BUCKET_ALLOC_WAIT0x1000;
79 if (pthread_hurd_cond_wait_np (&_ports_block, &_ports_lock))
80 goto cancelled;
81 goto loop;
82 }
83
84 err = hurd_ihash_add (&bucket->htable, port, pi);
85 if (err)
86 goto lose;
87
88 pi->next = class->ports;
89 pi->prevp = &class->ports;
90 if (class->ports)
91 class->ports->prevp = &pi->next;
92 class->ports = pi;
93 bucket->count++;
94 class->count++;
95 pthread_mutex_unlock (&_ports_lock);
96
97 if (install)
98 {
99 err = mach_port_move_member (mach_task_self ()((__mach_task_self_ + 0)), pi->port_right,
100 bucket->portset);
101 if (err)
102 goto lose_unlocked;
103 }
104
105 *(void **)result = pi;
106 return 0;
107
108 cancelled:
109 err = EINTR((0x10 << 26) | ((4) & 0x3fff));
Value stored to 'err' is never read
110 lose:
111 pthread_mutex_unlock (&_ports_lock);
112 lose_unlocked:
113 err = mach_port_mod_refs (mach_task_self ()((__mach_task_self_ + 0)), port,
114 MACH_PORT_RIGHT_RECEIVE((mach_port_right_t) 1), -1);
115 assert_perror (err)(!(err) ? (void) (0) : __assert_perror_fail ((err), "create-internal.c"
, 115, __PRETTY_FUNCTION__))
;
116 free (pi);
117
118 return err;
119}
120