Bug Summary

File:obj-scan-build/libnetfs/../../libnetfs/fsys-getroot.c
Location:line 84, column 7
Description:Value stored to 'err' is never read

Annotated Source Code

1/*
2 Copyright (C) 1996,97,2001,02 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 "netfs.h"
22#include "fsys_S.h"
23#include "misc.h"
24#include "callbacks.h"
25#include <fcntl.h>
26
27error_t
28netfs_S_fsys_getroot (struct netfs_control *pt,
29 mach_port_t reply,
30 mach_msg_type_name_t reply_type,
31 mach_port_t dotdot,
32 uid_t *uids, mach_msg_type_number_t nuids,
33 uid_t *gids, mach_msg_type_number_t ngids,
34 int flags,
35 retry_type *do_retry,
36 char *retry_name,
37 mach_port_t *retry_port,
38 mach_msg_type_name_t *retry_port_type)
39{
40 struct iouser *cred;
41 error_t err;
42 struct protid *newpi;
43 mode_t type;
44 struct peropen peropen_context =
45 {
46 root_parent: dotdot,
47 path: NULL((void*)0),
48 };
49
50 if (!pt)
51 return EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff));
52
53 err = iohelp_create_complex_iouser (&cred, uids, nuids, gids, ngids);
54 if (err)
55 return err;
56
57 flags &= O_HURD(0xffff | 0x00040000 | 0x00020000);
58
59 pthread_mutex_lock (&netfs_root_node->lock);
60 err = netfs_validate_stat (netfs_root_node, cred);
61 if (err)
62 goto out;
63
64 type = netfs_root_node->nn_stat.st_mode & S_IFMT0170000;
65
66 if (((netfs_root_node->nn_stat.st_mode & S_IPTRANS000010000000)
67 || fshelp_translated (&netfs_root_node->transbox))
68 && !(flags & O_NOTRANS0x0080))
69 {
70 err = fshelp_fetch_root (&netfs_root_node->transbox,
71 &peropen_context, dotdot, cred, flags,
72 _netfs_translator_callback1,
73 _netfs_translator_callback2,
74 do_retry, retry_name, retry_port);
75 if (err != ENOENT((0x10 << 26) | ((2) & 0x3fff)))
76 {
77 pthread_mutex_unlock (&netfs_root_node->lock);
78 iohelp_free_iouser (cred);
79 if (!err)
80 *retry_port_type = MACH_MSG_TYPE_MOVE_SEND17;
81 return err;
82 }
83 /* ENOENT means translator has vanished inside fshelp_fetch_root. */
84 err = 0;
Value stored to 'err' is never read
85 }
86
87 if (type == S_IFLNK0120000 && !(flags & (O_NOLINK0x0040 | O_NOTRANS0x0080)))
88 {
89 char pathbuf[netfs_root_node->nn_stat.st_size + 1];
90
91 err = netfs_attempt_readlink (cred, netfs_root_node, pathbuf);
92
93 if (err)
94 goto out;
95
96 pthread_mutex_unlock (&netfs_root_node->lock);
97 iohelp_free_iouser (cred);
98
99 if (pathbuf[0] == '/')
100 {
101 *do_retry = FS_RETRY_MAGICAL;
102 *retry_port = MACH_PORT_NULL((mach_port_t) 0);
103 *retry_port_type = MACH_MSG_TYPE_COPY_SEND19;
104 strcpy (retry_name, pathbuf);
105 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), dotdot);
106 return 0;
107 }
108 else
109 {
110 *do_retry = FS_RETRY_REAUTH;
111 *retry_port = dotdot;
112 *retry_port_type = MACH_MSG_TYPE_MOVE_SEND17;
113 strcpy (retry_name, pathbuf);
114 return 0;
115 }
116 }
117
118 if ((type == S_IFSOCK0140000 || type == S_IFBLK0060000 || type == S_IFCHR0020000
119 || type == S_IFIFO0010000) && (flags & (O_READ0x0001|O_WRITE0x0002|O_EXEC0x0004)))
120 {
121 err = EOPNOTSUPP((0x10 << 26) | ((45) & 0x3fff));
122 goto out;
123 }
124
125 err = netfs_check_open_permissions (cred, netfs_root_node, flags, 0);
126 if (err)
127 goto out;
128
129 flags &= ~OPENONLY_STATE_MODES(0x0010|0x0020|0x0040|0x0080);
130
131 newpi = netfs_make_protid (netfs_make_peropen (netfs_root_node, flags,
132 &peropen_context),
133 cred);
134 mach_port_deallocate (mach_task_self ()((__mach_task_self_ + 0)), dotdot);
135
136 *do_retry = FS_RETRY_NORMAL;
137 *retry_port = ports_get_right (newpi);
138 *retry_port_type = MACH_MSG_TYPE_MAKE_SEND20;
139 retry_name[0] = '\0';
140 ports_port_deref (newpi);
141
142 out:
143 if (err)
144 iohelp_free_iouser (cred);
145 pthread_mutex_unlock (&netfs_root_node->lock);
146 return err;
147}