Source-Changes-HG archive

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

[src/trunk]: src/lib/libutil read returns ssize_t, and err is a function name.



details:   https://anonhg.NetBSD.org/src/rev/deab115d0062
branches:  trunk
changeset: 778655:deab115d0062
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 07 16:17:17 2012 +0000

description:
read returns ssize_t, and err is a function name.

diffstat:

 lib/libutil/pidlock.c |  20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diffs (64 lines):

diff -r d801c486735a -r deab115d0062 lib/libutil/pidlock.c
--- a/lib/libutil/pidlock.c     Sat Apr 07 16:16:34 2012 +0000
+++ b/lib/libutil/pidlock.c     Sat Apr 07 16:17:17 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pidlock.c,v 1.15 2009/01/18 12:13:04 lukem Exp $ */
+/*     $NetBSD: pidlock.c,v 1.16 2012/04/07 16:17:17 christos Exp $ */
 
 /*
  * Copyright 1996, 1997 by Curt Sampson <cjs%NetBSD.org@localhost>.
@@ -24,7 +24,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: pidlock.c,v 1.15 2009/01/18 12:13:04 lukem Exp $");
+__RCSID("$NetBSD: pidlock.c,v 1.16 2012/04/07 16:17:17 christos Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 #include <sys/param.h>
@@ -52,8 +52,8 @@
        char    hostname[MAXHOSTNAMELEN + 1];
        pid_t   pid2 = -1;
        struct  stat st;
-       int     err;
-       int     f = -1;
+       ssize_t n;
+       int     f = -1, savee;
        char    s[256];
        char    *p;
        size_t  len;
@@ -114,16 +114,16 @@
                        goto out;
                /* Find out who has this lockfile. */
                if ((f = open(lockfile, O_RDONLY, 0)) != -1)  {
-                       if ((err = read(f, s, (size_t)11)) == -1)
+                       if ((n = read(f, s, (size_t)11)) == -1)
                                goto out;
-                       if (err == 0) {
+                       if (n == 0) {
                                errno = EINVAL;
                                goto out;
                        }
                        pid2 = atoi(s);
-                       if ((err = read(f, s, sizeof(s) - 2)) == -1)
+                       if ((n = read(f, s, sizeof(s) - 2)) == -1)
                                goto out;
-                       if (err == 0)
+                       if (n == 0)
                                *s = '\0';
                        s[sizeof(s) - 1] = '\0';
                        if ((p = strchr(s, '\n')) != NULL)
@@ -164,11 +164,11 @@
        errno = 0;
        return 0;
 out:
-       err = errno;
+       savee = errno;
        if (f != -1)
                (void)close(f);
        (void)unlink(tempfile);
-       errno = err;
+       errno = savee;
        return -1;
 }
 



Home | Main Index | Thread Index | Old Index