bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: zealous use of error


From: James Morrison
Subject: Re: zealous use of error
Date: Sun, 24 Mar 2002 15:20:14 -0800 (PST)

--- "Thomas Bushnell, BSG" <tb@becket.net> wrote:
> James A Morrison <ja2morri@student.math.uwaterloo.ca> writes:
> 
> > libnetfs:
> >     * make-protid.c (netfs_make_protid): Use err, not errno.
> 
> This one is incorrect; it changes the established interface of
> netfs_make_protid, which is that errno is set on error returns.
> 
> See, for example, libnetfs/fsys-getroot.c which depends on this
> behavior.
> 
> (There are other callers of netfs_make_protid which do not properly
> check for errors, but should.  They would also depend on this
> behavior.)
> 
> 
> Thomas
> 

 Previously netfs_make_protid set errno, no matter what.  So to keep this
behaviour the patch would look like this.

Index: make-protid.c
===================================================================
RCS file: /cvsroot/hurd/hurd/libnetfs/make-protid.c,v
retrieving revision 1.6
diff -u -r1.6 make-protid.c
--- make-protid.c       18 Nov 1996 23:51:10 -0000      1.6
+++ make-protid.c       24 Mar 2002 23:17:25 -0000
@@ -1,5 +1,5 @@
 /* 
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 2002 Free Software Foundation, Inc.
    Written by Michael I. Bushnell, p/BSG.
 
    This file is part of the GNU Hurd
@@ -23,17 +23,19 @@
 struct protid *
 netfs_make_protid (struct peropen *po, struct iouser *cred)
 {
+  error_t err;
   struct protid *pi;
 
   if (cred)
-    errno = ports_create_port (netfs_protid_class, netfs_port_bucket, 
-                              sizeof (struct protid), &pi);
+    err = ports_create_port (netfs_protid_class, netfs_port_bucket, 
+                            sizeof (struct protid), &pi);
   else
-    errno = ports_create_port_noinstall (netfs_protid_class,
-                                        netfs_port_bucket, 
-                                        sizeof (struct protid), &pi);
+    err = ports_create_port_noinstall (netfs_protid_class,
+                                      netfs_port_bucket, 
+                                      sizeof (struct protid), &pi);
     
-  if (errno)
+  errno = err;
+  if (err)
     return 0;
 
   po->refcnt++;


=====
James Morrison
   University of Waterloo
   Computer Science - Digital Hardware
   2A co-op
http://hurd.dyndns.org

Anyone refering this as 'Open Source' shall be eaten by a GNU

__________________________________________________
Do You Yahoo!?
Yahoo! Movies - coverage of the 74th Academy Awards®
http://movies.yahoo.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]