From e6b7ef9676739dc393c5dcd62cd5658e9a16e615 Mon Sep 17 00:00:00 2001 From: lukem Date: Mon, 29 Sep 1997 06:08:45 +0000 Subject: [PATCH] reorder some checks so that buf is initialised as early as possible (just after the check for buf != NULL) --- lib/libutil/opendisk.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/libutil/opendisk.c b/lib/libutil/opendisk.c index 3ee85cf9fac1..0c55aed10f3a 100644 --- a/lib/libutil/opendisk.c +++ b/lib/libutil/opendisk.c @@ -1,4 +1,4 @@ -/* $NetBSD: opendisk.c,v 1.1 1997/09/25 04:53:33 lukem Exp $ */ +/* $NetBSD: opendisk.c,v 1.2 1997/09/29 06:08:45 lukem Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -38,7 +38,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: opendisk.c,v 1.1 1997/09/25 04:53:33 lukem Exp $"); +__RCSID("$NetBSD: opendisk.c,v 1.2 1997/09/29 06:08:45 lukem Exp $"); #endif #include @@ -61,21 +61,21 @@ opendisk(path, flags, buf, buflen, iscooked) { int f, rawpart; - if ((flags & O_CREAT) != 0) { - errno = EINVAL; - return (-1); - } if (buf == NULL) { errno = EFAULT; return (-1); } + snprintf(buf, buflen, "%s", path); + + if ((flags & O_CREAT) != 0) { + errno = EINVAL; + return (-1); + } rawpart = getrawpartition(); if (rawpart < 0) return (-1); /* sysctl(3) in getrawpartition sets errno */ - snprintf(buf, buflen, "%s", path); - f = open(buf, flags); if (f != -1 || errno != ENOENT) return (f);