diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-04-24 12:13:38 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-04-24 12:13:38 +0000 |
commit | e71895b79ad876d4370f6917c3953830fdcd7237 (patch) | |
tree | 156a6b58be824428930dfbae23fd5ff37528fd37 | |
parent | 485774e9ad63a6f674cd622282e9d1c8fe37db8e (diff) |
Use warnx() if errno is not relevant. close() after errno of
interest is checked, not before.
Less confusing error messages.
-rw-r--r-- | sbin/fdisk/cmd.c | 6 | ||||
-rw-r--r-- | 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); } |