From 777094fd126fe31c2490ef8c672e4381675c6958 Mon Sep 17 00:00:00 2001 From: jnemeth Date: Wed, 2 Dec 2015 10:19:58 +0000 Subject: [PATCH] - dereferencing NULL is generally bad, found by visual inspection - automatically set nosync when opening a file to avoid spurious errors --- sbin/gpt/gpt.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sbin/gpt/gpt.c b/sbin/gpt/gpt.c index a83db1fa7ada..93cb5e770acc 100644 --- a/sbin/gpt/gpt.c +++ b/sbin/gpt/gpt.c @@ -35,7 +35,7 @@ __FBSDID("$FreeBSD: src/sbin/gpt/gpt.c,v 1.16 2006/07/07 02:44:23 marcel Exp $"); #endif #ifdef __RCSID -__RCSID("$NetBSD: gpt.c,v 1.54 2015/12/02 04:17:25 christos Exp $"); +__RCSID("$NetBSD: gpt.c,v 1.55 2015/12/02 10:19:58 jnemeth Exp $"); #endif #include @@ -467,7 +467,7 @@ gpt_open(const char *dev, int flags, int verbose, off_t mediasz, u_int secsz) if ((gpt = calloc(1, sizeof(*gpt))) == NULL) { - if (!(gpt->flags & GPT_QUIET)) + if (!(flags & GPT_QUIET)) warn("Cannot allocate `%s'", dev); return NULL; } @@ -525,6 +525,7 @@ gpt_open(const char *dev, int flags, int verbose, off_t mediasz, u_int secsz) goto close; } gpt->mediasz = gpt->sb.st_size; + gpt->flags |= GPT_NOSYNC; } }