From 45a092d74e3dedf641d58d4f2732a7da23cbebbe Mon Sep 17 00:00:00 2001 From: krw Date: Sun, 24 Apr 2022 12:13:37 +0000 Subject: [PATCH] Use warnx() if errno is not relevant. close() after errno of interest is checked, not before. Less confusing error messages. --- sbin/fdisk/cmd.c | 6 +++--- sbin/fdisk/fdisk.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index 432308006e1..c0a820f4fa6 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.157 2022/04/20 15:49:56 krw Exp $ */ +/* $OpenBSD: cmd.c,v 1.158 2022/04/24 12:13:37 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -394,13 +394,13 @@ Xwrite(char *args, struct mbr *mbr) if (gh.gh_sig == GPTSIGNATURE) { printf("Writing GPT.\n"); if (GPT_write() == -1) { - warn("error writing GPT"); + warnx("error writing GPT"); return CMD_CONT; } } else { printf("Writing MBR at offset %llu.\n", mbr->mbr_lba_self); if (MBR_write(mbr) == -1) { - warn("error writing MBR"); + warnx("error writing MBR"); return CMD_CONT; } GPT_zap_headers(); diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index 0a68b197e29..c9b58c78c53 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdisk.c,v 1.143 2022/03/11 22:29:55 krw Exp $ */ +/* $OpenBSD: fdisk.c,v 1.144 2022/04/24 12:13:37 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -275,10 +275,10 @@ get_default_dmbr(const char *mbrfile) sz = sizeof(*dmbr); len = read(fd, dmbr, sz); - close(fd); - if (len == -1) err(1, "read('%s')", mbrfile); else if (len != sz) errx(1, "read('%s'): read %zd bytes of %zd", mbrfile, len, sz); + + close(fd); } -- 2.20.1